mirror of
https://github.com/ceph/s3-tests.git
synced 2024-12-23 23:25:28 +00:00
Merge pull request #132 from ceph/wip-17635
add a test for post object with empty conditions
This commit is contained in:
commit
26b505a12d
1 changed files with 31 additions and 0 deletions
|
@ -2326,6 +2326,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')
|
||||
|
|
Loading…
Reference in a new issue