]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
add test case: test set policy with condition operator end with IfExists 167/head
authoryuliyang <yuliyang@cmss.chinamobile.com>
Wed, 14 Jun 2017 02:57:30 +0000 (10:57 +0800)
committeryuliyang <yuliyang@cmss.chinamobile.com>
Fri, 7 Jul 2017 23:27:04 +0000 (07:27 +0800)
Signed-off-by: yuliyang <yuliyang@cmss.chinamobile.com>
s3tests/functional/test_s3.py

index 0f4cf3860b911fbd0a6f850bc69b2e3c85b1900f..7abfe7ab668031d5a61bfdc38fc6489c8e2fc389 100644 (file)
@@ -8733,3 +8733,38 @@ def test_bucket_policy_another_bucket():
 
     b2 = new_conn.get_bucket(bucket2.name)
     b2.get_all_keys()
+
+@attr(resource='bucket')
+@attr(method='put')
+@attr(operation='Test put condition operator end with ifExists')
+@attr('policy')
+def test_bucket_policy_set_condition_operator_end_with_IfExists():
+    bucket = _create_keys(keys=['foo'])
+    policy = '''{
+      "Version":"2012-10-17",
+      "Statement": [{
+        "Sid": "Allow Public Access to All Objects",
+        "Effect": "Allow",
+        "Principal": "*",
+        "Action": "s3:GetObject",
+        "Condition": {
+                    "StringLikeIfExists": {
+                        "aws:Referer": "http://www.example.com/*"
+                    }
+                },
+        "Resource": "arn:aws:s3:::%s/*"
+      }
+     ]
+    }''' % bucket.name
+    eq(bucket.set_policy(policy), True)
+    res = _make_request('GET', bucket.name, bucket.get_key("foo"),
+                        request_headers={'referer': 'http://www.example.com/'})
+    eq(res.status, 200)
+    res = _make_request('GET', bucket.name, bucket.get_key("foo"),
+                        request_headers={'referer': 'http://www.example.com/index.html'})
+    eq(res.status, 200)
+    res = _make_request('GET', bucket.name, bucket.get_key("foo"))
+    eq(res.status, 200)
+    res = _make_request('GET', bucket.name, bucket.get_key("foo"),
+                        request_headers={'referer': 'http://example.com'})
+    eq(res.status, 403)