Beispiel #1
0
func initBucket() {
	var err error

	// Sanity-check flags.
	if *g_bucketName == "" {
		log.Fatalln("You must set the -bucket flag.")
	}

	if *g_region == "" {
		log.Fatalln("You must set the -region flag.")
	}

	if *g_keyId == "" {
		log.Fatalln("You must set the -key_id flag.")
	}

	// Set up the access key.
	prompt := fmt.Sprintf(
		"Enter secret for AWS access key %s: ",
		*g_keyId,
	)

	accessKey := aws.AccessKey{
		Id:     *g_keyId,
		Secret: password.ReadPassword(prompt),
	}

	// Open the bucket.
	g_bucket, err = s3.OpenBucket(*g_bucketName, s3.Region(*g_region), accessKey)
	if err != nil {
		log.Fatalf("OpenBucket:", err)
	}
}
Beispiel #2
0
func (t *BucketTest) SetUp(i *TestInfo) {
	var err error

	// Open a bucket.
	t.bucket, err = s3.OpenBucket(*g_bucketName, s3.Region(*g_region), g_accessKey)
	AssertEq(nil, err)
}
Beispiel #3
0
func (t *BucketTest) WrongAccessKeySecret() {
	// Open a bucket with the wrong key.
	wrongKey := g_accessKey
	wrongKey.Secret += "taco"

	bucket, err := s3.OpenBucket(*g_bucketName, s3.Region(*g_region), wrongKey)
	AssertEq(nil, err)

	// Attempt to do something.
	_, err = bucket.ListKeys("")
	ExpectThat(err, Error(HasSubstr("signature")))
}