]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
Improve list bucket invalid and bad auth tests 24/head
authorAndrew Gaul <andrew@gaul.org>
Thu, 4 Dec 2014 04:38:00 +0000 (20:38 -0800)
committerAndrew Gaul <andrew@gaul.org>
Thu, 4 Dec 2014 04:42:23 +0000 (20:42 -0800)
Explicitly test invalid access keys and valid access keys but invalid
secret keys.  Also disable anonymous list bucket test for AWS.
radosgw uses this for connectivity testing but AWS does not allow it:

http://ceph.com/docs/master/radosgw/config/#verify-the-runtime
http://docs.aws.amazon.com/AmazonS3/latest/API/RESTServiceGET.html

s3tests/functional/test_s3.py

index 44db1f191f38cfe5288067fe81546240b8cda8ae..bc5cdebdee2827d35cbc0f6ddddf4795127dad5b 100644 (file)
@@ -3873,12 +3873,12 @@ def test_buckets_create_then_list():
             raise RuntimeError("S3 implementation's GET on Service did not return bucket we created: %r", bucket.name)
 
 # Common code to create a connection object, which'll use bad authorization information
-def _create_connection_bad_auth():
+def _create_connection_bad_auth(aws_access_key_id='badauth'):
     # We're going to need to manually build a connection using bad authorization info.
     # But to save the day, lets just hijack the settings from s3.main. :)
     main = s3.main
     conn = boto.s3.connection.S3Connection(
-        aws_access_key_id='badauth',
+        aws_access_key_id=aws_access_key_id,
         aws_secret_access_key='roflmao',
         is_secure=main.is_secure,
         port=main.port,
@@ -3891,6 +3891,7 @@ def _create_connection_bad_auth():
 @attr(method='get')
 @attr(operation='list all buckets (anonymous)')
 @attr(assertion='succeeds')
+@attr('fails_on_aws')
 def test_list_buckets_anonymous():
     # Get a connection with bad authorization, then change it to be our new Anonymous auth mechanism,
     # emulating standard HTTP access.
@@ -3906,12 +3907,23 @@ def test_list_buckets_anonymous():
 @attr(method='get')
 @attr(operation='list all buckets (bad auth)')
 @attr(assertion='fails 403')
-def test_list_buckets_bad_auth():
+def test_list_buckets_invalid_auth():
     conn = _create_connection_bad_auth()
     e = assert_raises(boto.exception.S3ResponseError, conn.get_all_buckets)
     eq(e.status, 403)
     eq(e.reason, 'Forbidden')
-    eq(e.error_code, 'AccessDenied')
+    eq(e.error_code, 'InvalidAccessKeyId')
+
+@attr(resource='bucket')
+@attr(method='get')
+@attr(operation='list all buckets (bad auth)')
+@attr(assertion='fails 403')
+def test_list_buckets_bad_auth():
+    conn = _create_connection_bad_auth(aws_access_key_id=s3.main.aws_access_key_id)
+    e = assert_raises(boto.exception.S3ResponseError, conn.get_all_buckets)
+    eq(e.status, 403)
+    eq(e.reason, 'Forbidden')
+    eq(e.error_code, 'SignatureDoesNotMatch')
 
 @attr(resource='bucket')
 @attr(method='put')