mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-25 03:47:22 +00:00
s3tests: fix post tests
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
parent
92a60df56d
commit
c170c327a4
1 changed files with 12 additions and 66 deletions
|
@ -1052,7 +1052,7 @@ def test_post_object_anonymous_request():
|
||||||
("Content-Type" , "text/plain"),('file', ('bar'))])
|
("Content-Type" , "text/plain"),('file', ('bar'))])
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 200)
|
eq(r.status_code, 204)
|
||||||
key = bucket.get_key("foo.txt")
|
key = bucket.get_key("foo.txt")
|
||||||
got = key.get_contents_as_string()
|
got = key.get_contents_as_string()
|
||||||
eq(got, 'bar')
|
eq(got, 'bar')
|
||||||
|
@ -1212,8 +1212,6 @@ def test_post_object_set_key_from_filename():
|
||||||
policy = base64.b64encode(json_policy_document)
|
policy = base64.b64encode(json_policy_document)
|
||||||
signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest())
|
signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest())
|
||||||
|
|
||||||
foo_string = 'foo' * 1024*1024
|
|
||||||
|
|
||||||
payload = OrderedDict([ ("key" , "${filename}"),("AWSAccessKeyId" , conn.aws_access_key_id),\
|
payload = OrderedDict([ ("key" , "${filename}"),("AWSAccessKeyId" , conn.aws_access_key_id),\
|
||||||
("acl" , "private"),("signature" , signature),("policy" , policy),\
|
("acl" , "private"),("signature" , signature),("policy" , policy),\
|
||||||
("Content-Type" , "text/plain"),('file', ('foo.txt', 'bar'))])
|
("Content-Type" , "text/plain"),('file', ('foo.txt', 'bar'))])
|
||||||
|
@ -1222,7 +1220,7 @@ def test_post_object_set_key_from_filename():
|
||||||
eq(r.status_code, 204)
|
eq(r.status_code, 204)
|
||||||
key = bucket.get_key("foo.txt")
|
key = bucket.get_key("foo.txt")
|
||||||
got = key.get_contents_as_string()
|
got = key.get_contents_as_string()
|
||||||
eq(got, foo_string)
|
eq(got, 'bar')
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1345,12 +1343,17 @@ def test_post_object_escaped_field_values():
|
||||||
@attr(assertion='succeeds and returns redirect url')
|
@attr(assertion='succeeds and returns redirect url')
|
||||||
def test_post_object_success_redirect_action():
|
def test_post_object_success_redirect_action():
|
||||||
bucket = get_new_bucket()
|
bucket = get_new_bucket()
|
||||||
|
|
||||||
conn = s3.main
|
conn = s3.main
|
||||||
host_name = conn.host
|
host_name = conn.host
|
||||||
|
|
||||||
url = '{protocol}://{host}/{bucket}'.format(protocol= 'https' if conn.is_secure else 'http',\
|
url = '{protocol}://{host}/{bucket}'.format(protocol= 'https' if conn.is_secure else 'http',\
|
||||||
host=host_name,bucket=bucket.name)
|
host=host_name,bucket=bucket.name)
|
||||||
|
|
||||||
|
redirect_url = '{protocol}://{host}/{bucket}'.format(protocol= 'https' if conn.is_secure else 'http',\
|
||||||
|
host=host_name,bucket=bucket.name)
|
||||||
|
bucket.set_acl('public-read')
|
||||||
|
|
||||||
utc = pytz.utc
|
utc = pytz.utc
|
||||||
expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000)
|
expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000)
|
||||||
|
|
||||||
|
@ -1360,7 +1363,7 @@ def test_post_object_success_redirect_action():
|
||||||
["starts-with", "$key", "foo"],\
|
["starts-with", "$key", "foo"],\
|
||||||
{"acl": "private"},\
|
{"acl": "private"},\
|
||||||
["starts-with", "$Content-Type", "text/plain"],\
|
["starts-with", "$Content-Type", "text/plain"],\
|
||||||
["$eq", "$success_action_redirect", "http://localhost"],\
|
["eq", "$success_action_redirect", redirect_url],\
|
||||||
["content-length-range", 0, 1024]\
|
["content-length-range", 0, 1024]\
|
||||||
]\
|
]\
|
||||||
}
|
}
|
||||||
|
@ -1371,7 +1374,7 @@ def test_post_object_success_redirect_action():
|
||||||
|
|
||||||
payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\
|
payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\
|
||||||
("acl" , "private"),("signature" , signature),("policy" , policy),\
|
("acl" , "private"),("signature" , signature),("policy" , policy),\
|
||||||
("Content-Type" , "text/plain"),("success_action_redirect" , "http://localhost"),\
|
("Content-Type" , "text/plain"),("success_action_redirect" , redirect_url),\
|
||||||
('file', ('bar'))])
|
('file', ('bar'))])
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
|
@ -1379,8 +1382,8 @@ def test_post_object_success_redirect_action():
|
||||||
url = r.url
|
url = r.url
|
||||||
key = bucket.get_key("foo.txt")
|
key = bucket.get_key("foo.txt")
|
||||||
eq(url,
|
eq(url,
|
||||||
'http://localhost/?bucket={bucket}&key={key}&etag=%22{etag}%22'.format(bucket = bucket.name,
|
'{rurl}?bucket={bucket}&key={key}&etag=%22{etag}%22'.format(rurl = redirect_url, bucket = bucket.name,
|
||||||
key = key.name, etag = key.etag.strip('"')))
|
key = key.name, etag = key.etag.strip('"')))
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1418,10 +1421,6 @@ def test_post_object_invalid_signature():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 403)
|
eq(r.status_code, 403)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'The request signature we calculated does not match the\
|
|
||||||
signature you provided. Check your key and signing method.')
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1459,9 +1458,6 @@ def test_post_object_invalid_access_key():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 403)
|
eq(r.status_code, 403)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'The AWS Access Key Id you provided does not exist in our records.')
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1499,10 +1495,6 @@ def test_post_object_invalid_date_format():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 400)
|
eq(r.status_code, 400)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text,\
|
|
||||||
"Invalid Policy: Invalid 'expiration' value: '{date}'".format(date=str(expires)))
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1523,7 +1515,6 @@ def test_post_object_no_key_specified():
|
||||||
policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\
|
policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\
|
||||||
"conditions": [\
|
"conditions": [\
|
||||||
{"bucket": bucket.name},\
|
{"bucket": bucket.name},\
|
||||||
["starts-with", "$key", "\$foo"],\
|
|
||||||
{"acl": "private"},\
|
{"acl": "private"},\
|
||||||
["starts-with", "$Content-Type", "text/plain"],\
|
["starts-with", "$Content-Type", "text/plain"],\
|
||||||
["content-length-range", 0, 1024]\
|
["content-length-range", 0, 1024]\
|
||||||
|
@ -1534,16 +1525,12 @@ def test_post_object_no_key_specified():
|
||||||
policy = base64.b64encode(json_policy_document)
|
policy = base64.b64encode(json_policy_document)
|
||||||
signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest())
|
signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest())
|
||||||
|
|
||||||
payload = OrderedDict([ ("key" , "\$foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\
|
payload = OrderedDict([ ("AWSAccessKeyId" , conn.aws_access_key_id),\
|
||||||
("acl" , "private"),("signature" , signature),("policy" , policy),\
|
("acl" , "private"),("signature" , signature),("policy" , policy),\
|
||||||
("Content-Type" , "text/plain"),('file', ('bar'))])
|
("Content-Type" , "text/plain"),('file', ('bar'))])
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 400)
|
eq(r.status_code, 400)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, "Bucket POST must contain a field named 'key'.\
|
|
||||||
If it is specified, please check the order of the fields.")
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1581,10 +1568,6 @@ def test_post_object_missing_signature():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 400)
|
eq(r.status_code, 400)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq("Bucket POST must contain a field named 'Signature'.\
|
|
||||||
If it is specified, please check the order of the fields.")
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1621,9 +1604,6 @@ def test_post_object_missing_policy_condition():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 403)
|
eq(r.status_code, 403)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'Invalid according to Policy: Extra input fields: bucket')
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1702,9 +1682,6 @@ def test_post_object_request_missing_policy_specified_field():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 403)
|
eq(r.status_code, 403)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'Invalid according to Policy: Policy Condition failed: ["starts-with", "$x-amz-meta-foo", "bar"]')
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1742,9 +1719,6 @@ def test_post_object_condition_is_case_sensitive():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 400)
|
eq(r.status_code, 400)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, "Invalid Policy: Invalid 'conditions' value: must be a List.")
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1782,9 +1756,6 @@ def test_post_object_expires_is_case_sensitive():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 400)
|
eq(r.status_code, 400)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, "Invalid Policy: Invalid 'expiration' value: must be a String.")
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1822,9 +1793,6 @@ def test_post_object_expired_policy():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 403)
|
eq(r.status_code, 403)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'Invalid according to Policy: Policy expired.')
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1863,10 +1831,6 @@ def test_post_object_invalid_request_field_value():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 403)
|
eq(r.status_code, 403)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'Invalid according to Policy: Policy Condition failed:\
|
|
||||||
["eq", "$x-amz-meta-foo", ""]')
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1904,9 +1868,6 @@ def test_post_object_missing_expires_condition():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 400)
|
eq(r.status_code, 400)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'Invalid Policy: Policy missing expiration.')
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1937,9 +1898,6 @@ def test_post_object_missing_conditions_list():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 400)
|
eq(r.status_code, 400)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'Invalid Policy: Policy missing conditions.')
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -1977,9 +1935,6 @@ def test_post_object_upload_size_limit_exceeded():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 400)
|
eq(r.status_code, 400)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'Your proposed upload exceeds the maximum allowed size')
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -2017,9 +1972,6 @@ def test_post_object_missing_content_length_argument():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 400)
|
eq(r.status_code, 400)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'Invalid Policy: Invalid content-length-range: wrong number of arguments.')
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -2057,9 +2009,6 @@ def test_post_object_invalid_content_length_argument():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 400)
|
eq(r.status_code, 400)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'Invalid Policy: Invalid JSON.')
|
|
||||||
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
|
@ -2097,9 +2046,6 @@ def test_post_object_upload_size_below_minimum():
|
||||||
|
|
||||||
r = requests.post(url, files = payload)
|
r = requests.post(url, files = payload)
|
||||||
eq(r.status_code, 400)
|
eq(r.status_code, 400)
|
||||||
message = ET.fromstring(r.content).find('Message')
|
|
||||||
message_text = message.text
|
|
||||||
eq(message_text, 'Your proposed upload is smaller than the minimum allowed size')
|
|
||||||
|
|
||||||
|
|
||||||
def _setup_request(bucket_acl=None, object_acl=None):
|
def _setup_request(bucket_acl=None, object_acl=None):
|
||||||
|
|
Loading…
Reference in a new issue