| Index: third_party/gsutil/boto/tests/s3/test_connection.py
|
| diff --git a/third_party/gsutil/20110627/boto/tests/s3/test_connection.py b/third_party/gsutil/boto/tests/s3/test_connection.py
|
| similarity index 86%
|
| rename from third_party/gsutil/20110627/boto/tests/s3/test_connection.py
|
| rename to third_party/gsutil/boto/tests/s3/test_connection.py
|
| index 4c209bdd489d0d48935cbee4da19d5f00e8d676a..e9d372e5f5aadfd0055172b5c12d922fb164caf9 100644
|
| --- a/third_party/gsutil/20110627/boto/tests/s3/test_connection.py
|
| +++ b/third_party/gsutil/boto/tests/s3/test_connection.py
|
| @@ -29,7 +29,8 @@ import time
|
| import os
|
| import urllib
|
| from boto.s3.connection import S3Connection
|
| -from boto.exception import S3PermissionsError
|
| +from boto.s3.bucket import Bucket
|
| +from boto.exception import S3PermissionsError, S3ResponseError
|
|
|
| class S3ConnectionTest (unittest.TestCase):
|
|
|
| @@ -69,6 +70,8 @@ class S3ConnectionTest (unittest.TestCase):
|
| assert s1 == file.read(), 'invalid URL %s' % url
|
| url = k.generate_url(3600, force_http=True, headers={'x-amz-x-token' : 'XYZ'})
|
| file = urllib.urlopen(url)
|
| + rh = {'response-content-disposition': 'attachment; filename="foo.txt"'}
|
| + url = k.generate_url(60, response_headers=rh)
|
| assert s1 == file.read(), 'invalid URL %s' % url
|
| bucket.delete_key(k)
|
| # test a few variations on get_all_keys - first load some data
|
| @@ -187,3 +190,31 @@ class S3ConnectionTest (unittest.TestCase):
|
| time.sleep(5)
|
| c.delete_bucket(bucket)
|
| print '--- tests completed ---'
|
| +
|
| + def test_basic_anon(self):
|
| + auth_con = S3Connection()
|
| + # create a new, empty bucket
|
| + bucket_name = 'test-%d' % int(time.time())
|
| + auth_bucket = auth_con.create_bucket(bucket_name)
|
| +
|
| + # try read the bucket anonymously
|
| + anon_con = S3Connection(anon=True)
|
| + anon_bucket = Bucket(anon_con, bucket_name)
|
| + try:
|
| + iter(anon_bucket.list()).next()
|
| + self.fail("anon bucket list should fail")
|
| + except S3ResponseError:
|
| + pass
|
| +
|
| + # give bucket anon user access and anon read again
|
| + auth_bucket.set_acl('public-read')
|
| + try:
|
| + iter(anon_bucket.list()).next()
|
| + self.fail("not expecting contents")
|
| + except S3ResponseError:
|
| + self.fail("we should have public-read access.")
|
| + except StopIteration:
|
| + pass
|
| +
|
| + # cleanup
|
| + auth_con.delete_bucket(auth_bucket)
|
|
|