diff options
Diffstat (limited to 'vendor/github.com/goamz/goamz/iam')
-rw-r--r-- | vendor/github.com/goamz/goamz/iam/iam.go | 643 | ||||
-rw-r--r-- | vendor/github.com/goamz/goamz/iam/iam_test.go | 450 | ||||
-rw-r--r-- | vendor/github.com/goamz/goamz/iam/iami_test.go | 209 | ||||
-rw-r--r-- | vendor/github.com/goamz/goamz/iam/iamt_test.go | 39 | ||||
-rw-r--r-- | vendor/github.com/goamz/goamz/iam/iamtest/server.go | 432 | ||||
-rw-r--r-- | vendor/github.com/goamz/goamz/iam/responses_test.go | 261 | ||||
-rw-r--r-- | vendor/github.com/goamz/goamz/iam/sign.go | 38 |
7 files changed, 0 insertions, 2072 deletions
diff --git a/vendor/github.com/goamz/goamz/iam/iam.go b/vendor/github.com/goamz/goamz/iam/iam.go deleted file mode 100644 index 7271f1bf6..000000000 --- a/vendor/github.com/goamz/goamz/iam/iam.go +++ /dev/null @@ -1,643 +0,0 @@ -// The iam package provides types and functions for interaction with the AWS -// Identity and Access Management (IAM) service. -package iam - -import ( - "encoding/xml" - "net/http" - "net/url" - "strconv" - "strings" - "time" - - "github.com/goamz/goamz/aws" -) - -// The IAM type encapsulates operations operations with the IAM endpoint. -type IAM struct { - aws.Auth - aws.Region - httpClient *http.Client -} - -// New creates a new IAM instance. -func New(auth aws.Auth, region aws.Region) *IAM { - return NewWithClient(auth, region, aws.RetryingClient) -} - -func NewWithClient(auth aws.Auth, region aws.Region, httpClient *http.Client) *IAM { - return &IAM{auth, region, httpClient} -} - -func (iam *IAM) query(params map[string]string, resp interface{}) error { - params["Version"] = "2010-05-08" - params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339) - endpoint, err := url.Parse(iam.IAMEndpoint) - if err != nil { - return err - } - sign(iam.Auth, "GET", "/", params, endpoint.Host) - endpoint.RawQuery = multimap(params).Encode() - r, err := iam.httpClient.Get(endpoint.String()) - if err != nil { - return err - } - defer r.Body.Close() - if r.StatusCode > 200 { - return buildError(r) - } - - return xml.NewDecoder(r.Body).Decode(resp) -} - -func (iam *IAM) postQuery(params map[string]string, resp interface{}) error { - endpoint, err := url.Parse(iam.IAMEndpoint) - if err != nil { - return err - } - params["Version"] = "2010-05-08" - params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339) - sign(iam.Auth, "POST", "/", params, endpoint.Host) - encoded := multimap(params).Encode() - body := strings.NewReader(encoded) - req, err := http.NewRequest("POST", endpoint.String(), body) - if err != nil { - return err - } - req.Header.Set("Host", endpoint.Host) - req.Header.Set("Content-Type", "application/x-www-form-urlencoded") - req.Header.Set("Content-Length", strconv.Itoa(len(encoded))) - r, err := http.DefaultClient.Do(req) - if err != nil { - return err - } - defer r.Body.Close() - if r.StatusCode > 200 { - return buildError(r) - } - return xml.NewDecoder(r.Body).Decode(resp) -} - -func buildError(r *http.Response) error { - var ( - err Error - errors xmlErrors - ) - xml.NewDecoder(r.Body).Decode(&errors) - if len(errors.Errors) > 0 { - err = errors.Errors[0] - } - err.StatusCode = r.StatusCode - if err.Message == "" { - err.Message = r.Status - } - return &err -} - -func multimap(p map[string]string) url.Values { - q := make(url.Values, len(p)) - for k, v := range p { - q[k] = []string{v} - } - return q -} - -// Response to a CreateUser request. -// -// See http://goo.gl/JS9Gz for more details. -type CreateUserResp struct { - RequestId string `xml:"ResponseMetadata>RequestId"` - User User `xml:"CreateUserResult>User"` -} - -// User encapsulates a user managed by IAM. -// -// See http://goo.gl/BwIQ3 for more details. -type User struct { - Arn string - Path string - Id string `xml:"UserId"` - Name string `xml:"UserName"` -} - -// CreateUser creates a new user in IAM. -// -// See http://goo.gl/JS9Gz for more details. -func (iam *IAM) CreateUser(name, path string) (*CreateUserResp, error) { - params := map[string]string{ - "Action": "CreateUser", - "Path": path, - "UserName": name, - } - resp := new(CreateUserResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Response for GetUser requests. -// -// See http://goo.gl/ZnzRN for more details. -type GetUserResp struct { - RequestId string `xml:"ResponseMetadata>RequestId"` - User User `xml:"GetUserResult>User"` -} - -// GetUser gets a user from IAM. -// -// See http://goo.gl/ZnzRN for more details. -func (iam *IAM) GetUser(name string) (*GetUserResp, error) { - params := map[string]string{ - "Action": "GetUser", - "UserName": name, - } - resp := new(GetUserResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// DeleteUser deletes a user from IAM. -// -// See http://goo.gl/jBuCG for more details. -func (iam *IAM) DeleteUser(name string) (*SimpleResp, error) { - params := map[string]string{ - "Action": "DeleteUser", - "UserName": name, - } - resp := new(SimpleResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Response to a CreateGroup request. -// -// See http://goo.gl/n7NNQ for more details. -type CreateGroupResp struct { - Group Group `xml:"CreateGroupResult>Group"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// Group encapsulates a group managed by IAM. -// -// See http://goo.gl/ae7Vs for more details. -type Group struct { - Arn string - Id string `xml:"GroupId"` - Name string `xml:"GroupName"` - Path string -} - -// CreateGroup creates a new group in IAM. -// -// The path parameter can be used to identify which division or part of the -// organization the user belongs to. -// -// If path is unset ("") it defaults to "/". -// -// See http://goo.gl/n7NNQ for more details. -func (iam *IAM) CreateGroup(name string, path string) (*CreateGroupResp, error) { - params := map[string]string{ - "Action": "CreateGroup", - "GroupName": name, - } - if path != "" { - params["Path"] = path - } - resp := new(CreateGroupResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Response to a ListGroups request. -// -// See http://goo.gl/W2TRj for more details. -type GroupsResp struct { - Groups []Group `xml:"ListGroupsResult>Groups>member"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// Groups list the groups that have the specified path prefix. -// -// The parameter pathPrefix is optional. If pathPrefix is "", all groups are -// returned. -// -// See http://goo.gl/W2TRj for more details. -func (iam *IAM) Groups(pathPrefix string) (*GroupsResp, error) { - params := map[string]string{ - "Action": "ListGroups", - } - if pathPrefix != "" { - params["PathPrefix"] = pathPrefix - } - resp := new(GroupsResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// DeleteGroup deletes a group from IAM. -// -// See http://goo.gl/d5i2i for more details. -func (iam *IAM) DeleteGroup(name string) (*SimpleResp, error) { - params := map[string]string{ - "Action": "DeleteGroup", - "GroupName": name, - } - resp := new(SimpleResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Response to a CreateAccessKey request. -// -// See http://goo.gl/L46Py for more details. -type CreateAccessKeyResp struct { - RequestId string `xml:"ResponseMetadata>RequestId"` - AccessKey AccessKey `xml:"CreateAccessKeyResult>AccessKey"` -} - -// AccessKey encapsulates an access key generated for a user. -// -// See http://goo.gl/LHgZR for more details. -type AccessKey struct { - UserName string - Id string `xml:"AccessKeyId"` - Secret string `xml:"SecretAccessKey,omitempty"` - Status string -} - -// CreateAccessKey creates a new access key in IAM. -// -// See http://goo.gl/L46Py for more details. -func (iam *IAM) CreateAccessKey(userName string) (*CreateAccessKeyResp, error) { - params := map[string]string{ - "Action": "CreateAccessKey", - "UserName": userName, - } - resp := new(CreateAccessKeyResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Response to AccessKeys request. -// -// See http://goo.gl/Vjozx for more details. -type AccessKeysResp struct { - RequestId string `xml:"ResponseMetadata>RequestId"` - AccessKeys []AccessKey `xml:"ListAccessKeysResult>AccessKeyMetadata>member"` -} - -// AccessKeys lists all acccess keys associated with a user. -// -// The userName parameter is optional. If set to "", the userName is determined -// implicitly based on the AWS Access Key ID used to sign the request. -// -// See http://goo.gl/Vjozx for more details. -func (iam *IAM) AccessKeys(userName string) (*AccessKeysResp, error) { - params := map[string]string{ - "Action": "ListAccessKeys", - } - if userName != "" { - params["UserName"] = userName - } - resp := new(AccessKeysResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// DeleteAccessKey deletes an access key from IAM. -// -// The userName parameter is optional. If set to "", the userName is determined -// implicitly based on the AWS Access Key ID used to sign the request. -// -// See http://goo.gl/hPGhw for more details. -func (iam *IAM) DeleteAccessKey(id, userName string) (*SimpleResp, error) { - params := map[string]string{ - "Action": "DeleteAccessKey", - "AccessKeyId": id, - } - if userName != "" { - params["UserName"] = userName - } - resp := new(SimpleResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Response to a GetUserPolicy request. -// -// See http://goo.gl/BH04O for more details. -type GetUserPolicyResp struct { - Policy UserPolicy `xml:"GetUserPolicyResult"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// UserPolicy encapsulates an IAM group policy. -// -// See http://goo.gl/C7hgS for more details. -type UserPolicy struct { - Name string `xml:"PolicyName"` - UserName string `xml:"UserName"` - Document string `xml:"PolicyDocument"` -} - -// GetUserPolicy gets a user policy in IAM. -// -// See http://goo.gl/BH04O for more details. -func (iam *IAM) GetUserPolicy(userName, policyName string) (*GetUserPolicyResp, error) { - params := map[string]string{ - "Action": "GetUserPolicy", - "UserName": userName, - "PolicyName": policyName, - } - resp := new(GetUserPolicyResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil - return nil, nil -} - -// PutUserPolicy creates a user policy in IAM. -// -// See http://goo.gl/ldCO8 for more details. -func (iam *IAM) PutUserPolicy(userName, policyName, policyDocument string) (*SimpleResp, error) { - params := map[string]string{ - "Action": "PutUserPolicy", - "UserName": userName, - "PolicyName": policyName, - "PolicyDocument": policyDocument, - } - resp := new(SimpleResp) - if err := iam.postQuery(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// DeleteUserPolicy deletes a user policy from IAM. -// -// See http://goo.gl/7Jncn for more details. -func (iam *IAM) DeleteUserPolicy(userName, policyName string) (*SimpleResp, error) { - params := map[string]string{ - "Action": "DeleteUserPolicy", - "PolicyName": policyName, - "UserName": userName, - } - resp := new(SimpleResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Response for AddUserToGroup requests. -// -// See http://goo.gl/ZnzRN for more details. -type AddUserToGroupResp struct { - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// AddUserToGroup adds a user to a specific group -// -// See http://goo.gl/ZnzRN for more details. -func (iam *IAM) AddUserToGroup(name, group string) (*AddUserToGroupResp, error) { - - params := map[string]string{ - "Action": "AddUserToGroup", - "GroupName": group, - "UserName": name} - resp := new(AddUserToGroupResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Response for a ListAccountAliases request. -// -// See http://goo.gl/MMN79v for more details. -type ListAccountAliasesResp struct { - AccountAliases []string `xml:"ListAccountAliasesResult>AccountAliases>member"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// ListAccountAliases lists the account aliases associated with the account -// -// See http://goo.gl/MMN79v for more details. -func (iam *IAM) ListAccountAliases() (*ListAccountAliasesResp, error) { - params := map[string]string{ - "Action": "ListAccountAliases", - } - resp := new(ListAccountAliasesResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Response for a CreateAccountAlias request. -// -// See http://goo.gl/oU5C4H for more details. -type CreateAccountAliasResp struct { - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// CreateAccountAlias creates an alias for your AWS account. -// -// See http://goo.gl/oU5C4H for more details. -func (iam *IAM) CreateAccountAlias(alias string) (*CreateAccountAliasResp, error) { - params := map[string]string{ - "Action": "CreateAccountAlias", - "AccountAlias": alias, - } - resp := new(CreateAccountAliasResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Response for a DeleteAccountAlias request. -// -// See http://goo.gl/hKalgg for more details. -type DeleteAccountAliasResp struct { - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// DeleteAccountAlias deletes the specified AWS account alias. -// -// See http://goo.gl/hKalgg for more details. -func (iam *IAM) DeleteAccountAlias(alias string) (*DeleteAccountAliasResp, error) { - params := map[string]string{ - "Action": "DeleteAccountAlias", - "AccountAlias": alias, - } - resp := new(DeleteAccountAliasResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -type SimpleResp struct { - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -type xmlErrors struct { - Errors []Error `xml:"Error"` -} - -// ServerCertificateMetadata represents a ServerCertificateMetadata object -// -// See http://goo.gl/Rfu7LD for more details. -type ServerCertificateMetadata struct { - Arn string `xml:"Arn"` - Expiration time.Time `xml:"Expiration"` - Path string `xml:"Path"` - ServerCertificateId string `xml:"ServerCertificateId"` - ServerCertificateName string `xml:"ServerCertificateName"` - UploadDate time.Time `xml:"UploadDate"` -} - -// UploadServerCertificateResponse wraps up for UploadServerCertificate request. -// -// See http://goo.gl/bomzce for more details. -type UploadServerCertificateResponse struct { - ServerCertificateMetadata ServerCertificateMetadata `xml:"UploadServerCertificateResult>ServerCertificateMetadata"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// UploadServerCertificateParams wraps up the params to be passed for the UploadServerCertificate request -// -// See http://goo.gl/bomzce for more details. -type UploadServerCertificateParams struct { - ServerCertificateName string - PrivateKey string - CertificateBody string - CertificateChain string - Path string -} - -// UploadServerCertificate uploads a server certificate entity for the AWS account. -// -// Required Params: ServerCertificateName, PrivateKey, CertificateBody -// -// See http://goo.gl/bomzce for more details. -func (iam *IAM) UploadServerCertificate(options *UploadServerCertificateParams) ( - *UploadServerCertificateResponse, error) { - params := map[string]string{ - "Action": "UploadServerCertificate", - "ServerCertificateName": options.ServerCertificateName, - "PrivateKey": options.PrivateKey, - "CertificateBody": options.CertificateBody, - } - if options.CertificateChain != "" { - params["CertificateChain"] = options.CertificateChain - } - if options.Path != "" { - params["Path"] = options.Path - } - - resp := new(UploadServerCertificateResponse) - if err := iam.postQuery(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// ListServerCertificates lists all available certificates for the AWS account specified -// -// Required Params: None -// -// Optional Params: Marker, and, PathPrefix -// -// See http://goo.gl/bwn0Nb for specifics - -type ListServerCertificatesParams struct { - Marker string - PathPrefix string -} - -type ListServerCertificatesResp struct { - ServerCertificates []ServerCertificateMetadata `xml:"ListServerCertificatesResult>ServerCertificateMetadataList>member>ServerCertificateMetadata"` - RequestId string `xml:"ResponseMetadata>RequestId"` - IsTruncated bool `xml:"ListServerCertificatesResult>IsTruncated"` -} - -func (iam *IAM) ListServerCertificates(options *ListServerCertificatesParams) ( - *ListServerCertificatesResp, error) { - params := map[string]string{ - "Action": "ListServerCertificates", - } - - if options.Marker != "" { - params["Marker"] = options.Marker - } - - if options.PathPrefix != "" { - params["PathPrefix"] = options.PathPrefix - } - - resp := new(ListServerCertificatesResp) - if err := iam.query(params, resp); err != nil { - return nil, err - } - - return resp, nil -} - -// DeleteServerCertificate deletes the specified server certificate. -// -// See http://goo.gl/W4nmxQ for more details. -func (iam *IAM) DeleteServerCertificate(serverCertificateName string) (*SimpleResp, error) { - params := map[string]string{ - "Action": "DeleteServerCertificate", - "ServerCertificateName": serverCertificateName, - } - - resp := new(SimpleResp) - if err := iam.postQuery(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Error encapsulates an IAM error. -type Error struct { - // HTTP status code of the error. - StatusCode int - - // AWS code of the error. - Code string - - // Message explaining the error. - Message string -} - -func (e *Error) Error() string { - var prefix string - if e.Code != "" { - prefix = e.Code + ": " - } - if prefix == "" && e.StatusCode > 0 { - prefix = strconv.Itoa(e.StatusCode) + ": " - } - return prefix + e.Message -} diff --git a/vendor/github.com/goamz/goamz/iam/iam_test.go b/vendor/github.com/goamz/goamz/iam/iam_test.go deleted file mode 100644 index e73935670..000000000 --- a/vendor/github.com/goamz/goamz/iam/iam_test.go +++ /dev/null @@ -1,450 +0,0 @@ -package iam_test - -import ( - "strings" - "testing" - "time" - - "github.com/goamz/goamz/aws" - "github.com/goamz/goamz/iam" - "github.com/goamz/goamz/testutil" - . "gopkg.in/check.v1" -) - -func Test(t *testing.T) { - TestingT(t) -} - -type S struct { - iam *iam.IAM -} - -var _ = Suite(&S{}) - -var testServer = testutil.NewHTTPServer() - -func (s *S) SetUpSuite(c *C) { - testServer.Start() - auth := aws.Auth{AccessKey: "abc", SecretKey: "123"} - s.iam = iam.NewWithClient(auth, aws.Region{IAMEndpoint: testServer.URL}, testutil.DefaultClient) -} - -func (s *S) TearDownTest(c *C) { - testServer.Flush() -} - -func (s *S) TestCreateUser(c *C) { - testServer.Response(200, nil, CreateUserExample) - resp, err := s.iam.CreateUser("Bob", "/division_abc/subdivision_xyz/") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "CreateUser") - c.Assert(values.Get("UserName"), Equals, "Bob") - c.Assert(values.Get("Path"), Equals, "/division_abc/subdivision_xyz/") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") - expected := iam.User{ - Path: "/division_abc/subdivision_xyz/", - Name: "Bob", - Id: "AIDACKCEVSQ6C2EXAMPLE", - Arn: "arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob", - } - c.Assert(resp.User, DeepEquals, expected) -} - -func (s *S) TestCreateUserConflict(c *C) { - testServer.Response(409, nil, DuplicateUserExample) - resp, err := s.iam.CreateUser("Bob", "/division_abc/subdivision_xyz/") - testServer.WaitRequest() - c.Assert(resp, IsNil) - c.Assert(err, NotNil) - e, ok := err.(*iam.Error) - c.Assert(ok, Equals, true) - c.Assert(e.Message, Equals, "User with name Bob already exists.") - c.Assert(e.Code, Equals, "EntityAlreadyExists") -} - -func (s *S) TestGetUser(c *C) { - testServer.Response(200, nil, GetUserExample) - resp, err := s.iam.GetUser("Bob") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "GetUser") - c.Assert(values.Get("UserName"), Equals, "Bob") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") - expected := iam.User{ - Path: "/division_abc/subdivision_xyz/", - Name: "Bob", - Id: "AIDACKCEVSQ6C2EXAMPLE", - Arn: "arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob", - } - c.Assert(resp.User, DeepEquals, expected) -} - -func (s *S) TestDeleteUser(c *C) { - testServer.Response(200, nil, RequestIdExample) - resp, err := s.iam.DeleteUser("Bob") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "DeleteUser") - c.Assert(values.Get("UserName"), Equals, "Bob") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") -} - -func (s *S) TestCreateGroup(c *C) { - testServer.Response(200, nil, CreateGroupExample) - resp, err := s.iam.CreateGroup("Admins", "/admins/") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "CreateGroup") - c.Assert(values.Get("GroupName"), Equals, "Admins") - c.Assert(values.Get("Path"), Equals, "/admins/") - c.Assert(err, IsNil) - c.Assert(resp.Group.Path, Equals, "/admins/") - c.Assert(resp.Group.Name, Equals, "Admins") - c.Assert(resp.Group.Id, Equals, "AGPACKCEVSQ6C2EXAMPLE") - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") -} - -func (s *S) TestCreateGroupWithoutPath(c *C) { - testServer.Response(200, nil, CreateGroupExample) - _, err := s.iam.CreateGroup("Managers", "") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "CreateGroup") - c.Assert(err, IsNil) - _, ok := map[string][]string(values)["Path"] - c.Assert(ok, Equals, false) -} - -func (s *S) TestDeleteGroup(c *C) { - testServer.Response(200, nil, RequestIdExample) - resp, err := s.iam.DeleteGroup("Admins") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "DeleteGroup") - c.Assert(values.Get("GroupName"), Equals, "Admins") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") -} - -func (s *S) TestListGroups(c *C) { - testServer.Response(200, nil, ListGroupsExample) - resp, err := s.iam.Groups("/division_abc/") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "ListGroups") - c.Assert(values.Get("PathPrefix"), Equals, "/division_abc/") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") - expected := []iam.Group{ - { - Path: "/division_abc/subdivision_xyz/", - Name: "Admins", - Id: "AGPACKCEVSQ6C2EXAMPLE", - Arn: "arn:aws:iam::123456789012:group/Admins", - }, - { - Path: "/division_abc/subdivision_xyz/product_1234/engineering/", - Name: "Test", - Id: "AGP2MAB8DPLSRHEXAMPLE", - Arn: "arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/engineering/Test", - }, - { - Path: "/division_abc/subdivision_xyz/product_1234/", - Name: "Managers", - Id: "AGPIODR4TAW7CSEXAMPLE", - Arn: "arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/Managers", - }, - } - c.Assert(resp.Groups, DeepEquals, expected) -} - -func (s *S) TestListGroupsWithoutPathPrefix(c *C) { - testServer.Response(200, nil, ListGroupsExample) - _, err := s.iam.Groups("") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "ListGroups") - c.Assert(err, IsNil) - _, ok := map[string][]string(values)["PathPrefix"] - c.Assert(ok, Equals, false) -} - -func (s *S) TestCreateAccessKey(c *C) { - testServer.Response(200, nil, CreateAccessKeyExample) - resp, err := s.iam.CreateAccessKey("Bob") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "CreateAccessKey") - c.Assert(values.Get("UserName"), Equals, "Bob") - c.Assert(err, IsNil) - c.Assert(resp.AccessKey.UserName, Equals, "Bob") - c.Assert(resp.AccessKey.Id, Equals, "AKIAIOSFODNN7EXAMPLE") - c.Assert(resp.AccessKey.Secret, Equals, "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY") - c.Assert(resp.AccessKey.Status, Equals, "Active") -} - -func (s *S) TestDeleteAccessKey(c *C) { - testServer.Response(200, nil, RequestIdExample) - resp, err := s.iam.DeleteAccessKey("ysa8hasdhasdsi", "Bob") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "DeleteAccessKey") - c.Assert(values.Get("AccessKeyId"), Equals, "ysa8hasdhasdsi") - c.Assert(values.Get("UserName"), Equals, "Bob") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") -} - -func (s *S) TestDeleteAccessKeyBlankUserName(c *C) { - testServer.Response(200, nil, RequestIdExample) - _, err := s.iam.DeleteAccessKey("ysa8hasdhasdsi", "") - c.Assert(err, IsNil) - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "DeleteAccessKey") - c.Assert(values.Get("AccessKeyId"), Equals, "ysa8hasdhasdsi") - _, ok := map[string][]string(values)["UserName"] - c.Assert(ok, Equals, false) -} - -func (s *S) TestAccessKeys(c *C) { - testServer.Response(200, nil, ListAccessKeyExample) - resp, err := s.iam.AccessKeys("Bob") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "ListAccessKeys") - c.Assert(values.Get("UserName"), Equals, "Bob") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") - c.Assert(resp.AccessKeys, HasLen, 2) - c.Assert(resp.AccessKeys[0].Id, Equals, "AKIAIOSFODNN7EXAMPLE") - c.Assert(resp.AccessKeys[0].UserName, Equals, "Bob") - c.Assert(resp.AccessKeys[0].Status, Equals, "Active") - c.Assert(resp.AccessKeys[1].Id, Equals, "AKIAI44QH8DHBEXAMPLE") - c.Assert(resp.AccessKeys[1].UserName, Equals, "Bob") - c.Assert(resp.AccessKeys[1].Status, Equals, "Inactive") -} - -func (s *S) TestAccessKeysBlankUserName(c *C) { - testServer.Response(200, nil, ListAccessKeyExample) - _, err := s.iam.AccessKeys("") - c.Assert(err, IsNil) - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "ListAccessKeys") - _, ok := map[string][]string(values)["UserName"] - c.Assert(ok, Equals, false) -} - -func (s *S) TestGetUserPolicy(c *C) { - testServer.Response(200, nil, GetUserPolicyExample) - resp, err := s.iam.GetUserPolicy("Bob", "AllAccessPolicy") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "GetUserPolicy") - c.Assert(values.Get("UserName"), Equals, "Bob") - c.Assert(values.Get("PolicyName"), Equals, "AllAccessPolicy") - c.Assert(err, IsNil) - c.Assert(resp.Policy.UserName, Equals, "Bob") - c.Assert(resp.Policy.Name, Equals, "AllAccessPolicy") - c.Assert(strings.TrimSpace(resp.Policy.Document), Equals, `{"Statement":[{"Effect":"Allow","Action":"*","Resource":"*"}]}`) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") -} - -func (s *S) TestPutUserPolicy(c *C) { - document := `{ - "Statement": [ - { - "Action": [ - "s3:*" - ], - "Effect": "Allow", - "Resource": [ - "arn:aws:s3:::8shsns19s90ajahadsj/*", - "arn:aws:s3:::8shsns19s90ajahadsj" - ] - }] - }` - testServer.Response(200, nil, RequestIdExample) - resp, err := s.iam.PutUserPolicy("Bob", "AllAccessPolicy", document) - req := testServer.WaitRequest() - c.Assert(req.Method, Equals, "POST") - c.Assert(req.FormValue("Action"), Equals, "PutUserPolicy") - c.Assert(req.FormValue("PolicyName"), Equals, "AllAccessPolicy") - c.Assert(req.FormValue("UserName"), Equals, "Bob") - c.Assert(req.FormValue("PolicyDocument"), Equals, document) - c.Assert(req.FormValue("Version"), Equals, "2010-05-08") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") -} - -func (s *S) TestDeleteUserPolicy(c *C) { - testServer.Response(200, nil, RequestIdExample) - resp, err := s.iam.DeleteUserPolicy("Bob", "AllAccessPolicy") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "DeleteUserPolicy") - c.Assert(values.Get("PolicyName"), Equals, "AllAccessPolicy") - c.Assert(values.Get("UserName"), Equals, "Bob") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") -} - -func (s *S) TestAddUserToGroup(c *C) { - testServer.Response(200, nil, AddUserToGroupExample) - resp, err := s.iam.AddUserToGroup("admin1", "Admins") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "AddUserToGroup") - c.Assert(values.Get("GroupName"), Equals, "Admins") - c.Assert(values.Get("UserName"), Equals, "admin1") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") -} - -func (s *S) TestListAccountAliases(c *C) { - testServer.Response(200, nil, ListAccountAliasesExample) - resp, err := s.iam.ListAccountAliases() - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "ListAccountAliases") - c.Assert(err, IsNil) - c.Assert(resp.AccountAliases[0], Equals, "foocorporation") - c.Assert(resp.RequestId, Equals, "c5a076e9-f1b0-11df-8fbe-45274EXAMPLE") -} - -func (s *S) TestCreateAccountAlias(c *C) { - testServer.Response(200, nil, CreateAccountAliasExample) - resp, err := s.iam.CreateAccountAlias("foobaz") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "CreateAccountAlias") - c.Assert(values.Get("AccountAlias"), Equals, "foobaz") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "36b5db08-f1b0-11df-8fbe-45274EXAMPLE") -} - -func (s *S) TestDeleteAccountAlias(c *C) { - testServer.Response(200, nil, DeleteAccountAliasExample) - resp, err := s.iam.DeleteAccountAlias("foobaz") - values := testServer.WaitRequest().URL.Query() - c.Assert(values.Get("Action"), Equals, "DeleteAccountAlias") - c.Assert(values.Get("AccountAlias"), Equals, "foobaz") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") -} - -func (s *S) TestUploadServerCertificate(c *C) { - testServer.Response(200, nil, UploadServerCertificateExample) - - certificateBody := ` ------BEGIN CERTIFICATE----- -MIICdzCCAeCgAwIBAgIGANc+Ha2wMA0GCSqGSIb3DQEBBQUAMFMxCzAJBgNVBAYT -AlVTMRMwEQYDVQQKEwpBbWF6b24uY29tMQwwCgYDVQQLEwNBV1MxITAfBgNVBAMT -GEFXUyBMaW1pdGVkLUFzc3VyYW5jZSBDQTAeFw0wOTAyMDQxNzE5MjdaFw0xMDAy -MDQxNzE5MjdaMFIxCzAJBgNVBAYTAlVTMRMwEQYDVQQKEwpBbWF6b24uY29tMRcw -FQYDVQQLEw5BV1MtRGV2ZWxvcGVyczEVMBMGA1UEAxMMNTdxNDl0c3ZwYjRtMIGf -MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCpB/vsOwmT/O0td1RqzKjttSBaPjbr -dqwNe9BrOyB08fw2+Ch5oonZYXfGUrT6mkYXH5fQot9HvASrzAKHO596FdJA6DmL -ywdWe1Oggk7zFSXO1Xv+3vPrJtaYxYo3eRIp7w80PMkiOv6M0XK8ubcTouODeJbf -suDqcLnLDxwsvwIDAQABo1cwVTAOBgNVHQ8BAf8EBAMCBaAwFgYDVR0lAQH/BAww -CgYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQULGNaBphBumaKbDRK -CAi0mH8B3mowDQYJKoZIhvcNAQEFBQADgYEAuKxhkXaCLGcqDuweKtO/AEw9ZePH -wr0XqsaIK2HZboqruebXEGsojK4Ks0WzwgrEynuHJwTn760xe39rSqXWIOGrOBaX -wFpWHVjTFMKk+tSDG1lssLHyYWWdFFU4AnejRGORJYNaRHgVTKjHphc5jEhHm0BX -AEaHzTpmEXAMPLE= ------END CERTIFICATE----- -` - privateKey := ` ------BEGIN DSA PRIVATE KEY----- -MIIBugIBTTKBgQD33xToSXPJ6hr37L3+KNi3/7DgywlBcvlFPPSHIw3ORuO/22mT -8Cy5fT89WwNvZ3BPKWU6OZ38TQv3eWjNc/3U3+oqVNG2poX5nCPOtO1b96HYX2mR -3FTdH6FRKbQEhpDzZ6tRrjTHjMX6sT3JRWkBd2c4bGu+HUHO1H7QvrCTeQIVTKMs -TCKCyrLiGhUWuUGNJUMU6y6zToGTHl84Tz7TPwDGDXuy/Dk5s4jTVr+xibROC/gS -Qrs4Dzz3T1ze6lvU8S1KT9UsOB5FUJNTTPCPey+Lo4mmK6b23XdTyCIT8e2fsm2j -jHHC1pIPiTkdLS3j6ZYjF8LY6TENFng+LDY/xwPOl7TJVoD3J/WXC2J9CEYq9o34 -kq6WWn3CgYTuo54nXUgnoCb3xdG8COFrg+oTbIkHTSzs3w5o/GGgKK7TDF3UlJjq -vHNyJQ6kWBrQRR1Xp5KYQ4c/Dm5kef+62mH53HpcCELguWVcffuVQpmq3EWL9Zp9 -jobTJQ2VHjb5IVxiO6HRSd27di3njyrzUuJCyHSDTqwLJmTThpd6OTIUTL3Tc4m2 -62TITdw53KWJEXAMPLE= ------END DSA PRIVATE KEY----- -` - params := &iam.UploadServerCertificateParams{ - ServerCertificateName: "ProdServerCert", - Path: "/company/servercerts/", - PrivateKey: privateKey, - CertificateBody: certificateBody, - } - - resp, err := s.iam.UploadServerCertificate(params) - req := testServer.WaitRequest() - c.Assert(req.Method, Equals, "POST") - c.Assert(req.FormValue("Action"), Equals, "UploadServerCertificate") - c.Assert(req.FormValue("CertificateBody"), Equals, certificateBody) - c.Assert(req.FormValue("PrivateKey"), Equals, privateKey) - c.Assert(req.FormValue("ServerCertificateName"), Equals, "ProdServerCert") - c.Assert(req.FormValue("CertificateChain"), Equals, "") - c.Assert(req.FormValue("Path"), Equals, "/company/servercerts/") - c.Assert(req.FormValue("Version"), Equals, "2010-05-08") - c.Assert(err, IsNil) - - ud, _ := time.Parse(time.RFC3339, "2010-05-08T01:02:03.004Z") - exp, _ := time.Parse(time.RFC3339, "2012-05-08T01:02:03.004Z") - expected := iam.ServerCertificateMetadata{ - Arn: "arn:aws:iam::123456789012:server-certificate/company/servercerts/ProdServerCert", - ServerCertificateName: "ProdServerCert", - ServerCertificateId: "ASCACKCEVSQ6C2EXAMPLE", - Path: "/company/servercerts/", - UploadDate: ud, - Expiration: exp, - } - c.Assert(resp.ServerCertificateMetadata, DeepEquals, expected) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") -} - -func (s *S) TestListServerCertificates(c *C) { - testServer.Response(200, nil, ListServerCertificatesExample) - params := &iam.ListServerCertificatesParams{ - Marker: "my-fake-marker", - PathPrefix: "/some/fake/path", - } - - resp, err := s.iam.ListServerCertificates(params) - req := testServer.WaitRequest() - - c.Assert(err, IsNil) - c.Assert(req.Method, Equals, "GET") - c.Assert(req.FormValue("Action"), Equals, "ListServerCertificates") - c.Assert(req.FormValue("Marker"), Equals, "my-fake-marker") - c.Assert(req.FormValue("PathPrefix"), Equals, "/some/fake/path") - c.Assert(req.FormValue("Version"), Equals, "2010-05-08") - - uploadDate, _ := time.Parse(time.RFC3339, "2010-05-08T01:02:03.004Z") - expirationDate, _ := time.Parse(time.RFC3339, "2012-05-08T01:02:03.004Z") - expected := []iam.ServerCertificateMetadata{ - { - Arn: "arn:aws:iam::123456789012:server-certificate/company/servercerts/ProdServerCert", - ServerCertificateName: "ProdServerCert", - ServerCertificateId: "ASCACKCEVSQ6C2EXAMPLE1", - Path: "/some/fake/path", - UploadDate: uploadDate, - Expiration: expirationDate, - }, - { - Arn: "arn:aws:iam::123456789012:server-certificate/company/servercerts/BetaServerCert", - ServerCertificateName: "BetaServerCert", - ServerCertificateId: "ASCACKCEVSQ6C2EXAMPLE2", - Path: "/some/fake/path", - UploadDate: uploadDate, - Expiration: expirationDate, - }, - { - Arn: "arn:aws:iam::123456789012:server-certificate/company/servercerts/TestServerCert", - ServerCertificateName: "TestServerCert", - ServerCertificateId: "ASCACKCEVSQ6C2EXAMPLE3", - Path: "/some/fake/path", - UploadDate: uploadDate, - Expiration: expirationDate, - }, - } - - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eTHISDIFFERENTTEST") - c.Assert(resp.IsTruncated, Equals, false) - c.Assert(resp.ServerCertificates, DeepEquals, expected) -} - -func (s *S) TestDeleteServerCertificate(c *C) { - testServer.Response(200, nil, DeleteServerCertificateExample) - resp, err := s.iam.DeleteServerCertificate("ProdServerCert") - req := testServer.WaitRequest() - c.Assert(req.FormValue("Action"), Equals, "DeleteServerCertificate") - c.Assert(req.FormValue("ServerCertificateName"), Equals, "ProdServerCert") - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") -} diff --git a/vendor/github.com/goamz/goamz/iam/iami_test.go b/vendor/github.com/goamz/goamz/iam/iami_test.go deleted file mode 100644 index 26f32386f..000000000 --- a/vendor/github.com/goamz/goamz/iam/iami_test.go +++ /dev/null @@ -1,209 +0,0 @@ -package iam_test - -import ( - "net/url" - - "github.com/goamz/goamz/aws" - "github.com/goamz/goamz/iam" - "github.com/goamz/goamz/testutil" - . "gopkg.in/check.v1" -) - -// AmazonServer represents an Amazon AWS server. -type AmazonServer struct { - auth aws.Auth -} - -func (s *AmazonServer) SetUp(c *C) { - auth, err := aws.EnvAuth() - if err != nil { - c.Fatal(err) - } - s.auth = auth -} - -var _ = Suite(&AmazonClientSuite{}) - -// AmazonClientSuite tests the client against a live AWS server. -type AmazonClientSuite struct { - srv AmazonServer - ClientTests -} - -func (s *AmazonClientSuite) SetUpSuite(c *C) { - if !testutil.Amazon { - c.Skip("AmazonClientSuite tests not enabled") - } - s.srv.SetUp(c) - s.iam = iam.New(s.srv.auth, aws.USEast) -} - -// ClientTests defines integration tests designed to test the client. -// It is not used as a test suite in itself, but embedded within -// another type. -type ClientTests struct { - iam *iam.IAM -} - -func (s *ClientTests) TestCreateAndDeleteUser(c *C) { - createResp, err := s.iam.CreateUser("gopher", "/gopher/") - c.Assert(err, IsNil) - getResp, err := s.iam.GetUser("gopher") - c.Assert(err, IsNil) - c.Assert(createResp.User, DeepEquals, getResp.User) - _, err = s.iam.DeleteUser("gopher") - c.Assert(err, IsNil) -} - -func (s *ClientTests) TestCreateUserError(c *C) { - _, err := s.iam.CreateUser("gopher", "/gopher/") - c.Assert(err, IsNil) - defer s.iam.DeleteUser("gopher") - _, err = s.iam.CreateUser("gopher", "/") - iamErr, ok := err.(*iam.Error) - c.Assert(ok, Equals, true) - c.Assert(iamErr.StatusCode, Equals, 409) - c.Assert(iamErr.Code, Equals, "EntityAlreadyExists") - c.Assert(iamErr.Message, Equals, "User with name gopher already exists.") -} - -func (s *ClientTests) TestDeleteUserError(c *C) { - _, err := s.iam.DeleteUser("gopher") - iamErr, ok := err.(*iam.Error) - c.Assert(ok, Equals, true) - c.Assert(iamErr.StatusCode, Equals, 404) - c.Assert(iamErr.Code, Equals, "NoSuchEntity") - c.Assert(iamErr.Message, Equals, "The user with name gopher cannot be found.") -} - -func (s *ClientTests) TestGetUserError(c *C) { - _, err := s.iam.GetUser("gopher") - iamErr, ok := err.(*iam.Error) - c.Assert(ok, Equals, true) - c.Assert(iamErr.StatusCode, Equals, 404) - c.Assert(iamErr.Code, Equals, "NoSuchEntity") - c.Assert(iamErr.Message, Equals, "The user with name gopher cannot be found.") -} - -func (s *ClientTests) TestCreateListAndDeleteAccessKey(c *C) { - createUserResp, err := s.iam.CreateUser("gopher", "/gopher/") - c.Assert(err, IsNil) - defer s.iam.DeleteUser(createUserResp.User.Name) - createKeyResp, err := s.iam.CreateAccessKey(createUserResp.User.Name) - c.Assert(err, IsNil) - listKeyResp, err := s.iam.AccessKeys(createUserResp.User.Name) - c.Assert(err, IsNil) - c.Assert(listKeyResp.AccessKeys, HasLen, 1) - createKeyResp.AccessKey.Secret = "" - c.Assert(listKeyResp.AccessKeys[0], DeepEquals, createKeyResp.AccessKey) - _, err = s.iam.DeleteAccessKey(createKeyResp.AccessKey.Id, createUserResp.User.Name) - c.Assert(err, IsNil) -} - -func (s *ClientTests) TestCreateAccessKeyError(c *C) { - _, err := s.iam.CreateAccessKey("unknowngopher") - c.Assert(err, NotNil) - iamErr, ok := err.(*iam.Error) - c.Assert(ok, Equals, true) - c.Assert(iamErr.StatusCode, Equals, 404) - c.Assert(iamErr.Code, Equals, "NoSuchEntity") - c.Assert(iamErr.Message, Equals, "The user with name unknowngopher cannot be found.") -} - -func (s *ClientTests) TestListAccessKeysUserNotFound(c *C) { - _, err := s.iam.AccessKeys("unknowngopher") - c.Assert(err, NotNil) - iamErr, ok := err.(*iam.Error) - c.Assert(ok, Equals, true) - c.Assert(iamErr.StatusCode, Equals, 404) - c.Assert(iamErr.Code, Equals, "NoSuchEntity") - c.Assert(iamErr.Message, Equals, "The user with name unknowngopher cannot be found.") -} - -func (s *ClientTests) TestListAccessKeysUserWithoutKeys(c *C) { - createUserResp, err := s.iam.CreateUser("gopher", "/") - c.Assert(err, IsNil) - defer s.iam.DeleteUser(createUserResp.User.Name) - resp, err := s.iam.AccessKeys(createUserResp.User.Name) - c.Assert(err, IsNil) - c.Assert(resp.AccessKeys, HasLen, 0) -} - -func (s *ClientTests) TestCreateListAndDeleteGroup(c *C) { - cResp1, err := s.iam.CreateGroup("Finances", "/finances/") - c.Assert(err, IsNil) - cResp2, err := s.iam.CreateGroup("DevelopmentManagers", "/development/managers/") - c.Assert(err, IsNil) - lResp, err := s.iam.Groups("/development/") - c.Assert(err, IsNil) - c.Assert(lResp.Groups, HasLen, 1) - c.Assert(cResp2.Group, DeepEquals, lResp.Groups[0]) - lResp, err = s.iam.Groups("") - c.Assert(err, IsNil) - c.Assert(lResp.Groups, HasLen, 2) - if lResp.Groups[0].Name == cResp1.Group.Name { - c.Assert([]iam.Group{cResp1.Group, cResp2.Group}, DeepEquals, lResp.Groups) - } else { - c.Assert([]iam.Group{cResp2.Group, cResp1.Group}, DeepEquals, lResp.Groups) - } - _, err = s.iam.DeleteGroup("DevelopmentManagers") - c.Assert(err, IsNil) - lResp, err = s.iam.Groups("/development/") - c.Assert(err, IsNil) - c.Assert(lResp.Groups, HasLen, 0) - _, err = s.iam.DeleteGroup("Finances") - c.Assert(err, IsNil) -} - -func (s *ClientTests) TestCreateGroupError(c *C) { - _, err := s.iam.CreateGroup("Finances", "/finances/") - c.Assert(err, IsNil) - defer s.iam.DeleteGroup("Finances") - _, err = s.iam.CreateGroup("Finances", "/something-else/") - iamErr, ok := err.(*iam.Error) - c.Assert(ok, Equals, true) - c.Assert(iamErr.StatusCode, Equals, 409) - c.Assert(iamErr.Code, Equals, "EntityAlreadyExists") - c.Assert(iamErr.Message, Equals, "Group with name Finances already exists.") -} - -func (s *ClientTests) TestDeleteGroupError(c *C) { - _, err := s.iam.DeleteGroup("Finances") - iamErr, ok := err.(*iam.Error) - c.Assert(ok, Equals, true) - c.Assert(iamErr.StatusCode, Equals, 404) - c.Assert(iamErr.Code, Equals, "NoSuchEntity") - c.Assert(iamErr.Message, Equals, "The group with name Finances cannot be found.") -} - -func (s *ClientTests) TestPutGetAndDeleteUserPolicy(c *C) { - userResp, err := s.iam.CreateUser("gopher", "/gopher/") - c.Assert(err, IsNil) - defer s.iam.DeleteUser(userResp.User.Name) - document := `{ - "Statement": [ - { - "Action": [ - "s3:*" - ], - "Effect": "Allow", - "Resource": [ - "arn:aws:s3:::8shsns19s90ajahadsj/*", - "arn:aws:s3:::8shsns19s90ajahadsj" - ] - }] - }` - _, err = s.iam.PutUserPolicy(userResp.User.Name, "EverythingS3", document) - c.Assert(err, IsNil) - resp, err := s.iam.GetUserPolicy(userResp.User.Name, "EverythingS3") - c.Assert(err, IsNil) - c.Assert(resp.Policy.Name, Equals, "EverythingS3") - c.Assert(resp.Policy.UserName, Equals, userResp.User.Name) - gotDocument, err := url.QueryUnescape(resp.Policy.Document) - c.Assert(err, IsNil) - c.Assert(gotDocument, Equals, document) - _, err = s.iam.DeleteUserPolicy(userResp.User.Name, "EverythingS3") - c.Assert(err, IsNil) - _, err = s.iam.GetUserPolicy(userResp.User.Name, "EverythingS3") - c.Assert(err, NotNil) -} diff --git a/vendor/github.com/goamz/goamz/iam/iamt_test.go b/vendor/github.com/goamz/goamz/iam/iamt_test.go deleted file mode 100644 index 9d89f43e3..000000000 --- a/vendor/github.com/goamz/goamz/iam/iamt_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package iam_test - -import ( - "github.com/goamz/goamz/aws" - "github.com/goamz/goamz/iam" - "github.com/goamz/goamz/iam/iamtest" - . "gopkg.in/check.v1" -) - -// LocalServer represents a local ec2test fake server. -type LocalServer struct { - auth aws.Auth - region aws.Region - srv *iamtest.Server -} - -func (s *LocalServer) SetUp(c *C) { - srv, err := iamtest.NewServer() - c.Assert(err, IsNil) - c.Assert(srv, NotNil) - - s.srv = srv - s.region = aws.Region{IAMEndpoint: srv.URL()} -} - -// LocalServerSuite defines tests that will run -// against the local iamtest server. It includes -// tests from ClientTests. -type LocalServerSuite struct { - srv LocalServer - ClientTests -} - -var _ = Suite(&LocalServerSuite{}) - -func (s *LocalServerSuite) SetUpSuite(c *C) { - s.srv.SetUp(c) - s.ClientTests.iam = iam.New(s.srv.auth, s.srv.region) -} diff --git a/vendor/github.com/goamz/goamz/iam/iamtest/server.go b/vendor/github.com/goamz/goamz/iam/iamtest/server.go deleted file mode 100644 index 08991d2f8..000000000 --- a/vendor/github.com/goamz/goamz/iam/iamtest/server.go +++ /dev/null @@ -1,432 +0,0 @@ -// Package iamtest implements a fake IAM provider with the capability of -// inducing errors on any given operation, and retrospectively determining what -// operations have been carried out. -package iamtest - -import ( - "encoding/json" - "encoding/xml" - "fmt" - "github.com/goamz/goamz/iam" - "net" - "net/http" - "strings" - "sync" -) - -type action struct { - srv *Server - w http.ResponseWriter - req *http.Request - reqId string -} - -// Server implements an IAM simulator for use in tests. -type Server struct { - reqId int - url string - listener net.Listener - users []iam.User - groups []iam.Group - accessKeys []iam.AccessKey - userPolicies []iam.UserPolicy - mutex sync.Mutex -} - -func NewServer() (*Server, error) { - l, err := net.Listen("tcp", "localhost:0") - if err != nil { - return nil, fmt.Errorf("cannot listen on localhost: %v", err) - } - srv := &Server{ - listener: l, - url: "http://" + l.Addr().String(), - } - go http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - srv.serveHTTP(w, req) - })) - return srv, nil -} - -// Quit closes down the server. -func (srv *Server) Quit() error { - return srv.listener.Close() -} - -// URL returns a URL for the server. -func (srv *Server) URL() string { - return srv.url -} - -type xmlErrors struct { - XMLName string `xml:"ErrorResponse"` - Error iam.Error -} - -func (srv *Server) error(w http.ResponseWriter, err *iam.Error) { - w.WriteHeader(err.StatusCode) - xmlErr := xmlErrors{Error: *err} - if e := xml.NewEncoder(w).Encode(xmlErr); e != nil { - panic(e) - } -} - -func (srv *Server) serveHTTP(w http.ResponseWriter, req *http.Request) { - req.ParseForm() - srv.mutex.Lock() - defer srv.mutex.Unlock() - action := req.FormValue("Action") - if action == "" { - srv.error(w, &iam.Error{ - StatusCode: 400, - Code: "MissingAction", - Message: "Missing action", - }) - } - if a, ok := actions[action]; ok { - reqId := fmt.Sprintf("req%0X", srv.reqId) - srv.reqId++ - if resp, err := a(srv, w, req, reqId); err == nil { - if err := xml.NewEncoder(w).Encode(resp); err != nil { - panic(err) - } - } else { - switch err.(type) { - case *iam.Error: - srv.error(w, err.(*iam.Error)) - default: - panic(err) - } - } - } else { - srv.error(w, &iam.Error{ - StatusCode: 400, - Code: "InvalidAction", - Message: "Invalid action: " + action, - }) - } -} - -func (srv *Server) createUser(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - if err := srv.validate(req, []string{"UserName"}); err != nil { - return nil, err - } - path := req.FormValue("Path") - if path == "" { - path = "/" - } - name := req.FormValue("UserName") - for _, user := range srv.users { - if user.Name == name { - return nil, &iam.Error{ - StatusCode: 409, - Code: "EntityAlreadyExists", - Message: fmt.Sprintf("User with name %s already exists.", name), - } - } - } - user := iam.User{ - Id: "USER" + reqId + "EXAMPLE", - Arn: fmt.Sprintf("arn:aws:iam:::123456789012:user%s%s", path, name), - Name: name, - Path: path, - } - srv.users = append(srv.users, user) - return iam.CreateUserResp{ - RequestId: reqId, - User: user, - }, nil -} - -func (srv *Server) getUser(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - if err := srv.validate(req, []string{"UserName"}); err != nil { - return nil, err - } - name := req.FormValue("UserName") - index, err := srv.findUser(name) - if err != nil { - return nil, err - } - return iam.GetUserResp{RequestId: reqId, User: srv.users[index]}, nil -} - -func (srv *Server) deleteUser(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - if err := srv.validate(req, []string{"UserName"}); err != nil { - return nil, err - } - name := req.FormValue("UserName") - index, err := srv.findUser(name) - if err != nil { - return nil, err - } - copy(srv.users[index:], srv.users[index+1:]) - srv.users = srv.users[:len(srv.users)-1] - return iam.SimpleResp{RequestId: reqId}, nil -} - -func (srv *Server) createAccessKey(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - if err := srv.validate(req, []string{"UserName"}); err != nil { - return nil, err - } - userName := req.FormValue("UserName") - if _, err := srv.findUser(userName); err != nil { - return nil, err - } - key := iam.AccessKey{ - Id: fmt.Sprintf("%s%d", userName, len(srv.accessKeys)), - Secret: "", - UserName: userName, - Status: "Active", - } - srv.accessKeys = append(srv.accessKeys, key) - return iam.CreateAccessKeyResp{RequestId: reqId, AccessKey: key}, nil -} - -func (srv *Server) deleteAccessKey(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - if err := srv.validate(req, []string{"AccessKeyId", "UserName"}); err != nil { - return nil, err - } - key := req.FormValue("AccessKeyId") - index := -1 - for i, ak := range srv.accessKeys { - if ak.Id == key { - index = i - break - } - } - if index < 0 { - return nil, &iam.Error{ - StatusCode: 404, - Code: "NoSuchEntity", - Message: "No such key.", - } - } - copy(srv.accessKeys[index:], srv.accessKeys[index+1:]) - srv.accessKeys = srv.accessKeys[:len(srv.accessKeys)-1] - return iam.SimpleResp{RequestId: reqId}, nil -} - -func (srv *Server) listAccessKeys(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - if err := srv.validate(req, []string{"UserName"}); err != nil { - return nil, err - } - userName := req.FormValue("UserName") - if _, err := srv.findUser(userName); err != nil { - return nil, err - } - var keys []iam.AccessKey - for _, k := range srv.accessKeys { - if k.UserName == userName { - keys = append(keys, k) - } - } - return iam.AccessKeysResp{ - RequestId: reqId, - AccessKeys: keys, - }, nil -} - -func (srv *Server) createGroup(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - if err := srv.validate(req, []string{"GroupName"}); err != nil { - return nil, err - } - name := req.FormValue("GroupName") - path := req.FormValue("Path") - for _, group := range srv.groups { - if group.Name == name { - return nil, &iam.Error{ - StatusCode: 409, - Code: "EntityAlreadyExists", - Message: fmt.Sprintf("Group with name %s already exists.", name), - } - } - } - group := iam.Group{ - Id: "GROUP " + reqId + "EXAMPLE", - Arn: fmt.Sprintf("arn:aws:iam:::123456789012:group%s%s", path, name), - Name: name, - Path: path, - } - srv.groups = append(srv.groups, group) - return iam.CreateGroupResp{ - RequestId: reqId, - Group: group, - }, nil -} - -func (srv *Server) listGroups(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - pathPrefix := req.FormValue("PathPrefix") - if pathPrefix == "" { - return iam.GroupsResp{ - RequestId: reqId, - Groups: srv.groups, - }, nil - } - var groups []iam.Group - for _, group := range srv.groups { - if strings.HasPrefix(group.Path, pathPrefix) { - groups = append(groups, group) - } - } - return iam.GroupsResp{ - RequestId: reqId, - Groups: groups, - }, nil -} - -func (srv *Server) deleteGroup(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - if err := srv.validate(req, []string{"GroupName"}); err != nil { - return nil, err - } - name := req.FormValue("GroupName") - index := -1 - for i, group := range srv.groups { - if group.Name == name { - index = i - break - } - } - if index == -1 { - return nil, &iam.Error{ - StatusCode: 404, - Code: "NoSuchEntity", - Message: fmt.Sprintf("The group with name %s cannot be found.", name), - } - } - copy(srv.groups[index:], srv.groups[index+1:]) - srv.groups = srv.groups[:len(srv.groups)-1] - return iam.SimpleResp{RequestId: reqId}, nil -} - -func (srv *Server) putUserPolicy(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - if err := srv.validate(req, []string{"UserName", "PolicyDocument", "PolicyName"}); err != nil { - return nil, err - } - var exists bool - policyName := req.FormValue("PolicyName") - userName := req.FormValue("UserName") - for _, policy := range srv.userPolicies { - if policyName == policy.Name && userName == policy.UserName { - exists = true - break - } - } - if !exists { - policy := iam.UserPolicy{ - Name: policyName, - UserName: userName, - Document: req.FormValue("PolicyDocument"), - } - var dumb interface{} - if err := json.Unmarshal([]byte(policy.Document), &dumb); err != nil { - return nil, &iam.Error{ - StatusCode: 400, - Code: "MalformedPolicyDocument", - Message: "Malformed policy document", - } - } - srv.userPolicies = append(srv.userPolicies, policy) - } - return iam.SimpleResp{RequestId: reqId}, nil -} - -func (srv *Server) deleteUserPolicy(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - if err := srv.validate(req, []string{"UserName", "PolicyName"}); err != nil { - return nil, err - } - policyName := req.FormValue("PolicyName") - userName := req.FormValue("UserName") - index := -1 - for i, policy := range srv.userPolicies { - if policyName == policy.Name && userName == policy.UserName { - index = i - break - } - } - if index < 0 { - return nil, &iam.Error{ - StatusCode: 404, - Code: "NoSuchEntity", - Message: "No such user policy", - } - } - copy(srv.userPolicies[index:], srv.userPolicies[index+1:]) - srv.userPolicies = srv.userPolicies[:len(srv.userPolicies)-1] - return iam.SimpleResp{RequestId: reqId}, nil -} - -func (srv *Server) getUserPolicy(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) { - if err := srv.validate(req, []string{"UserName", "PolicyName"}); err != nil { - return nil, err - } - policyName := req.FormValue("PolicyName") - userName := req.FormValue("UserName") - index := -1 - for i, policy := range srv.userPolicies { - if policyName == policy.Name && userName == policy.UserName { - index = i - break - } - } - if index < 0 { - return nil, &iam.Error{ - StatusCode: 404, - Code: "NoSuchEntity", - Message: "No such user policy", - } - } - return iam.GetUserPolicyResp{ - Policy: srv.userPolicies[index], - RequestId: reqId, - }, nil -} - -func (srv *Server) findUser(userName string) (int, error) { - var ( - err error - index = -1 - ) - for i, user := range srv.users { - if user.Name == userName { - index = i - break - } - } - if index < 0 { - err = &iam.Error{ - StatusCode: 404, - Code: "NoSuchEntity", - Message: fmt.Sprintf("The user with name %s cannot be found.", userName), - } - } - return index, err -} - -// Validates the presence of required request parameters. -func (srv *Server) validate(req *http.Request, required []string) error { - for _, r := range required { - if req.FormValue(r) == "" { - return &iam.Error{ - StatusCode: 400, - Code: "InvalidParameterCombination", - Message: fmt.Sprintf("%s is required.", r), - } - } - } - return nil -} - -var actions = map[string]func(*Server, http.ResponseWriter, *http.Request, string) (interface{}, error){ - "CreateUser": (*Server).createUser, - "DeleteUser": (*Server).deleteUser, - "GetUser": (*Server).getUser, - "CreateAccessKey": (*Server).createAccessKey, - "DeleteAccessKey": (*Server).deleteAccessKey, - "ListAccessKeys": (*Server).listAccessKeys, - "PutUserPolicy": (*Server).putUserPolicy, - "DeleteUserPolicy": (*Server).deleteUserPolicy, - "GetUserPolicy": (*Server).getUserPolicy, - "CreateGroup": (*Server).createGroup, - "DeleteGroup": (*Server).deleteGroup, - "ListGroups": (*Server).listGroups, -} diff --git a/vendor/github.com/goamz/goamz/iam/responses_test.go b/vendor/github.com/goamz/goamz/iam/responses_test.go deleted file mode 100644 index d8a0b2c4c..000000000 --- a/vendor/github.com/goamz/goamz/iam/responses_test.go +++ /dev/null @@ -1,261 +0,0 @@ -package iam_test - -// http://goo.gl/EUIvl -var CreateUserExample = ` -<CreateUserResponse> - <CreateUserResult> - <User> - <Path>/division_abc/subdivision_xyz/</Path> - <UserName>Bob</UserName> - <UserId>AIDACKCEVSQ6C2EXAMPLE</UserId> - <Arn>arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob</Arn> - </User> - </CreateUserResult> - <ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> - </ResponseMetadata> -</CreateUserResponse> -` - -var DuplicateUserExample = ` -<ErrorResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/"> - <Error> - <Type>Sender</Type> - <Code>EntityAlreadyExists</Code> - <Message>User with name Bob already exists.</Message> - </Error> - <RequestId>1d5f5000-1316-11e2-a60f-91a8e6fb6d21</RequestId> -</ErrorResponse> -` - -var GetUserExample = ` -<GetUserResponse> - <GetUserResult> - <User> - <Path>/division_abc/subdivision_xyz/</Path> - <UserName>Bob</UserName> - <UserId>AIDACKCEVSQ6C2EXAMPLE</UserId> - <Arn>arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob</Arn> - </User> - </GetUserResult> - <ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> - </ResponseMetadata> -</GetUserResponse> -` - -var CreateGroupExample = ` -<CreateGroupResponse> - <CreateGroupResult> - <Group> - <Path>/admins/</Path> - <GroupName>Admins</GroupName> - <GroupId>AGPACKCEVSQ6C2EXAMPLE</GroupId> - <Arn>arn:aws:iam::123456789012:group/Admins</Arn> - </Group> - </CreateGroupResult> - <ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> - </ResponseMetadata> -</CreateGroupResponse> -` - -var ListGroupsExample = ` -<ListGroupsResponse> - <ListGroupsResult> - <Groups> - <member> - <Path>/division_abc/subdivision_xyz/</Path> - <GroupName>Admins</GroupName> - <GroupId>AGPACKCEVSQ6C2EXAMPLE</GroupId> - <Arn>arn:aws:iam::123456789012:group/Admins</Arn> - </member> - <member> - <Path>/division_abc/subdivision_xyz/product_1234/engineering/</Path> - <GroupName>Test</GroupName> - <GroupId>AGP2MAB8DPLSRHEXAMPLE</GroupId> - <Arn>arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/engineering/Test</Arn> - </member> - <member> - <Path>/division_abc/subdivision_xyz/product_1234/</Path> - <GroupName>Managers</GroupName> - <GroupId>AGPIODR4TAW7CSEXAMPLE</GroupId> - <Arn>arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/Managers</Arn> - </member> - </Groups> - <IsTruncated>false</IsTruncated> - </ListGroupsResult> - <ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> - </ResponseMetadata> -</ListGroupsResponse> -` - -var RequestIdExample = ` -<AddUserToGroupResponse> - <ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> - </ResponseMetadata> -</AddUserToGroupResponse> -` - -var CreateAccessKeyExample = ` -<CreateAccessKeyResponse> - <CreateAccessKeyResult> - <AccessKey> - <UserName>Bob</UserName> - <AccessKeyId>AKIAIOSFODNN7EXAMPLE</AccessKeyId> - <Status>Active</Status> - <SecretAccessKey>wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY</SecretAccessKey> - </AccessKey> - </CreateAccessKeyResult> - <ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> - </ResponseMetadata> -</CreateAccessKeyResponse> -` - -var ListAccessKeyExample = ` -<ListAccessKeysResponse> - <ListAccessKeysResult> - <UserName>Bob</UserName> - <AccessKeyMetadata> - <member> - <UserName>Bob</UserName> - <AccessKeyId>AKIAIOSFODNN7EXAMPLE</AccessKeyId> - <Status>Active</Status> - </member> - <member> - <UserName>Bob</UserName> - <AccessKeyId>AKIAI44QH8DHBEXAMPLE</AccessKeyId> - <Status>Inactive</Status> - </member> - </AccessKeyMetadata> - <IsTruncated>false</IsTruncated> - </ListAccessKeysResult> - <ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> - </ResponseMetadata> -</ListAccessKeysResponse> -` - -var GetUserPolicyExample = ` -<GetUserPolicyResponse> - <GetUserPolicyResult> - <UserName>Bob</UserName> - <PolicyName>AllAccessPolicy</PolicyName> - <PolicyDocument> - {"Statement":[{"Effect":"Allow","Action":"*","Resource":"*"}]} - </PolicyDocument> - </GetUserPolicyResult> - <ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> - </ResponseMetadata> -</GetUserPolicyResponse> -` - -var AddUserToGroupExample = ` -<AddUserToGroupResponse> - <ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> - </ResponseMetadata> -</AddUserToGroupResponse> -` - -var ListAccountAliasesExample = ` -<ListAccountAliasesResponse> - <ListAccountAliasesResult> - <IsTruncated>false</IsTruncated> - <AccountAliases> - <member>foocorporation</member> - </AccountAliases> - </ListAccountAliasesResult> - <ResponseMetadata> - <RequestId>c5a076e9-f1b0-11df-8fbe-45274EXAMPLE</RequestId> - </ResponseMetadata> -</ListAccountAliasesResponse> -` - -var CreateAccountAliasExample = ` -<CreateAccountAliasResponse> - <ResponseMetadata> - <RequestId>36b5db08-f1b0-11df-8fbe-45274EXAMPLE</RequestId> - </ResponseMetadata> -</CreateAccountAliasResponse> -` - -var DeleteAccountAliasExample = ` -<DeleteAccountAliasResponse> - <ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> - </ResponseMetadata> -</DeleteAccountAliasResponse> -` - -var UploadServerCertificateExample = ` -<UploadServerCertificateResponse> -<UploadServerCertificateResult> - <ServerCertificateMetadata> - <ServerCertificateName>ProdServerCert</ServerCertificateName> - <Path>/company/servercerts/</Path> - <Arn>arn:aws:iam::123456789012:server-certificate/company/servercerts/ProdServerCert</Arn> - <UploadDate>2010-05-08T01:02:03.004Z</UploadDate> - <ServerCertificateId>ASCACKCEVSQ6C2EXAMPLE</ServerCertificateId> - <Expiration>2012-05-08T01:02:03.004Z</Expiration> - </ServerCertificateMetadata> -</UploadServerCertificateResult> -<ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> -</ResponseMetadata> -</UploadServerCertificateResponse> -` -var ListServerCertificatesExample = ` -<ListServerCertificatesResponse> -<ListServerCertificatesResult> - <IsTruncated>false</IsTruncated> - <ServerCertificateMetadataList> - <member> - <ServerCertificateMetadata> - <ServerCertificateName>ProdServerCert</ServerCertificateName> - <Path>/some/fake/path</Path> - <Arn>arn:aws:iam::123456789012:server-certificate/company/servercerts/ProdServerCert</Arn> - <UploadDate>2010-05-08T01:02:03.004Z</UploadDate> - <ServerCertificateId>ASCACKCEVSQ6C2EXAMPLE1</ServerCertificateId> - <Expiration>2012-05-08T01:02:03.004Z</Expiration> - </ServerCertificateMetadata> - </member> - <member> - <ServerCertificateMetadata> - <ServerCertificateName>BetaServerCert</ServerCertificateName> - <Path>/some/fake/path</Path> - <Arn>arn:aws:iam::123456789012:server-certificate/company/servercerts/BetaServerCert</Arn> - <UploadDate>2010-05-08T01:02:03.004Z</UploadDate> - <ServerCertificateId>ASCACKCEVSQ6C2EXAMPLE2</ServerCertificateId> - <Expiration>2012-05-08T01:02:03.004Z</Expiration> - </ServerCertificateMetadata> - </member> - <member> - <ServerCertificateMetadata> - <ServerCertificateName>TestServerCert</ServerCertificateName> - <Path>/some/fake/path</Path> - <Arn>arn:aws:iam::123456789012:server-certificate/company/servercerts/TestServerCert</Arn> - <UploadDate>2010-05-08T01:02:03.004Z</UploadDate> - <ServerCertificateId>ASCACKCEVSQ6C2EXAMPLE3</ServerCertificateId> - <Expiration>2012-05-08T01:02:03.004Z</Expiration> - </ServerCertificateMetadata> - </member> - </ServerCertificateMetadataList> -</ListServerCertificatesResult> -<ResponseMetadata> - <RequestId>7a62c49f-347e-4fc4-9331-6e8eTHISDIFFERENTTEST</RequestId> -</ResponseMetadata> -</ListServerCertificatesResponse> -` - -var DeleteServerCertificateExample = ` -<DeleteServerCertificateResponse> -<ResponseMetadata> -<RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> -</ResponseMetadata> -</DeleteServerCertificateResponse> -` diff --git a/vendor/github.com/goamz/goamz/iam/sign.go b/vendor/github.com/goamz/goamz/iam/sign.go deleted file mode 100644 index b704fd8d6..000000000 --- a/vendor/github.com/goamz/goamz/iam/sign.go +++ /dev/null @@ -1,38 +0,0 @@ -package iam - -import ( - "crypto/hmac" - "crypto/sha256" - "encoding/base64" - "github.com/goamz/goamz/aws" - "sort" - "strings" -) - -// ---------------------------------------------------------------------------- -// Version 2 signing (http://goo.gl/RSRp5) - -var b64 = base64.StdEncoding - -func sign(auth aws.Auth, method, path string, params map[string]string, host string) { - params["AWSAccessKeyId"] = auth.AccessKey - params["SignatureVersion"] = "2" - params["SignatureMethod"] = "HmacSHA256" - if auth.Token() != "" { - params["SecurityToken"] = auth.Token() - } - - var sarray []string - for k, v := range params { - sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v)) - } - sort.StringSlice(sarray).Sort() - joined := strings.Join(sarray, "&") - payload := method + "\n" + host + "\n" + path + "\n" + joined - hash := hmac.New(sha256.New, []byte(auth.SecretKey)) - hash.Write([]byte(payload)) - signature := make([]byte, b64.EncodedLen(hash.Size())) - b64.Encode(signature, hash.Sum(nil)) - - params["Signature"] = string(signature) -} |