mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-28 19:31:39 +00:00
Merge pull request #204 from linuxbox2/wip-post-ctype
Add test case for POST with no Content-Type header
This commit is contained in:
commit
6bef6ad125
1 changed files with 36 additions and 0 deletions
|
@ -1500,6 +1500,42 @@ def test_post_object_authenticated_request():
|
||||||
got = key.get_contents_as_string()
|
got = key.get_contents_as_string()
|
||||||
eq(got, 'bar')
|
eq(got, 'bar')
|
||||||
|
|
||||||
|
@attr(resource='object')
|
||||||
|
@attr(method='post')
|
||||||
|
@attr(operation='authenticated browser based upload via POST request, no content-type header')
|
||||||
|
@attr(assertion='succeeds and returns written data')
|
||||||
|
def test_post_object_authenticated_no_content_type():
|
||||||
|
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": [\
|
||||||
|
{"bucket": bucket.name},\
|
||||||
|
["starts-with", "$key", "foo"],\
|
||||||
|
{"acl": "private"},\
|
||||||
|
["content-length-range", 0, 1024]\
|
||||||
|
]\
|
||||||
|
}
|
||||||
|
|
||||||
|
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),\
|
||||||
|
('file', ('bar'))])
|
||||||
|
|
||||||
|
r = requests.post(url, files = payload)
|
||||||
|
eq(r.status_code, 204)
|
||||||
|
key = bucket.get_key("foo.txt")
|
||||||
|
got = key.get_contents_as_string()
|
||||||
|
eq(got, 'bar')
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
@attr(method='post')
|
@attr(method='post')
|
||||||
@attr(operation='authenticated browser based upload via POST request, bad access key')
|
@attr(operation='authenticated browser based upload via POST request, bad access key')
|
||||||
|
|
Loading…
Reference in a new issue