func (s *S) TestDescribeLoadBalancersBadRequest(c *gocheck.C) { testServer.PrepareResponse(400, nil, DescribeLoadBalancersBadRequest) resp, err := s.elb.DescribeLoadBalancers() c.Assert(resp, gocheck.IsNil) c.Assert(err, gocheck.NotNil) c.Assert(err, gocheck.ErrorMatches, `^Cannot find Load Balancer absentlb \(LoadBalancerNotFound\)$`) }
func (s *S) SetUpSuite(c *gocheck.C) { var err error testServer.Start() auth := aws.Auth{AccessKey: "abc", SecretKey: "123"} s.rds, err = rds.New(auth, aws.Region{RDSEndpoint: aws.ServiceInfo{testServer.URL, aws.V2Signature}}) c.Assert(err, gocheck.IsNil) }
func (s *S) TestListGroups(c *gocheck.C) { testServer.Response(200, nil, ListGroupsExample) resp, err := s.iam.Groups("/division_abc/") values := testServer.WaitRequest().URL.Query() c.Assert(values.Get("Action"), gocheck.Equals, "ListGroups") c.Assert(values.Get("PathPrefix"), gocheck.Equals, "/division_abc/") c.Assert(err, gocheck.IsNil) c.Assert(resp.RequestId, gocheck.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, gocheck.DeepEquals, expected) }
func (s *DynamoDBTest) WaitUntilStatus(c *gocheck.C, status string) { // We should wait until the table is in specified status because a real DynamoDB has some delay for ready done := make(chan bool) timeout := time.After(TIMEOUT) go func() { for { select { case <-done: return default: desc, err := s.table.DescribeTable() if err != nil { c.Fatal(err) } if desc.TableStatus == status { done <- true return } time.Sleep(5 * time.Second) } } }() select { case <-done: break case <-timeout: c.Errorf("Expect a status to be %s, but timed out", status) close(done) } }
func (s *AmazonServerSuite) SetUpSuite(c *gocheck.C) { if !*amazon { c.Skip("AmazonServerSuite tests not enabled") } s.srv.SetUp(c) s.ServerTests.elb = elb.New(s.srv.auth, aws.USEast) }
func (s *ClientTests) createInstanceAndLB(c *gocheck.C) (*elb.CreateLoadBalancer, string) { options := ec2.RunInstancesOptions{ ImageId: "ami-ccf405a5", InstanceType: "t1.micro", AvailabilityZone: "us-east-1c", } resp1, err := s.ec2.RunInstances(&options) c.Assert(err, gocheck.IsNil) instId := resp1.Instances[0].InstanceId createLBReq := elb.CreateLoadBalancer{ Name: "testlb", AvailabilityZones: []string{"us-east-1c"}, Listeners: []elb.Listener{ { InstancePort: 80, InstanceProtocol: "http", LoadBalancerPort: 80, Protocol: "http", }, }, } _, err = s.elb.CreateLoadBalancer(&createLBReq) c.Assert(err, gocheck.IsNil) return &createLBReq, instId }
func (s *LocalServer) SetUp(c *gocheck.C) { srv, err := elbtest.NewServer() c.Assert(err, gocheck.IsNil) c.Assert(srv, gocheck.NotNil) s.srv = srv s.region = aws.Region{ELBEndpoint: srv.URL()} }
func (s *S) TestDescribeScheduledActions(c *gocheck.C) { testServer.Response(200, nil, DescribeScheduledActionsResponse) st, _ := time.Parse(time.RFC3339, "2014-06-01T00:30:00Z") request := &DescribeScheduledActionsParams{ AutoScalingGroupName: "ASGTest1", MaxRecords: 1, StartTime: st, } resp, err := s.as.DescribeScheduledActions(request) c.Assert(err, gocheck.IsNil) values := testServer.WaitRequest().PostForm c.Assert(values.Get("Version"), gocheck.Equals, "2011-01-01") c.Assert(values.Get("Action"), gocheck.Equals, "DescribeScheduledActions") c.Assert(resp.RequestId, gocheck.Equals, "0eb4217f-8421-11e3-9233-7100ef811766") c.Assert(resp.ScheduledUpdateGroupActions, gocheck.DeepEquals, []ScheduledUpdateGroupAction{ { AutoScalingGroupName: "ASGTest1", ScheduledActionARN: "arn:aws:autoscaling:us-west-2:193024542802:scheduledUpdateGroupAction:61f68b2c-bde3-4316-9a81-eb95dc246509:autoScalingGroupName/ASGTest1:scheduledActionName/SATest1", ScheduledActionName: "SATest1", Recurrence: "30 0 1 1,6,12 *", MaxSize: 4, StartTime: st, Time: st, }, }) }
func (s *S) TestExitStandby(c *gocheck.C) { testServer.Response(200, nil, ExitStandbyResponse) resp, err := s.as.ExitStandby("my-asg", []string{"i-5b73d709"}) c.Assert(err, gocheck.IsNil) values := testServer.WaitRequest().PostForm c.Assert(values.Get("Version"), gocheck.Equals, "2011-01-01") c.Assert(values.Get("Action"), gocheck.Equals, "ExitStandby") c.Assert(values.Get("AutoScalingGroupName"), gocheck.Equals, "my-asg") c.Assert(values.Get("InstanceIds.member.1"), gocheck.Equals, "i-5b73d709") st, _ := time.Parse(time.RFC3339, "2014-06-13T22:43:53.523Z") expected := &ExitStandbyResult{ RequestId: "321a11c8-f34c-11e3-a434-7f10009d5849", Activities: []Activity{ { StatusCode: "PreInService", Progress: 30, ActivityId: "dca4efcf-eea6-4844-8064-cab1fecd1aa2", StartTime: st, AutoScalingGroupName: "my-asg", Details: "{\"Availability Zone\":\"us-east-1a\"}", Cause: "At 2014-06-13T22:43:53Z instance i-5b73d709 was moved out of standby in response to a user request, increasing the capacity from 3 to 4.", Description: "Moving EC2 instance out of Standby: i-5b73d709", }, }, } c.Assert(resp, gocheck.DeepEquals, expected) }
func (s *AmazonServer) SetUp(c *gocheck.C) { auth, err := aws.EnvAuth() if err != nil { c.Fatal(err.Error()) } s.auth = auth }
func (s *AmazonClientSuite) SetUpSuite(c *gocheck.C) { if !testutil.Amazon { c.Skip("AmazonClientSuite tests not enabled") } s.srv.SetUp(c) s.iam = iam.New(s.srv.auth, aws.USEast) }
func (s *AmazonServerSuite) SetUpSuite(c *gocheck.C) { if !testutil.Amazon { c.Skip("AmazonServerSuite tests not enabled") } s.srv.SetUp(c) s.ServerTests.ec2 = ec2.NewWithClient(s.srv.auth, aws.USEast, testutil.DefaultClient) }
func (s *S) TestEscaping(c *gocheck.C) { params := map[string]string{"Nonce": "+ +"} elb.Sign(testAuth, "GET", "/path", params, "localhost") c.Assert(params["Nonce"], gocheck.Equals, "+ +") expected := "bqffDELReIqwjg/W0DnsnVUmfLK4wXVLO4/LuG+1VFA=" c.Assert(params["Signature"], gocheck.Equals, expected) }
func (s *S) TestDescribeInstanceHealthBadRequest(c *gocheck.C) { testServer.PrepareResponse(400, nil, DescribeInstanceHealthBadRequest) resp, err := s.elb.DescribeInstanceHealth("testlb", "i-foooo") c.Assert(err, gocheck.NotNil) c.Assert(resp, gocheck.IsNil) c.Assert(err, gocheck.ErrorMatches, ".*i-foooo.*(InvalidInstance).*") }
func (s *S) TestGetTemplate(c *gocheck.C) { testServer.Response(200, nil, GetTemplateResponse) resp, err := s.cf.GetTemplate("MyStack") c.Assert(err, gocheck.IsNil) values := testServer.WaitRequest().PostForm // Post request test c.Assert(values.Get("Version"), gocheck.Equals, "2010-05-15") c.Assert(values.Get("Action"), gocheck.Equals, "GetTemplate") c.Assert(values.Get("StackName"), gocheck.Equals, "MyStack") // Response test templateBody := `{ "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "Simple example", "Resources" : { "MySQS" : { "Type" : "AWS::SQS::Queue", "Properties" : { } } } }` c.Assert(resp.TemplateBody, gocheck.Equals, templateBody) c.Assert(resp.RequestId, gocheck.Equals, "4af14eec-350e-11e4-b260-EXAMPLE") }
func (s *S) TestGetAuthEnv(c *gocheck.C) { os.Clearenv() os.Setenv("AWS_SECRET_ACCESS_KEY", "secret") os.Setenv("AWS_ACCESS_KEY_ID", "access") auth, err := aws.GetAuth("", "", "", time.Time{}) c.Assert(err, gocheck.IsNil) c.Assert(auth, gocheck.Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"}) }
func (s *S) TestEnvAuthAlt(c *gocheck.C) { os.Clearenv() os.Setenv("AWS_SECRET_KEY", "secret") os.Setenv("AWS_ACCESS_KEY", "access") auth, err := aws.EnvAuth() c.Assert(err, gocheck.IsNil) c.Assert(auth, gocheck.Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"}) }
func (s *AmazonClientSuite) SetUpSuite(c *gocheck.C) { if !*amazon { c.Skip("AmazonClientSuite tests not enabled") } s.srv.SetUp(c) s.elb = elb.New(s.srv.auth, aws.USEast) s.ec2 = ec2.New(s.srv.auth, aws.USEast) }
func (s *AmazonClientSuite) SetUpSuite(c *gocheck.C) { if !testutil.Amazon { c.Skip("live tests against AWS disabled (no -amazon)") } s.srv.SetUp(c) s.s3 = s3.New(s.srv.auth, s.Region) // In case tests were interrupted in the middle before. s.ClientTests.Cleanup() }
func (s *ClientTests) TestListAccessKeysUserNotFound(c *gocheck.C) { _, err := s.iam.AccessKeys("unknowngopher") c.Assert(err, gocheck.NotNil) iamErr, ok := err.(*iam.Error) c.Assert(ok, gocheck.Equals, true) c.Assert(iamErr.StatusCode, gocheck.Equals, 404) c.Assert(iamErr.Code, gocheck.Equals, "NoSuchEntity") c.Assert(iamErr.Message, gocheck.Equals, "The user with name unknowngopher cannot be found.") }
func (s *LocalServerSuite) TestDeregisterInstancewithLoadBalancerWithAbsentInstance(c *gocheck.C) { srv := s.srv.srv srv.NewLoadBalancer("testlb") defer srv.RemoveLoadBalancer("testlb") resp, err := s.clientTests.elb.DeregisterInstancesFromLoadBalancer([]string{"i-212"}, "testlb") c.Assert(resp, gocheck.IsNil) c.Assert(err, gocheck.NotNil) c.Assert(err, gocheck.ErrorMatches, `^InvalidInstance found in \[i-212\]. Invalid id: "i-212" \(InvalidInstance\)$`) }
func (s *AmazonDomainClientSuite) SetUpSuite(c *gocheck.C) { if !testutil.Amazon { c.Skip("live tests against AWS disabled (no -amazon)") } s.srv.SetUp(c) region := s.Region region.S3BucketEndpoint = "https://${bucket}.s3.amazonaws.com" s.s3 = s3.New(s.srv.auth, region) s.ClientTests.Cleanup() }
func (s *LocalServerSuite) TestRegisterInstanceWithLoadBalancer(c *gocheck.C) { srv := s.srv.srv instId := srv.NewInstance() defer srv.RemoveInstance(instId) srv.NewLoadBalancer("testlb") defer srv.RemoveLoadBalancer("testlb") resp, err := s.clientTests.elb.RegisterInstancesWithLoadBalancer([]string{instId}, "testlb") c.Assert(err, gocheck.IsNil) c.Assert(resp.InstanceIds, gocheck.DeepEquals, []string{instId}) }
func (s *S) TestDeleteSecurityGroupExampleWithId(c *gocheck.C) { testServer.Response(200, nil, DeleteSecurityGroupExample) // ignore return and error - we're only want to check the parameter handling. s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Id: "sg-67ad940e", Name: "ignored"}) req := testServer.WaitRequest() c.Assert(req.Form["GroupName"], gocheck.IsNil) c.Assert(req.Form["GroupId"], gocheck.DeepEquals, []string{"sg-67ad940e"}) }
func (s *QueryBuilderSuite) TestEmptyQuery(c *gocheck.C) { q := dynamodb.NewEmptyQuery() queryString := q.String() expectedString := "{}" c.Check(queryString, gocheck.Equals, expectedString) if expectedString != queryString { c.Fatalf("Unexpected Query String : %s\n", queryString) } }
func (s *LiveSuite) SetUpSuite(c *gocheck.C) { if !Amazon { c.Skip("amazon tests not enabled (-amazon flag)") } auth, err := aws.EnvAuth() if err != nil { c.Fatal(err.Error()) } s.auth = auth }
func (s *S) TestAddUserToGroup(c *gocheck.C) { testServer.Response(200, nil, AddUserToGroupExample) resp, err := s.iam.AddUserToGroup("admin1", "Admins") values := testServer.WaitRequest().URL.Query() c.Assert(values.Get("Action"), gocheck.Equals, "AddUserToGroup") c.Assert(values.Get("GroupName"), gocheck.Equals, "Admins") c.Assert(values.Get("UserName"), gocheck.Equals, "admin1") c.Assert(err, gocheck.IsNil) c.Assert(resp.RequestId, gocheck.Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") }
func (s *S) TestDeleteUserPolicy(c *gocheck.C) { testServer.Response(200, nil, RequestIdExample) resp, err := s.iam.DeleteUserPolicy("Bob", "AllAccessPolicy") values := testServer.WaitRequest().URL.Query() c.Assert(values.Get("Action"), gocheck.Equals, "DeleteUserPolicy") c.Assert(values.Get("PolicyName"), gocheck.Equals, "AllAccessPolicy") c.Assert(values.Get("UserName"), gocheck.Equals, "Bob") c.Assert(err, gocheck.IsNil) c.Assert(resp.RequestId, gocheck.Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE") }
func (s *MarshallerSuite) TestMarshalEmptySets(c *gocheck.C) { testObj := testObjectWithEmptySets() attrs, err := dynamodb.MarshalAttributes(testObj) if err != nil { c.Errorf("Error from dynamodb.MarshalAttributes: %#v", err) } expected := testAttrsWithNilSets() c.Check(attrs, gocheck.DeepEquals, expected) }
func (s *S) TestCreateQueueWithTimeout(c *gocheck.C) { testServer.PrepareResponse(200, nil, TestCreateQueueXmlOK) s.sqs.CreateQueueWithTimeout("testQueue", 180) req := testServer.WaitRequest() // TestCreateQueue() tests the core functionality, just check the timeout in this test c.Assert(req.Form["Attribute.1.Name"], gocheck.DeepEquals, []string{"VisibilityTimeout"}) c.Assert(req.Form["Attribute.1.Value"], gocheck.DeepEquals, []string{"180"}) }