]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
Anonymously list private and public-read buckets 83/head
authorAndrew Gaul <andrew@gaul.org>
Mon, 12 Oct 2015 22:03:24 +0000 (15:03 -0700)
committerAndrew Gaul <andrew@gaul.org>
Fri, 16 Oct 2015 04:49:43 +0000 (21:49 -0700)
Signed-off-by: Andrew Gaul <andrew@gaul.org>
s3tests/functional/test_s3.py

index 374ca5cfb11c4de17396c87841b79965184fcdef..406e9f999cca21e3bedcee42bbc334f5fe0708c5 100644 (file)
@@ -742,6 +742,41 @@ def test_bucket_list_object_time():
 
     _compare_dates(iso_datetime, http_datetime)
 
+@attr(resource='bucket')
+@attr(method='get')
+@attr(operation='list all objects (anonymous)')
+@attr(assertion='succeeds')
+def test_bucket_list_objects_anonymous():
+    # Get a connection with bad authorization, then change it to be our new Anonymous auth mechanism,
+    # emulating standard HTTP access.
+    #
+    # While it may have been possible to use httplib directly, doing it this way takes care of also
+    # allowing us to vary the calling format in testing.
+    conn = _create_connection_bad_auth()
+    conn._auth_handler = AnonymousAuth.AnonymousAuthHandler(None, None, None) # Doesn't need this
+    bucket = get_new_bucket()
+    bucket.set_acl('public-read')
+    anon_bucket = conn.get_bucket(bucket.name)
+    anon_bucket.get_all_keys()
+
+@attr(resource='bucket')
+@attr(method='get')
+@attr(operation='list all objects (anonymous)')
+@attr(assertion='fails')
+def test_bucket_list_objects_anonymous_fail():
+    # Get a connection with bad authorization, then change it to be our new Anonymous auth mechanism,
+    # emulating standard HTTP access.
+    #
+    # While it may have been possible to use httplib directly, doing it this way takes care of also
+    # allowing us to vary the calling format in testing.
+    conn = _create_connection_bad_auth()
+    conn._auth_handler = AnonymousAuth.AnonymousAuthHandler(None, None, None) # Doesn't need this
+    bucket = get_new_bucket()
+    e = assert_raises(boto.exception.S3ResponseError, conn.get_bucket, bucket.name)
+    eq(e.status, 403)
+    eq(e.reason, 'Forbidden')
+    eq(e.error_code, 'AccessDenied')
+
 
 @attr(resource='bucket')
 @attr(method='get')