forked from TrueCloudLab/s3-tests
Whitespace cleanup.
This commit is contained in:
parent
79d54ac071
commit
19ac38791c
1 changed files with 67 additions and 67 deletions
132
test_s3.py
132
test_s3.py
|
@ -308,7 +308,7 @@ def test_bucket_create_naming_bad_short_two():
|
||||||
check_bad_bucket_name('aa')
|
check_bad_bucket_name('aa')
|
||||||
|
|
||||||
def test_bucket_create_naming_good_short_3():
|
def test_bucket_create_naming_good_short_3():
|
||||||
check_good_bucket_name('aaa')
|
check_good_bucket_name('aaa')
|
||||||
|
|
||||||
def test_bucket_create_naming_bad_long():
|
def test_bucket_create_naming_bad_long():
|
||||||
check_bad_bucket_name(256*'a')
|
check_bad_bucket_name(256*'a')
|
||||||
|
@ -786,88 +786,88 @@ def test_object_giveaway():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_buckets_create_then_list():
|
def test_buckets_create_then_list():
|
||||||
create_buckets = [get_new_bucket() for i in xrange(5)]
|
create_buckets = [get_new_bucket() for i in xrange(5)]
|
||||||
list_buckets = s3.main.get_all_buckets()
|
list_buckets = s3.main.get_all_buckets()
|
||||||
names = frozenset(bucket.name for bucket in list_buckets)
|
names = frozenset(bucket.name for bucket in list_buckets)
|
||||||
for bucket in create_buckets:
|
for bucket in create_buckets:
|
||||||
if bucket.name not in names:
|
if bucket.name not in names:
|
||||||
raise RuntimeError("S3 implementation's GET on Service did not return bucket we created: %r", bucket.name)
|
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
|
# Common code to create a connection object, which'll use bad authorization information
|
||||||
def _create_connection_bad_auth():
|
def _create_connection_bad_auth():
|
||||||
# We're going to need to manually build a connection using bad authorization info.
|
# 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. :)
|
# But to save the day, lets just hijack the settings from s3.main. :)
|
||||||
main = s3.main
|
main = s3.main
|
||||||
conn = boto.s3.connection.S3Connection(
|
conn = boto.s3.connection.S3Connection(
|
||||||
aws_access_key_id='badauth',
|
aws_access_key_id='badauth',
|
||||||
aws_secret_access_key='roflmao',
|
aws_secret_access_key='roflmao',
|
||||||
is_secure=main.is_secure,
|
is_secure=main.is_secure,
|
||||||
port=main.port,
|
port=main.port,
|
||||||
host=main.host,
|
host=main.host,
|
||||||
calling_format=main.calling_format,
|
calling_format=main.calling_format,
|
||||||
)
|
)
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
def test_list_buckets_anonymous():
|
def test_list_buckets_anonymous():
|
||||||
# Get a connection with bad authorization, then change it to be our new Anonymous auth mechanism,
|
# Get a connection with bad authorization, then change it to be our new Anonymous auth mechanism,
|
||||||
# emulating standard HTTP access.
|
# emulating standard HTTP access.
|
||||||
#
|
#
|
||||||
# While it may have been possible to use httplib directly, doing it this way takes care of also
|
# 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.
|
# allowing us to vary the calling format in testing.
|
||||||
conn = _create_connection_bad_auth()
|
conn = _create_connection_bad_auth()
|
||||||
conn._auth_handler = AnonymousAuth.AnonymousAuthHandler(None, None, None) # Doesn't need this
|
conn._auth_handler = AnonymousAuth.AnonymousAuthHandler(None, None, None) # Doesn't need this
|
||||||
buckets = conn.get_all_buckets()
|
buckets = conn.get_all_buckets()
|
||||||
eq(len(buckets), 0)
|
eq(len(buckets), 0)
|
||||||
|
|
||||||
def test_list_buckets_bad_auth():
|
def test_list_buckets_bad_auth():
|
||||||
conn = _create_connection_bad_auth()
|
conn = _create_connection_bad_auth()
|
||||||
e = assert_raises(boto.exception.S3ResponseError, conn.get_all_buckets)
|
e = assert_raises(boto.exception.S3ResponseError, conn.get_all_buckets)
|
||||||
eq(e.status, 403)
|
eq(e.status, 403)
|
||||||
eq(e.reason, 'Forbidden')
|
eq(e.reason, 'Forbidden')
|
||||||
eq(e.error_code, 'AccessDenied')
|
eq(e.error_code, 'AccessDenied')
|
||||||
|
|
||||||
def test_bucket_create_naming_good_contains_period():
|
def test_bucket_create_naming_good_contains_period():
|
||||||
check_good_bucket_name('aaa.111')
|
check_good_bucket_name('aaa.111')
|
||||||
|
|
||||||
def test_bucket_create_naming_good_contains_hyphen():
|
def test_bucket_create_naming_good_contains_hyphen():
|
||||||
check_good_bucket_name('aaa-111')
|
check_good_bucket_name('aaa-111')
|
||||||
|
|
||||||
def test_bucket_delete_notexist():
|
def test_bucket_delete_notexist():
|
||||||
name = '{prefix}{num}'.format(
|
name = '{prefix}{num}'.format(
|
||||||
prefix=prefix,
|
prefix=prefix,
|
||||||
num=next(bucket_counter),
|
num=next(bucket_counter),
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
bucket = s3.main.delete_bucket(name)
|
bucket = s3.main.delete_bucket(name)
|
||||||
raise RuntimeError("S3 implementation allowed us to delete a bucket that shouldn't exist")
|
raise RuntimeError("S3 implementation allowed us to delete a bucket that shouldn't exist")
|
||||||
except boto.exception.S3ResponseError, e:
|
except boto.exception.S3ResponseError, e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_object_write_to_nonexist_bucket():
|
def test_object_write_to_nonexist_bucket():
|
||||||
name = '{prefix}{num}'.format(
|
name = '{prefix}{num}'.format(
|
||||||
prefix=prefix,
|
prefix=prefix,
|
||||||
num=next(bucket_counter),
|
num=next(bucket_counter),
|
||||||
)
|
)
|
||||||
bucket = s3.main.get_bucket(name, validate=False)
|
bucket = s3.main.get_bucket(name, validate=False)
|
||||||
key = bucket.new_key('foo123bar')
|
key = bucket.new_key('foo123bar')
|
||||||
try:
|
try:
|
||||||
key.set_contents_from_string('foo')
|
key.set_contents_from_string('foo')
|
||||||
raise RuntimeError("S3 implementation allowed us to write a key to a bucket that shouldn't exist")
|
raise RuntimeError("S3 implementation allowed us to write a key to a bucket that shouldn't exist")
|
||||||
except boto.exception.S3ResponseError, e:
|
except boto.exception.S3ResponseError, e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_object_copy_same_bucket():
|
def test_object_copy_same_bucket():
|
||||||
bucket = get_new_bucket()
|
bucket = get_new_bucket()
|
||||||
key = bucket.new_key('foo123bar')
|
key = bucket.new_key('foo123bar')
|
||||||
key.set_contents_from_string('foo')
|
key.set_contents_from_string('foo')
|
||||||
key.copy(bucket, 'bar321foo')
|
key.copy(bucket, 'bar321foo')
|
||||||
key2 = bucket.get_key('bar321foo')
|
key2 = bucket.get_key('bar321foo')
|
||||||
eq(key2.get_contents_as_string(), 'foo')
|
eq(key2.get_contents_as_string(), 'foo')
|
||||||
|
|
||||||
def test_object_copy_diff_bucket():
|
def test_object_copy_diff_bucket():
|
||||||
buckets = [get_new_bucket(), get_new_bucket()]
|
buckets = [get_new_bucket(), get_new_bucket()]
|
||||||
key = buckets[0].new_key('foo123bar')
|
key = buckets[0].new_key('foo123bar')
|
||||||
key.set_contents_from_string('foo')
|
key.set_contents_from_string('foo')
|
||||||
key.copy(buckets[1], 'bar321foo')
|
key.copy(buckets[1], 'bar321foo')
|
||||||
key2 = buckets[1].get_key('bar321foo')
|
key2 = buckets[1].get_key('bar321foo')
|
||||||
eq(key2.get_contents_as_string(), 'foo')
|
eq(key2.get_contents_as_string(), 'foo')
|
||||||
|
|
Loading…
Reference in a new issue