Пример #1
0
func (s *S) TestCreateLoadBalancer(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, CreateLoadBalancer)
	createLB := &elb.CreateLoadBalancer{
		Name:              "testlb",
		AvailabilityZones: []string{"us-east-1a", "us-east-1b"},
		Listeners: []elb.Listener{
			{
				InstancePort:     80,
				InstanceProtocol: "http",
				Protocol:         "http",
				LoadBalancerPort: 80,
			},
		},
	}
	resp, err := s.elb.CreateLoadBalancer(createLB)
	c.Assert(err, gocheck.IsNil)
	defer s.elb.DeleteLoadBalancer(createLB.Name)
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Action"), gocheck.Equals, "CreateLoadBalancer")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("LoadBalancerName"), gocheck.Equals, "testlb")
	c.Assert(values.Get("AvailabilityZones.member.1"), gocheck.Equals, "us-east-1a")
	c.Assert(values.Get("AvailabilityZones.member.2"), gocheck.Equals, "us-east-1b")
	c.Assert(values.Get("Listeners.member.1.InstancePort"), gocheck.Equals, "80")
	c.Assert(values.Get("Listeners.member.1.InstanceProtocol"), gocheck.Equals, "http")
	c.Assert(values.Get("Listeners.member.1.Protocol"), gocheck.Equals, "http")
	c.Assert(values.Get("Listeners.member.1.LoadBalancerPort"), gocheck.Equals, "80")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(resp.DNSName, gocheck.Equals, "testlb-339187009.us-east-1.elb.amazonaws.com")
}
Пример #2
0
func (s *S) TestConfigureHealthCheck(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, ConfigureHealthCheck)
	hc := elb.HealthCheck{
		HealthyThreshold:   10,
		Interval:           30,
		Target:             "HTTP:80/",
		Timeout:            5,
		UnhealthyThreshold: 2,
	}
	resp, err := s.elb.ConfigureHealthCheck("testlb", &hc)
	c.Assert(err, gocheck.IsNil)
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Action"), gocheck.Equals, "ConfigureHealthCheck")
	c.Assert(values.Get("LoadBalancerName"), gocheck.Equals, "testlb")
	c.Assert(values.Get("HealthCheck.HealthyThreshold"), gocheck.Equals, "10")
	c.Assert(values.Get("HealthCheck.Interval"), gocheck.Equals, "30")
	c.Assert(values.Get("HealthCheck.Target"), gocheck.Equals, "HTTP:80/")
	c.Assert(values.Get("HealthCheck.Timeout"), gocheck.Equals, "5")
	c.Assert(values.Get("HealthCheck.UnhealthyThreshold"), gocheck.Equals, "2")
	c.Assert(resp.HealthCheck.HealthyThreshold, gocheck.Equals, 10)
	c.Assert(resp.HealthCheck.Interval, gocheck.Equals, 30)
	c.Assert(resp.HealthCheck.Target, gocheck.Equals, "HTTP:80/")
	c.Assert(resp.HealthCheck.Timeout, gocheck.Equals, 5)
	c.Assert(resp.HealthCheck.UnhealthyThreshold, gocheck.Equals, 2)
}
Пример #3
0
func (s *S) TestListPlatformApplications(c *gocheck.C) {
	testServer.Response(200, nil, TestListPlatformApplicationsXmlOK)

	resp, err := s.sns.ListPlatformApplications("")
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(len(resp.PlatformApplications), gocheck.Not(gocheck.Equals), 0)

	c.Assert(resp.PlatformApplications[0].PlatformApplicationArn, gocheck.Equals, "arn:aws:sns:us-west-2:123456789012:app/APNS_SANDBOX/apnspushapp")
	c.Assert(len(resp.PlatformApplications[0].Attributes), gocheck.Equals, 1)
	c.Assert(resp.PlatformApplications[0].Attributes[0].Key, gocheck.Equals, "AllowEndpointPolicies")
	c.Assert(resp.PlatformApplications[0].Attributes[0].Value, gocheck.Equals, "false")

	c.Assert(resp.PlatformApplications[1].PlatformApplicationArn, gocheck.Equals, "arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp")
	c.Assert(len(resp.PlatformApplications[1].Attributes), gocheck.Equals, 1)
	c.Assert(resp.PlatformApplications[1].Attributes[0].Key, gocheck.Equals, "AllowEndpointPolicies")
	c.Assert(resp.PlatformApplications[1].Attributes[0].Value, gocheck.Equals, "false")

	c.Assert(resp.RequestId, gocheck.Equals, "315a335e-85d8-52df-9349-791283cbb529")

	c.Assert(err, gocheck.IsNil)
}
Пример #4
0
func (s *S) TestDescribeLoadBalancersByName(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, DescribeLoadBalancers)
	s.elb.DescribeLoadBalancers("somelb")
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Action"), gocheck.Equals, "DescribeLoadBalancers")
	c.Assert(values.Get("LoadBalancerNames.member.1"), gocheck.Equals, "somelb")
}
Пример #5
0
func (s *S) TestDeleteLoadBalancer(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, DeleteLoadBalancer)
	resp, err := s.elb.DeleteLoadBalancer("testlb")
	c.Assert(err, gocheck.IsNil)
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Action"), gocheck.Equals, "DeleteLoadBalancer")
	c.Assert(values.Get("LoadBalancerName"), gocheck.Equals, "testlb")
	c.Assert(resp.RequestId, gocheck.Equals, "8d7223db-49d7-11e2-bba9-35ba56032fe1")
}
Пример #6
0
func (s *S) TestDescribeLoadBalancers(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, DescribeLoadBalancers)
	resp, err := s.elb.DescribeLoadBalancers()
	c.Assert(err, gocheck.IsNil)
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Action"), gocheck.Equals, "DescribeLoadBalancers")
	t, _ := time.Parse(time.RFC3339, "2012-12-27T11:51:52.970Z")
	expected := &elb.DescribeLoadBalancerResp{
		[]elb.LoadBalancerDescription{
			{
				AvailabilityZones:         []string{"us-east-1a"},
				BackendServerDescriptions: []elb.BackendServerDescriptions(nil),
				CanonicalHostedZoneName:   "testlb-2087227216.us-east-1.elb.amazonaws.com",
				CanonicalHostedZoneNameId: "Z3DZXE0Q79N41H",
				CreatedTime:               t,
				DNSName:                   "testlb-2087227216.us-east-1.elb.amazonaws.com",
				HealthCheck: elb.HealthCheck{
					HealthyThreshold:   10,
					Interval:           30,
					Target:             "TCP:80",
					Timeout:            5,
					UnhealthyThreshold: 2,
				},
				Instances: []elb.Instance(nil),
				ListenerDescriptions: []elb.ListenerDescription{
					{
						Listener: elb.Listener{
							Protocol:         "HTTP",
							LoadBalancerPort: 80,
							InstanceProtocol: "HTTP",
							InstancePort:     80,
						},
					},
				},
				LoadBalancerName: "testlb",
				//Policies:                  elb.Policies(nil),
				Scheme:         "internet-facing",
				SecurityGroups: []string(nil),
				SourceSecurityGroup: elb.SourceSecurityGroup{
					GroupName:  "amazon-elb-sg",
					OwnerAlias: "amazon-elb",
				},
				Subnets: []string(nil),
			},
		},
	}
	c.Assert(resp, gocheck.DeepEquals, expected)
}
Пример #7
0
func (s *S) TestRegisterInstancesWithLoadBalancer(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, RegisterInstancesWithLoadBalancer)
	resp, err := s.elb.RegisterInstancesWithLoadBalancer([]string{"i-b44db8ca", "i-461ecf38"}, "testlb")
	c.Assert(err, gocheck.IsNil)
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Action"), gocheck.Equals, "RegisterInstancesWithLoadBalancer")
	c.Assert(values.Get("LoadBalancerName"), gocheck.Equals, "testlb")
	c.Assert(values.Get("Instances.member.1.InstanceId"), gocheck.Equals, "i-b44db8ca")
	c.Assert(values.Get("Instances.member.2.InstanceId"), gocheck.Equals, "i-461ecf38")
	c.Assert(resp.InstanceIds, gocheck.DeepEquals, []string{"i-b44db8ca", "i-461ecf38"})
}
Пример #8
0
func (s *S) TestDeregisterInstancesFromLoadBalancer(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, DeregisterInstancesFromLoadBalancer)
	resp, err := s.elb.DeregisterInstancesFromLoadBalancer([]string{"i-b44db8ca", "i-461ecf38"}, "testlb")
	c.Assert(err, gocheck.IsNil)
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Action"), gocheck.Equals, "DeregisterInstancesFromLoadBalancer")
	c.Assert(values.Get("LoadBalancerName"), gocheck.Equals, "testlb")
	c.Assert(values.Get("Instances.member.1.InstanceId"), gocheck.Equals, "i-b44db8ca")
	c.Assert(values.Get("Instances.member.2.InstanceId"), gocheck.Equals, "i-461ecf38")
	c.Assert(resp.RequestId, gocheck.Equals, "d6490837-49fd-11e2-bba9-35ba56032fe1")
}
Пример #9
0
func (s *S) TestListQueues(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, TestListQueuesXmlOK)

	resp, err := s.sqs.ListQueues("")
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(len(resp.QueueUrl), gocheck.Not(gocheck.Equals), 0)
	c.Assert(resp.QueueUrl[0], gocheck.Equals, "http://sqs.us-east-1.amazonaws.com/123456789012/testQueue")
	c.Assert(resp.ResponseMetadata.RequestId, gocheck.Equals, "725275ae-0b9b-4762-b238-436d7c65a1ac")
	c.Assert(err, gocheck.IsNil)
}
Пример #10
0
func (s *S) TestAttrsSelectOK(c *gocheck.C) {
	testServer.Response(200, nil, TestAttrsXmlOK)

	domain := s.sdb.Domain("MyDomain")
	item := domain.Item("Item123")

	resp, err := item.Attrs([]string{"Color", "Size"}, true)
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")
	c.Assert(req.Form["Action"], gocheck.DeepEquals, []string{"GetAttributes"})
	c.Assert(req.Form["ItemName"], gocheck.DeepEquals, []string{"Item123"})
	c.Assert(req.Form["DomainName"], gocheck.DeepEquals, []string{"MyDomain"})
	c.Assert(req.Form["ConsistentRead"], gocheck.DeepEquals, []string{"true"})
	c.Assert(req.Form["AttributeName.1"], gocheck.DeepEquals, []string{"Color"})
	c.Assert(req.Form["AttributeName.2"], gocheck.DeepEquals, []string{"Size"})

	c.Assert(resp.Attrs[0].Name, gocheck.Equals, "Color")
	c.Assert(resp.Attrs[0].Value, gocheck.Equals, "Blue")
	c.Assert(resp.Attrs[1].Name, gocheck.Equals, "Size")
	c.Assert(resp.Attrs[1].Value, gocheck.Equals, "Med")
	c.Assert(resp.ResponseMetadata.RequestId, gocheck.Equals, "b1e8f1f7-42e9-494c-ad09-2674e557526d")
	c.Assert(resp.ResponseMetadata.BoxUsage, gocheck.Equals, 0.0000219942)

	c.Assert(err, gocheck.IsNil)
}
Пример #11
0
func (s *S) TestListWithDelimiter(c *gocheck.C) {
	testServer.Response(200, nil, GetListResultDump2)

	b := s.s3.Bucket("quotes")

	data, err := b.List("photos/2006/", "/", "some-marker", 1000)
	c.Assert(err, gocheck.IsNil)

	req := testServer.WaitRequest()
	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/quotes/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")
	c.Assert(req.Form["prefix"], gocheck.DeepEquals, []string{"photos/2006/"})
	c.Assert(req.Form["delimiter"], gocheck.DeepEquals, []string{"/"})
	c.Assert(req.Form["marker"], gocheck.DeepEquals, []string{"some-marker"})
	c.Assert(req.Form["max-keys"], gocheck.DeepEquals, []string{"1000"})

	c.Assert(data.Name, gocheck.Equals, "example-bucket")
	c.Assert(data.Prefix, gocheck.Equals, "photos/2006/")
	c.Assert(data.Delimiter, gocheck.Equals, "/")
	c.Assert(data.Marker, gocheck.Equals, "some-marker")
	c.Assert(data.IsTruncated, gocheck.Equals, false)
	c.Assert(len(data.Contents), gocheck.Equals, 0)
	c.Assert(data.CommonPrefixes, gocheck.DeepEquals, []string{"photos/2006/feb/", "photos/2006/jan/"})
}
Пример #12
0
func (s *S) TestGetPlatformApplicationAttributes(c *gocheck.C) {
	testServer.Response(200, nil, TestGetPlatformApplicationAttributesXmlOK)

	resp, err := s.sns.GetPlatformApplicationAttributes("arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp", "")
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(len(resp.Attributes), gocheck.Not(gocheck.Equals), 0)
	c.Assert(resp.Attributes[0].Key, gocheck.Equals, "AllowEndpointPolicies")
	c.Assert(resp.Attributes[0].Value, gocheck.Equals, "false")
	c.Assert(resp.RequestId, gocheck.Equals, "74848df2-87f6-55ed-890c-c7be80442462")

	c.Assert(err, gocheck.IsNil)
}
Пример #13
0
func (s *S) TestDescribeInstanceHealth(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, DescribeInstanceHealth)
	resp, err := s.elb.DescribeInstanceHealth("testlb", "i-b44db8ca")
	c.Assert(err, gocheck.IsNil)
	values := testServer.WaitRequest().URL.Query()
	c.Assert(values.Get("Version"), gocheck.Equals, "2012-06-01")
	c.Assert(values.Get("Signature"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Timestamp"), gocheck.Not(gocheck.Equals), "")
	c.Assert(values.Get("Action"), gocheck.Equals, "DescribeInstanceHealth")
	c.Assert(values.Get("LoadBalancerName"), gocheck.Equals, "testlb")
	c.Assert(values.Get("Instances.member.1.InstanceId"), gocheck.Equals, "i-b44db8ca")
	c.Assert(len(resp.InstanceStates) > 0, gocheck.Equals, true)
	c.Assert(resp.InstanceStates[0].Description, gocheck.Equals, "Instance registration is still in progress.")
	c.Assert(resp.InstanceStates[0].InstanceId, gocheck.Equals, "i-b44db8ca")
	c.Assert(resp.InstanceStates[0].State, gocheck.Equals, "OutOfService")
	c.Assert(resp.InstanceStates[0].ReasonCode, gocheck.Equals, "ELB")
}
Пример #14
0
func (s *S) TestListSubscriptions(c *gocheck.C) {
	testServer.Response(200, nil, TestListSubscriptionsXmlOK)

	resp, err := s.sns.ListSubscriptions(nil)
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(len(resp.Subscriptions), gocheck.Not(gocheck.Equals), 0)
	c.Assert(resp.Subscriptions[0].Protocol, gocheck.Equals, "email")
	c.Assert(resp.Subscriptions[0].Endpoint, gocheck.Equals, "*****@*****.**")
	c.Assert(resp.Subscriptions[0].SubscriptionArn, gocheck.Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca")
	c.Assert(resp.Subscriptions[0].TopicArn, gocheck.Equals, "arn:aws:sns:us-east-1:698519295917:My-Topic")
	c.Assert(resp.Subscriptions[0].Owner, gocheck.Equals, "123456789012")
	c.Assert(err, gocheck.IsNil)
}
Пример #15
0
func (s *S) TestGetTopicAttributes(c *gocheck.C) {
	testServer.Response(200, nil, TestGetTopicAttributesXmlOK)

	resp, err := s.sns.GetTopicAttributes("arn:aws:sns:us-east-1:123456789012:My-Topic")
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(len(resp.Attributes), gocheck.Not(gocheck.Equals), 0)
	c.Assert(resp.Attributes[0].Key, gocheck.Equals, "Owner")
	c.Assert(resp.Attributes[0].Value, gocheck.Equals, "123456789012")
	c.Assert(resp.Attributes[1].Key, gocheck.Equals, "Policy")
	c.Assert(resp.Attributes[1].Value, gocheck.Equals, `{"Version":"2008-10-17","Id":"us-east-1/698519295917/test__default_policy_ID","Statement" : [{"Effect":"Allow","Sid":"us-east-1/698519295917/test__default_statement_ID","Principal" : {"AWS": "*"},"Action":["SNS:GetTopicAttributes","SNS:SetTopicAttributes","SNS:AddPermission","SNS:RemovePermission","SNS:DeleteTopic","SNS:Subscribe","SNS:ListSubscriptionsByTopic","SNS:Publish","SNS:Receive"],"Resource":"arn:aws:sns:us-east-1:698519295917:test","Condition" : {"StringLike" : {"AWS:SourceArn": "arn:aws:*:*:698519295917:*"}}}]}`)
	c.Assert(resp.ResponseMetadata.RequestId, gocheck.Equals, "057f074c-33a7-11df-9540-99d0768312d3")
	c.Assert(err, gocheck.IsNil)
}
Пример #16
0
func (s *S) TestDelMultiObjects(c *gocheck.C) {
	testServer.Response(200, nil, "")

	b := s.s3.Bucket("bucket")
	objects := []s3.Object{s3.Object{Key: "test"}}
	err := b.DelMulti(s3.Delete{
		Quiet:   false,
		Objects: objects,
	})
	c.Assert(err, gocheck.IsNil)

	req := testServer.WaitRequest()
	c.Assert(req.Method, gocheck.Equals, "POST")
	c.Assert(req.URL.RawQuery, gocheck.Equals, "delete=")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")
	c.Assert(req.Header["Content-MD5"], gocheck.Not(gocheck.Equals), "")
	c.Assert(req.Header["Content-Type"], gocheck.Not(gocheck.Equals), "")
	c.Assert(req.ContentLength, gocheck.Not(gocheck.Equals), "")
}
Пример #17
0
func (s *LocalServerSuite) TestDeregisterInstanceWithLoadBalancer(c *gocheck.C) {
	// there is no need to register the instance first, amazon returns the same response
	// in both cases (instance registered or not)
	srv := s.srv.srv
	instId := srv.NewInstance()
	defer srv.RemoveInstance(instId)
	srv.NewLoadBalancer("testlb")
	defer srv.RemoveLoadBalancer("testlb")
	resp, err := s.clientTests.elb.DeregisterInstancesFromLoadBalancer([]string{instId}, "testlb")
	c.Assert(err, gocheck.IsNil)
	c.Assert(resp.RequestId, gocheck.Not(gocheck.Equals), "")
}
Пример #18
0
func (s *ClientTests) TestCreateAndDeleteLoadBalancer(c *gocheck.C) {
	createLBReq := elb.CreateLoadBalancer{
		Name:              "testlb",
		AvailabilityZones: []string{"us-east-1a"},
		Listeners: []elb.Listener{
			{
				InstancePort:     80,
				InstanceProtocol: "http",
				LoadBalancerPort: 80,
				Protocol:         "http",
			},
		},
	}
	resp, err := s.elb.CreateLoadBalancer(&createLBReq)
	c.Assert(err, gocheck.IsNil)
	defer s.elb.DeleteLoadBalancer(createLBReq.Name)
	c.Assert(resp.DNSName, gocheck.Not(gocheck.Equals), "")
	deleteResp, err := s.elb.DeleteLoadBalancer(createLBReq.Name)
	c.Assert(err, gocheck.IsNil)
	c.Assert(deleteResp.RequestId, gocheck.Not(gocheck.Equals), "")
}
Пример #19
0
func (s *S) TestDelBucket(c *gocheck.C) {
	testServer.Response(204, nil, "")

	b := s.s3.Bucket("bucket")
	err := b.DelBucket()
	c.Assert(err, gocheck.IsNil)

	req := testServer.WaitRequest()
	c.Assert(req.Method, gocheck.Equals, "DELETE")
	c.Assert(req.URL.Path, gocheck.Equals, "/bucket/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")
}
Пример #20
0
func (s *S) TestSetTopicAttributes(c *gocheck.C) {
	testServer.Response(200, nil, TestSetTopicAttributesXmlOK)

	resp, err := s.sns.SetTopicAttributes("DisplayName", "MyTopicName", "arn:aws:sns:us-east-1:123456789012:My-Topic")
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(resp.ResponseMetadata.RequestId, gocheck.Equals, "a8763b99-33a7-11df-a9b7-05d48da6f042")
	c.Assert(err, gocheck.IsNil)
}
Пример #21
0
func (s *S) TestUnsubscribe(c *gocheck.C) {
	testServer.Response(200, nil, TestUnsubscribeXmlOK)

	resp, err := s.sns.Unsubscribe("arn:aws:sns:us-east-1:123456789012:My-Topic:a169c740-3766-11df-8963-01868b7c937a")
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(resp.ResponseMetadata.RequestId, gocheck.Equals, "18e0ac39-3776-11df-84c0-b93cc1666b84")
	c.Assert(err, gocheck.IsNil)
}
Пример #22
0
func (s *S) TestRemovePermission(c *gocheck.C) {
	testServer.Response(200, nil, TestRemovePermissionXmlOK)

	resp, err := s.sns.RemovePermission("NewPermission", "arn:aws:sns:us-east-1:123456789012:My-Topic")
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(resp.RequestId, gocheck.Equals, "d170b150-33a8-11df-995a-2d6fbe836cc1")
	c.Assert(err, gocheck.IsNil)
}
Пример #23
0
func (s *S) TestDeletePlatformApplication(c *gocheck.C) {
	testServer.Response(200, nil, TestDeletePlatformApplicationXmlOK)

	resp, err := s.sns.DeletePlatformApplication("arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp")
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(resp.RequestId, gocheck.Equals, "097dac18-7a77-5823-a8dd-e65476dcb037")

	c.Assert(err, gocheck.IsNil)
}
Пример #24
0
func (s *S) TestDeleteQueue(c *gocheck.C) {
	testServer.PrepareResponse(200, nil, TestDeleteQueueXmlOK)

	q := &Queue{s.sqs, testServer.URL + "/123456789012/testQueue/"}
	resp, err := q.Delete()
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/123456789012/testQueue/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(resp.ResponseMetadata.RequestId, gocheck.Equals, "6fde8d1e-52cd-4581-8cd9-c512f4c64223")
	c.Assert(err, gocheck.IsNil)
}
Пример #25
0
func (s *S) TestSubscribe(c *gocheck.C) {
	testServer.Response(200, nil, TestSubscribeXmlOK)

	resp, err := s.sns.Subscribe("*****@*****.**", "email", "arn:aws:sns:us-east-1:123456789012:My-Topic")
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(resp.SubscriptionArn, gocheck.Equals, "pending confirmation")
	c.Assert(resp.ResponseMetadata.RequestId, gocheck.Equals, "a169c740-3766-11df-8963-01868b7c937a")
	c.Assert(err, gocheck.IsNil)
}
Пример #26
0
func (s *S) TestGet(c *gocheck.C) {
	testServer.Response(200, nil, "content")

	b := s.s3.Bucket("bucket")
	data, err := b.Get("name")

	req := testServer.WaitRequest()
	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/bucket/name")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(err, gocheck.IsNil)
	c.Assert(string(data), gocheck.Equals, "content")
}
Пример #27
0
func (s *S) TestDeleteEndpoint(c *gocheck.C) {
	testServer.Response(200, nil, DeleteEndpointXmlOK)

	resp, err := s.sns.DeleteEndpoint("arn:aws:sns:us-west-2:123456789012:endpoint/GCM%/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3")
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(resp.RequestId, gocheck.Equals, "c1d2b191-353c-5a5f-8969-fbdd3900afa8")

	c.Assert(err, gocheck.IsNil)
}
Пример #28
0
func (s *S) TestDeleteTopic(c *gocheck.C) {
	testServer.Response(200, nil, TestDeleteTopicXmlOK)

	t := sns.Topic{s.sns, "arn:aws:sns:us-east-1:123456789012:My-Topic"}
	resp, err := t.Delete()
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(resp.ResponseMetadata.RequestId, gocheck.Equals, "f3aa9ac9-3c3d-11df-8235-9dab105e9c32")
	c.Assert(err, gocheck.IsNil)
}
Пример #29
0
func (s *S) TestListTopicsOK(c *gocheck.C) {
	testServer.Response(200, nil, TestListTopicsXmlOK)

	resp, err := s.sns.ListTopics(nil)
	req := testServer.WaitRequest()

	c.Assert(req.Method, gocheck.Equals, "GET")
	c.Assert(req.URL.Path, gocheck.Equals, "/")
	c.Assert(req.Header["Date"], gocheck.Not(gocheck.Equals), "")

	c.Assert(resp.Topics[0].SNS, gocheck.Equals, s.sns)
	c.Assert(resp.ResponseMetadata.RequestId, gocheck.Equals, "bd10b26c-e30e-11e0-ba29-93c3aca2f103")
	c.Assert(err, gocheck.IsNil)
}
Пример #30
0
// Cost: 0.02 USD
func (s *ClientTests) TestCreateRegisterAndDeregisterInstanceWithLoadBalancer(c *gocheck.C) {
	createLBReq, instId := s.createInstanceAndLB(c)
	defer func() {
		_, err := s.elb.DeleteLoadBalancer(createLBReq.Name)
		c.Check(err, gocheck.IsNil)
		_, err = s.ec2.TerminateInstances([]string{instId})
		c.Check(err, gocheck.IsNil)
	}()
	resp, err := s.elb.RegisterInstancesWithLoadBalancer([]string{instId}, createLBReq.Name)
	c.Assert(err, gocheck.IsNil)
	c.Assert(resp.InstanceIds, gocheck.DeepEquals, []string{instId})
	resp2, err := s.elb.DeregisterInstancesFromLoadBalancer([]string{instId}, createLBReq.Name)
	c.Assert(err, gocheck.IsNil)
	c.Assert(resp2, gocheck.Not(gocheck.Equals), "")
}