iamauthtest

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2022 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestServer

func NewTestServer(t *testing.T, s *Server) *httptest.Server

NewTestServer returns a fake AWS API server for local tests: It supports the following paths:

/sts returns STS API responses
/iam returns IAM API responses

Types

type Fixture

type Fixture struct {
	AssumedRoleARN   string
	CanonicalRoleARN string
	RoleARN          string
	RoleARNWildcard  string
	RoleName         string
	RolePath         string
	RoleTags         map[string]string

	EntityID            string
	EntityIDWithSession string
	AccountID           string

	UserARN         string
	UserARNWildcard string
	UserName        string
	UserPath        string
	UserTags        map[string]string

	ServerForRole *Server
	ServerForUser *Server
}

func MakeFixture

func MakeFixture() Fixture

func (*Fixture) RoleTagKeys

func (f *Fixture) RoleTagKeys() []string

func (*Fixture) RoleTagValues

func (f *Fixture) RoleTagValues() []string

func (*Fixture) UserTagKeys

func (f *Fixture) UserTagKeys() []string

func (*Fixture) UserTagValues

func (f *Fixture) UserTagValues() []string

type GetCallerIdentityResponse

type GetCallerIdentityResponse struct {
	XMLName                 xml.Name                  `xml:"GetCallerIdentityResponse"`
	GetCallerIdentityResult []GetCallerIdentityResult `xml:"GetCallerIdentityResult"`
	ResponseMetadata        []ResponseMetadata        `xml:"ResponseMetadata"`
}

func MakeGetCallerIdentityResponse

func MakeGetCallerIdentityResponse(arn, userId, accountId string) GetCallerIdentityResponse

type GetCallerIdentityResult

type GetCallerIdentityResult struct {
	Arn     string `xml:"Arn"`
	UserId  string `xml:"UserId"`
	Account string `xml:"Account"`
}

type GetRoleResponse

type GetRoleResponse struct {
	XMLName          xml.Name           `xml:"GetRoleResponse"`
	GetRoleResult    []GetRoleResult    `xml:"GetRoleResult"`
	ResponseMetadata []ResponseMetadata `xml:"ResponseMetadata"`
}

func MakeGetRoleResponse

func MakeGetRoleResponse(arn, id string, tags Tags) GetRoleResponse

type GetRoleResult

type GetRoleResult struct {
	Role Role `xml:"Role"`
}

type GetUserResponse

type GetUserResponse struct {
	XMLName          xml.Name           `xml:"GetUserResponse"`
	GetUserResult    []GetUserResult    `xml:"GetUserResult"`
	ResponseMetadata []ResponseMetadata `xml:"ResponseMetadata"`
}

func MakeGetUserResponse

func MakeGetUserResponse(arn, id string, tags Tags) GetUserResponse

type GetUserResult

type GetUserResult struct {
	User User `xml:"User"`
}

type IAMEntity

type IAMEntity interface {
	EntityPath() string
	EntityArn() string
	EntityName() string
	EntityId() string
	EntityTags() map[string]string
}

IAMEntity is an interface for getting details from an IAM Role or User.

type ParsedArn

type ParsedArn struct {
	Partition     string
	AccountNumber string
	Type          string
	Path          string
	FriendlyName  string
	SessionInfo   string
}

https://github.com/hashicorp/vault/blob/ba533d006f2244103648785ebfe8a9a9763d2b6e/builtin/credential/aws/path_login.go#L1722-L1744

func (*ParsedArn) CanonicalArn

func (p *ParsedArn) CanonicalArn() string

CanonicalArn returns the canonical ARN for referring to an IAM entity

type ResponseMetadata

type ResponseMetadata struct {
	RequestId string `xml:"RequestId"`
}

type Role

type Role struct {
	Arn      string `xml:"Arn"`
	Path     string `xml:"Path"`
	RoleId   string `xml:"RoleId"`
	RoleName string `xml:"RoleName"`
	Tags     Tags   `xml:"Tags"`
}

func (*Role) EntityArn

func (r *Role) EntityArn() string

func (*Role) EntityId

func (r *Role) EntityId() string

func (*Role) EntityName

func (r *Role) EntityName() string

func (*Role) EntityPath

func (r *Role) EntityPath() string

func (*Role) EntityTags

func (r *Role) EntityTags() map[string]string

type Server

type Server struct {
	GetCallerIdentityResponse GetCallerIdentityResponse
	GetRoleResponse           GetRoleResponse
	GetUserResponse           GetUserResponse
}

Server contains configuration for the fake AWS API server.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type TagMember

type TagMember struct {
	Key   string `xml:"Key"`
	Value string `xml:"Value"`
}

type Tags

type Tags struct {
	Members []TagMember `xml:"member"`
}

type User

type User struct {
	Arn      string `xml:"Arn"`
	Path     string `xml:"Path"`
	UserId   string `xml:"UserId"`
	UserName string `xml:"UserName"`
	Tags     Tags   `xml:"Tags"`
}

func (*User) EntityArn

func (u *User) EntityArn() string

func (*User) EntityId

func (u *User) EntityId() string

func (*User) EntityName

func (u *User) EntityName() string

func (*User) EntityPath

func (u *User) EntityPath() string

func (*User) EntityTags

func (u *User) EntityTags() map[string]string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL