예제 #1
0
파일: bucket.go 프로젝트: jacobsa/aws
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)
	}
}
예제 #2
0
파일: tests.go 프로젝트: jacobsa/aws
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)
}
예제 #3
0
파일: tests.go 프로젝트: jacobsa/aws
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")))
}