Documentation ¶
Index ¶
- Constants
- Variables
- func AccountID(id string) string
- func RouteMethod(r interface{}, q *Request) bool
- func WriteJSON(w http.ResponseWriter, v interface{})
- type AWS
- type ChainRouter
- func (r *ChainRouter) Add(t ...Router)
- func (r *ChainRouter) DataTypeRouter() (t DataTypeRouter)
- func (r ChainRouter) Find(v interface{}) bool
- func (r ChainRouter) OrgRouter() (t *OrgRouter)
- func (r *ChainRouter) RoleRouter() (t RoleRouter)
- func (r ChainRouter) Route(q *Request) bool
- func (r *ChainRouter) STSRouter() (t STSRouter)
- func (r *ChainRouter) UserRouter() (t UserRouter)
- type CtxRouter
- type DataTypeRouter
- type OrgRouter
- func (r *OrgRouter) All() []*orgs.Account
- func (r *OrgRouter) CreateAccount(q *Request, in *orgs.CreateAccountInput)
- func (r *OrgRouter) DescribeAccount(q *Request, in *orgs.DescribeAccountInput)
- func (r *OrgRouter) DescribeCreateAccountStatus(q *Request, in *orgs.DescribeCreateAccountStatusInput)
- func (r *OrgRouter) DescribeOrganization(q *Request, _ *orgs.DescribeOrganizationInput)
- func (r *OrgRouter) Get(id string) *orgs.Account
- func (r *OrgRouter) ListAccounts(q *Request, _ *orgs.ListAccountsInput)
- func (r *OrgRouter) NewAccount(name string) *orgs.Account
- func (r *OrgRouter) Route(q *Request) bool
- type Request
- type Response
- type Role
- type RoleRouter
- func (r RoleRouter) AttachRolePolicy(q *Request, in *iam.AttachRolePolicyInput)
- func (r RoleRouter) CreateRole(q *Request, in *iam.CreateRoleInput)
- func (r RoleRouter) DeleteRole(q *Request, in *iam.DeleteRoleInput)
- func (r RoleRouter) DeleteRolePolicy(q *Request, in *iam.DeleteRolePolicyInput)
- func (r RoleRouter) DetachRolePolicy(q *Request, in *iam.DetachRolePolicyInput)
- func (r RoleRouter) GetRole(q *Request, in *iam.GetRoleInput)
- func (r RoleRouter) ListAttachedRolePolicies(q *Request, in *iam.ListAttachedRolePoliciesInput)
- func (r RoleRouter) ListRolePolicies(q *Request, in *iam.ListRolePoliciesInput)
- func (r RoleRouter) ListRoles(q *Request, in *iam.ListRolesInput)
- func (r RoleRouter) PutRolePolicy(q *Request, in *iam.PutRolePolicyInput)
- func (r RoleRouter) Route(q *Request) bool
- func (r RoleRouter) UpdateAssumeRolePolicy(q *Request, in *iam.UpdateAssumeRolePolicyInput)
- func (r RoleRouter) UpdateRoleDescription(q *Request, in *iam.UpdateRoleDescriptionInput)
- type Router
- type RouterFunc
- type STSRouter
- type Server
- type User
- type UserRouter
- func (r UserRouter) AttachUserPolicy(q *Request, in *iam.AttachUserPolicyInput)
- func (r UserRouter) CreateAccessKey(q *Request, in *iam.CreateAccessKeyInput)
- func (r UserRouter) CreateUser(q *Request, in *iam.CreateUserInput)
- func (r UserRouter) DeleteAccessKey(q *Request, in *iam.DeleteAccessKeyInput)
- func (r UserRouter) DeleteUser(q *Request, in *iam.DeleteUserInput)
- func (r UserRouter) DetachUserPolicy(q *Request, in *iam.DetachUserPolicyInput)
- func (r UserRouter) GetUser(q *Request, in *iam.GetUserInput)
- func (r UserRouter) ListAccessKeys(q *Request, in *iam.ListAccessKeysInput)
- func (r UserRouter) ListAttachedUserPolicies(q *Request, in *iam.ListAttachedUserPoliciesInput)
- func (r UserRouter) ListUsers(q *Request, in *iam.ListUsersInput)
- func (r UserRouter) Route(q *Request) bool
Constants ¶
const ( AccessKeyID = "ASIAIOSFODNN7EXAMPLE" SecretAccessKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY" )
Mock STS credentials.
Variables ¶
var Ctx = arn.Ctx{Partition: "aws", Region: "us-east-1", Account: "000000000000"}
Ctx is a mock ARN context.
Functions ¶
func RouteMethod ¶
RouteMethod uses reflection to find a method of r that matches the API name. If such method is found, it handles the request. The method type must be:
func(q *mock.Request, in *svc.XyzInput)
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, v interface{})
WriteJSON writes JSON encoding of v to w.
Types ¶
type AWS ¶
AWS is a mock AWS cloud that uses routers to handle requests.
func NewAWS ¶
NewAWS returns a mock AWS cloud configured with the specified context and custom routers. The STS router is added to the root context automatically.
func (*AWS) SessionToken ¶
SessionToken returns the session token for the specified account/role.
type ChainRouter ¶
type ChainRouter []Router
ChainRouter maintains a router chain, passing requests to each router, starting with the last one, until the request is handled.
func (*ChainRouter) Add ¶
func (r *ChainRouter) Add(t ...Router)
Add appends new routers to the chain, giving them highest priority.
func (*ChainRouter) DataTypeRouter ¶
func (r *ChainRouter) DataTypeRouter() (t DataTypeRouter)
DataTypeRouter returns the highest priority DataTypeRouter in the chain. A new router is created if one does not exist.
func (ChainRouter) Find ¶
func (r ChainRouter) Find(v interface{}) bool
Find assigns v, which must be a Router pointer, the highest priority router of the matching type.
func (ChainRouter) OrgRouter ¶
func (r ChainRouter) OrgRouter() (t *OrgRouter)
OrgRouter returns the highest priority OrgRouter in the chain.
func (*ChainRouter) RoleRouter ¶
func (r *ChainRouter) RoleRouter() (t RoleRouter)
RoleRouter returns the highest priority RoleRouter in the chain. A new router is created if one does not exist.
func (ChainRouter) Route ¶
func (r ChainRouter) Route(q *Request) bool
Route implements the Router interface.
func (*ChainRouter) STSRouter ¶
func (r *ChainRouter) STSRouter() (t STSRouter)
STSRouter returns the highest priority STSRouter in the chain. A new router is created if one does not exist.
func (*ChainRouter) UserRouter ¶
func (r *ChainRouter) UserRouter() (t UserRouter)
UserRouter returns the highest priority UserRouter in the chain. A new router is created if one does not exist.
type CtxRouter ¶
type CtxRouter map[arn.Ctx]*ChainRouter
CtxRouter redirects requests to other routers using the ARN context. More specific context keys take priority over less specific ones. The zero value context matches all requests.
func (CtxRouter) Account ¶
func (r CtxRouter) Account(id string) *ChainRouter
Account returns the router for the specified account ID.
func (CtxRouter) Get ¶
func (r CtxRouter) Get(ctx arn.Ctx) *ChainRouter
Get returns the router for the specified context. A new router is created if one does not exist.
func (CtxRouter) Root ¶
func (r CtxRouter) Root() *ChainRouter
Root returns the router that matches all contexts.
type DataTypeRouter ¶
DataTypeRouter handles requests based on the Data field type.
func NewDataTypeRouter ¶
func NewDataTypeRouter(out ...interface{}) DataTypeRouter
NewDataTypeRouter returns a router that will serve 'out' values to all requests with a matching data output type. All out values should be pointers to AWS SDK XyzOutput structs.
func (DataTypeRouter) Get ¶
func (r DataTypeRouter) Get(out interface{}) error
Get copies a response value of the matching type into out and returns the associated error, if any.
func (DataTypeRouter) Route ¶
func (r DataTypeRouter) Route(q *Request) bool
Route implements the Router interface.
func (DataTypeRouter) Set ¶
func (r DataTypeRouter) Set(out interface{}, err error)
Set allows the router to handle API requests with the given output type. If err is not nil, it will be used to set the request's Error field.
type OrgRouter ¶
OrgRouter handles Organizations API calls.
func NewOrg ¶
NewOrg creates a new AWS organization router consisting of a master account and any number of additional non-master accounts. Account IDs are assigned sequentially starting from ctx.Account.
func (*OrgRouter) CreateAccount ¶
func (r *OrgRouter) CreateAccount(q *Request, in *orgs.CreateAccountInput)
func (*OrgRouter) DescribeAccount ¶
func (r *OrgRouter) DescribeAccount(q *Request, in *orgs.DescribeAccountInput)
func (*OrgRouter) DescribeCreateAccountStatus ¶
func (r *OrgRouter) DescribeCreateAccountStatus(q *Request, in *orgs.DescribeCreateAccountStatusInput)
func (*OrgRouter) DescribeOrganization ¶
func (r *OrgRouter) DescribeOrganization(q *Request, _ *orgs.DescribeOrganizationInput)
func (*OrgRouter) ListAccounts ¶
func (r *OrgRouter) ListAccounts(q *Request, _ *orgs.ListAccountsInput)
func (*OrgRouter) NewAccount ¶
NewAccount adds a new account to the organization.
type Response ¶
type Response struct { Out interface{} Err error }
Response contains values that are assigned to request Data and Error fields.
type RoleRouter ¶
RoleRouter handles IAM role API calls.
func (RoleRouter) AttachRolePolicy ¶
func (r RoleRouter) AttachRolePolicy(q *Request, in *iam.AttachRolePolicyInput)
func (RoleRouter) CreateRole ¶
func (r RoleRouter) CreateRole(q *Request, in *iam.CreateRoleInput)
func (RoleRouter) DeleteRole ¶
func (r RoleRouter) DeleteRole(q *Request, in *iam.DeleteRoleInput)
func (RoleRouter) DeleteRolePolicy ¶
func (r RoleRouter) DeleteRolePolicy(q *Request, in *iam.DeleteRolePolicyInput)
func (RoleRouter) DetachRolePolicy ¶
func (r RoleRouter) DetachRolePolicy(q *Request, in *iam.DetachRolePolicyInput)
func (RoleRouter) GetRole ¶
func (r RoleRouter) GetRole(q *Request, in *iam.GetRoleInput)
func (RoleRouter) ListAttachedRolePolicies ¶
func (r RoleRouter) ListAttachedRolePolicies(q *Request, in *iam.ListAttachedRolePoliciesInput)
func (RoleRouter) ListRolePolicies ¶
func (r RoleRouter) ListRolePolicies(q *Request, in *iam.ListRolePoliciesInput)
func (RoleRouter) ListRoles ¶
func (r RoleRouter) ListRoles(q *Request, in *iam.ListRolesInput)
func (RoleRouter) PutRolePolicy ¶
func (r RoleRouter) PutRolePolicy(q *Request, in *iam.PutRolePolicyInput)
func (RoleRouter) Route ¶
func (r RoleRouter) Route(q *Request) bool
Route implements the Router interface.
func (RoleRouter) UpdateAssumeRolePolicy ¶
func (r RoleRouter) UpdateAssumeRolePolicy(q *Request, in *iam.UpdateAssumeRolePolicyInput)
func (RoleRouter) UpdateRoleDescription ¶
func (r RoleRouter) UpdateRoleDescription(q *Request, in *iam.UpdateRoleDescriptionInput)
type Router ¶
Router simulates AWS responses by populating request Data and Error fields. Route returns true if the request was handled or false if it should be passed to the next router.
type RouterFunc ¶
RouterFunc allows using a regular function as a router.
func (RouterFunc) Route ¶
func (f RouterFunc) Route(q *Request) bool
Route implements the Router interface.
type STSRouter ¶
type STSRouter map[arn.ARN]*sts.GetCallerIdentityOutput
STSRouter handles STS API calls. Key is SessionToken, which is the assumed role ARN, as returned by GetCallerIdentity.
func (STSRouter) AssumeRole ¶
func (r STSRouter) AssumeRole(q *Request, in *sts.AssumeRoleInput)
func (STSRouter) GetCallerIdentity ¶
func (r STSRouter) GetCallerIdentity(q *Request, _ *sts.GetCallerIdentityInput)
type Server ¶
Server is a mock HTTP server.
func ClientServer ¶
ClientServer returns an HTTP client connected to a mock server.
type User ¶
type User struct { iam.User AccessKeys []*iam.AccessKeyMetadata AttachedPolicies map[arn.ARN]string }
User is a mock IAM user.
type UserRouter ¶
UserRouter handles IAM user API calls.
func (UserRouter) AttachUserPolicy ¶
func (r UserRouter) AttachUserPolicy(q *Request, in *iam.AttachUserPolicyInput)
func (UserRouter) CreateAccessKey ¶
func (r UserRouter) CreateAccessKey(q *Request, in *iam.CreateAccessKeyInput)
func (UserRouter) CreateUser ¶
func (r UserRouter) CreateUser(q *Request, in *iam.CreateUserInput)
func (UserRouter) DeleteAccessKey ¶
func (r UserRouter) DeleteAccessKey(q *Request, in *iam.DeleteAccessKeyInput)
func (UserRouter) DeleteUser ¶
func (r UserRouter) DeleteUser(q *Request, in *iam.DeleteUserInput)
func (UserRouter) DetachUserPolicy ¶
func (r UserRouter) DetachUserPolicy(q *Request, in *iam.DetachUserPolicyInput)
func (UserRouter) GetUser ¶
func (r UserRouter) GetUser(q *Request, in *iam.GetUserInput)
func (UserRouter) ListAccessKeys ¶
func (r UserRouter) ListAccessKeys(q *Request, in *iam.ListAccessKeysInput)
func (UserRouter) ListAttachedUserPolicies ¶
func (r UserRouter) ListAttachedUserPolicies(q *Request, in *iam.ListAttachedUserPoliciesInput)
func (UserRouter) ListUsers ¶
func (r UserRouter) ListUsers(q *Request, in *iam.ListUsersInput)
func (UserRouter) Route ¶
func (r UserRouter) Route(q *Request) bool
Route implements the Router interface.