From c82649b6353893770af8cd453af38d61dfd1e363 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Thu, 31 Jul 2014 01:27:57 -0700 Subject: [PATCH] test_bucket_create_exists should fail on recreate AWS S3 has two behaviors for recreating a bucket depending if you use the us-standard or another region: >>> bucket = conn.create_bucket('gaul-default', location=Location.DEFAULT) >>> bucket = conn.create_bucket('gaul-default', location=Location.DEFAULT) >>> bucket = conn.create_bucket('gaul-uswest', location=Location.USWest) >>> bucket = conn.create_bucket('gaul-uswest', location=Location.USWest) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/dist-packages/boto/s3/connection.py", line 499, in create_bucket response.status, response.reason, body) boto.exception.S3CreateError: S3CreateError: 409 Conflict BucketAlreadyOwnedByYouYour previous request to create the named bucket succeeded and you already own it.gaul-uswest24B6DC3170365CD7hUynMTyqc9WZFxAJ2RFK6P7BqmmeHHlMl9xL2NOy56xBUnOZCAlHqGvtMeGeAfVs Additional discussion: https://issues.apache.org/jira/browse/JCLOUDS-334 --- s3tests/functional/test_s3.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index 44db1f1..e0aca9b 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -2628,11 +2628,15 @@ def test_bucket_create_naming_dns_dash_dot(): @attr(resource='bucket') @attr(method='put') @attr(operation='re-create') -@attr(assertion='idempotent success') +@attr(assertion='fails 409') def test_bucket_create_exists(): + # aws-s3 default region allows recreation of buckets + # but all other regions fail with BucketAlreadyOwnedByYou. bucket = get_new_bucket(targets.main.default) - # REST idempotency means this should be a nop - get_new_bucket(targets.main.default, bucket.name) + e = assert_raises(boto.exception.S3CreateError, get_new_bucket, targets.main.default, bucket.name) + eq(e.status, 409) + eq(e.reason, 'Conflict') + eq(e.error_code, 'BucketAlreadyOwnedByYou') @attr(resource='bucket')