// Communicate with all endpoints to see if they are alive. func (s *ClientTests) TestRegions(c *C) { errs := make(chan error, len(aws.Regions)) for _, region := range aws.Regions { go func(r aws.Region) { s := s3.New(s.s3.Auth, r) b := s.Bucket("goamz-" + s.Auth.AccessKey) _, err := b.Get("non-existent") errs <- err }(region) } for _ = range aws.Regions { err := <-errs if err != nil { s3_err, ok := err.(*s3.Error) if ok { c.Check(s3_err.Code, Matches, "NoSuchBucket") } else if _, ok = err.(*net.DNSError); ok { // Okay as well. } else { c.Errorf("Non-S3 error: %s", err) } } else { c.Errorf("Test should have errored but it seems to have succeeded") } } }
// s3Connection makes a connection to s3 func s3Connection(name string) (*s3.S3, error) { // Make the auth accessKeyId := fs.ConfigFile.MustValue(name, "access_key_id") if accessKeyId == "" { return nil, errors.New("access_key_id not found") } secretAccessKey := fs.ConfigFile.MustValue(name, "secret_access_key") if secretAccessKey == "" { return nil, errors.New("secret_access_key not found") } auth := aws.Auth{AccessKey: accessKeyId, SecretKey: secretAccessKey} // FIXME look through all the regions by name and use one of them if found // Synthesize the region s3Endpoint := fs.ConfigFile.MustValue(name, "endpoint") if s3Endpoint == "" { s3Endpoint = "https://s3.amazonaws.com/" } region := aws.Region{ Name: "s3", S3Endpoint: s3Endpoint, S3LocationConstraint: false, } s3LocationConstraint := fs.ConfigFile.MustValue(name, "location_constraint") if s3LocationConstraint != "" { region.Name = s3LocationConstraint region.S3LocationConstraint = true } c := s3.New(auth, region) c.Client = fs.Config.Client() return c, nil }
func (s *LocalServerSuite) SetUpSuite(c *C) { s.srv.SetUp(c) s.clientTests.s3 = s3.New(s.srv.auth, s.srv.region) // TODO Sadly the fake server ignores auth completely right now. :-( s.clientTests.authIsBroken = true s.clientTests.Cleanup() }
func (s *AmazonClientSuite) SetUpSuite(c *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 *AmazonDomainClientSuite) SetUpSuite(c *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 *S) SetUpSuite(c *C) { testServer.Start() auth := aws.Auth{"abc", "123"} s.s3 = s3.New(auth, aws.Region{Name: "faux-region-1", S3Endpoint: testServer.URL}) }