]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
add a test for post object with empty conditions wip-17635 132/head
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 20 Oct 2016 19:21:46 +0000 (12:21 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 20 Oct 2016 19:21:46 +0000 (12:21 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
s3tests/functional/test_s3.py

index d03c9f67b2ae76284152c397eafba6fcd0e8a5af..5cdb1e7aedacf8e4907f292c6769a36c9d9a5605 100644 (file)
@@ -2287,6 +2287,37 @@ def test_post_object_upload_size_below_minimum():
        r = requests.post(url, files = payload)
        eq(r.status_code, 400)
 
+@attr(resource='object')
+@attr(method='post')
+@attr(operation='authenticated browser based upload via POST request')
+@attr(assertion='empty conditions return appropriate error response')
+def test_post_object_empty_conditions():
+       bucket = get_new_bucket()
+
+       url = _get_post_url(s3.main, bucket)
+
+       utc = pytz.utc
+       expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000)
+
+       policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\
+       "conditions": [\
+        { }\
+       ]\
+       }
+
+       json_policy_document = json.JSONEncoder().encode(policy_document)
+       policy = base64.b64encode(json_policy_document)
+       conn = s3.main
+       signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest())
+
+       payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\
+       ("acl" , "private"),("signature" , signature),("policy" , policy),\
+       ("Content-Type" , "text/plain"),('file', ('bar'))])
+
+       r = requests.post(url, files = payload)
+       eq(r.status_code, 400)
+
+
 
 @attr(resource='object')
 @attr(method='get')