From ef471ec2b96b40ec267f91493f3042707572ae18 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 1 Aug 2013 13:24:28 -0700 Subject: [PATCH] s3tests: improve cors test to cover more functionality Signed-off-by: Yehuda Sadeh --- s3tests/functional/test_s3.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index 708815c..e858736 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -4260,7 +4260,8 @@ def test_stress_bucket_acls_changes(): def test_set_cors(): bucket = get_new_bucket() 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) eq(e.status, 404) @@ -4268,6 +4269,25 @@ def test_set_cors(): bucket.set_cors(cfg) 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): """ file that simulates seek, tell, and current character