s3tests: improve cors test to cover more functionality

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
Yehuda Sadeh 2013-08-01 13:24:28 -07:00
parent 7bdf4b897a
commit ef471ec2b9

View file

@ -4260,7 +4260,8 @@ def test_stress_bucket_acls_changes():
def test_set_cors(): def test_set_cors():
bucket = get_new_bucket() bucket = get_new_bucket()
cfg = CORSConfiguration() cfg = CORSConfiguration()
cfg.add_rule('GET', '*') cfg.add_rule('GET', '*.get')
cfg.add_rule('PUT', '*.put')
e = assert_raises(boto.exception.S3ResponseError, bucket.get_cors) e = assert_raises(boto.exception.S3ResponseError, bucket.get_cors)
eq(e.status, 404) eq(e.status, 404)
@ -4268,6 +4269,25 @@ def test_set_cors():
bucket.set_cors(cfg) bucket.set_cors(cfg)
new_cfg = bucket.get_cors() new_cfg = bucket.get_cors()
eq(len(new_cfg), 2)
result = bunch.Bunch()
for c in new_cfg:
eq(len(c.allowed_method), 1)
eq(len(c.allowed_origin), 1)
result[c.allowed_method[0]] = c.allowed_origin[0]
eq(result['GET'], '*.get')
eq(result['PUT'], '*.put')
bucket.delete_cors()
e = assert_raises(boto.exception.S3ResponseError, bucket.get_cors)
eq(e.status, 404)
class FakeFile(object): class FakeFile(object):
""" """
file that simulates seek, tell, and current character file that simulates seek, tell, and current character