Ejemplo n.º 1
0
func (s *NiftyClientSuite) SetUpSuite(c *C) {
	if !testutil.Nifty {
		c.Skip("NiftyClientSuite tests not enabled")
	}
	s.srv.SetUp(c)
	s.compute = compute.NewWithClient(s.srv.auth, niftycloud.JPEast, testutil.DefaultClient)
}
Ejemplo n.º 2
0
// Communicate with all NIFTY Cloud endpoints to see if they are alive.
func (s *ClientTests) TestRegions(c *C) {
	name := sessionName("goamz-region-test")
	perms := []compute.IPPerm{{
		Protocol:  "tcp",
		FromPort:  80,
		ToPort:    80,
		SourceIPs: []string{"127.0.0.1/32"},
	}}
	errs := make(chan error, len(allRegions))
	for _, region := range allRegions {
		go func(r niftycloud.Region) {
			e := compute.NewWithClient(s.compute.Auth, r, testutil.DefaultClient)
			_, err := e.AuthorizeSecurityGroup(compute.SecurityGroup{Name: name}, perms)
			errs <- err
		}(region)
	}
	for _ = range allRegions {
		err := <-errs
		if err != nil {
			compute_err, ok := err.(*compute.Error)
			if ok {
				c.Check(compute_err.Code, Matches, "InvalidGroup.NotFound")
			} else {
				c.Errorf("Non-Compute error: %s", err)
			}
		} else {
			c.Errorf("Test should have errored but it seems to have succeeded")
		}
	}
}
Ejemplo n.º 3
0
func (s *S) SetUpSuite(c *C) {
	testServer.Start()
	auth := niftycloud.Auth{AccessKey: "abc", SecretKey: "123"}
	s.compute = compute.NewWithClient(
		auth,
		niftycloud.Region{ComputeEndpoint: testServer.URL},
		testutil.DefaultClient,
	)
}
Ejemplo n.º 4
0
func (s *S) TestSignatureWithEndpointPath(c *C) {
	compute.FakeTime(true)
	defer compute.FakeTime(false)

	testServer.Response(200, nil, RebootInstancesExample)

	options := compute.RebootInstancesOptions{
		InstanceIds: []string{
			"9145d31f",
		},
	}

	// https://bugs.launchpad.net/goamz/+bug/1022749
	compute := compute.NewWithClient(s.compute.Auth, niftycloud.Region{ComputeEndpoint: testServer.URL + "/services/Cloud"}, testutil.DefaultClient)

	_, err := compute.RebootInstances(&options)
	c.Assert(err, IsNil)

	req := testServer.WaitRequest()
	c.Assert(req.Form["Signature"], DeepEquals, []string{"dBRWHVHQ27fB8Zv8JsnkAf8gyT0ARQyCfeYKKuHjxP0="})
}
Ejemplo n.º 5
0
func (s *LocalServerSuite) SetUpSuite(c *C) {
	s.srv.SetUp(c)
	s.ServerTests.compute = compute.NewWithClient(s.srv.auth, s.srv.region, testutil.DefaultClient)
	s.clientTests.compute = compute.NewWithClient(s.srv.auth, s.srv.region, testutil.DefaultClient)
}