mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-25 03:47:22 +00:00
Add test to verify HTTP OPTIONS on presigned URL
Related: https://tracker.ceph.com/issues/62033
Signed-off-by: Tobias Urdin <tobias.urdin@binero.com>
(cherry picked from commit c0a1880d4c
)
This commit is contained in:
parent
e0dea7f74b
commit
5642cf4b7b
1 changed files with 43 additions and 5 deletions
|
@ -3141,13 +3141,14 @@ def test_put_object_ifnonmatch_overwrite_existed_failed():
|
|||
body = _get_body(response)
|
||||
assert body == 'bar'
|
||||
|
||||
def _setup_bucket_object_acl(bucket_acl, object_acl):
|
||||
def _setup_bucket_object_acl(bucket_acl, object_acl, client=None):
|
||||
"""
|
||||
add a foo key, and specified key and bucket acls to
|
||||
a (new or existing) bucket.
|
||||
"""
|
||||
bucket_name = get_new_bucket_name()
|
||||
if client is None:
|
||||
client = get_client()
|
||||
bucket_name = get_new_bucket_name()
|
||||
client.create_bucket(ACL=bucket_acl, Bucket=bucket_name)
|
||||
client.put_object(ACL=object_acl, Bucket=bucket_name, Key='foo')
|
||||
|
||||
|
@ -3320,16 +3321,24 @@ def test_object_raw_authenticated_object_gone():
|
|||
assert status == 404
|
||||
assert error_code == 'NoSuchKey'
|
||||
|
||||
def test_object_raw_get_x_amz_expires_not_expired():
|
||||
bucket_name = _setup_bucket_object_acl('public-read', 'public-read')
|
||||
client = get_client()
|
||||
def _test_object_raw_get_x_amz_expires_not_expired(client):
|
||||
bucket_name = _setup_bucket_object_acl('public-read', 'public-read', client=client)
|
||||
params = {'Bucket': bucket_name, 'Key': 'foo'}
|
||||
|
||||
url = client.generate_presigned_url(ClientMethod='get_object', Params=params, ExpiresIn=100000, HttpMethod='GET')
|
||||
|
||||
res = requests.options(url, verify=get_config_ssl_verify()).__dict__
|
||||
assert res['status_code'] == 400
|
||||
|
||||
res = requests.get(url, verify=get_config_ssl_verify()).__dict__
|
||||
assert res['status_code'] == 200
|
||||
|
||||
def test_object_raw_get_x_amz_expires_not_expired():
|
||||
_test_object_raw_get_x_amz_expires_not_expired(client=get_client())
|
||||
|
||||
def test_object_raw_get_x_amz_expires_not_expired_tenant():
|
||||
_test_object_raw_get_x_amz_expires_not_expired(client=get_tenant_client())
|
||||
|
||||
def test_object_raw_get_x_amz_expires_out_range_zero():
|
||||
bucket_name = _setup_bucket_object_acl('public-read', 'public-read')
|
||||
client = get_client()
|
||||
|
@ -6506,6 +6515,35 @@ def test_cors_header_option():
|
|||
|
||||
_cors_request_and_check(requests.options, obj_url, {'Origin': 'example.origin','Access-Control-Request-Headers':'x-amz-meta-header2','Access-Control-Request-Method':'GET'}, 403, None, None)
|
||||
|
||||
def _test_cors_options_presigned_get_object(client):
|
||||
bucket_name = _setup_bucket_object_acl('public-read', 'public-read', client=client)
|
||||
params = {'Bucket': bucket_name, 'Key': 'foo'}
|
||||
|
||||
url = client.generate_presigned_url(ClientMethod='get_object', Params=params, ExpiresIn=100000, HttpMethod='GET')
|
||||
|
||||
res = requests.options(url, verify=get_config_ssl_verify()).__dict__
|
||||
assert res['status_code'] == 400
|
||||
|
||||
allowed_methods = ['GET']
|
||||
allowed_origins = ['example']
|
||||
|
||||
cors_config ={
|
||||
'CORSRules': [
|
||||
{'AllowedMethods': allowed_methods,
|
||||
'AllowedOrigins': allowed_origins,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
client.put_bucket_cors(Bucket=bucket_name, CORSConfiguration=cors_config)
|
||||
_cors_request_and_check(requests.options, url, {'Origin': 'example', 'Access-Control-Request-Method': 'GET'}, 200, 'example', 'GET')
|
||||
|
||||
def test_cors_presigned_get_object():
|
||||
_test_cors_options_presigned_get_object(client=get_client())
|
||||
|
||||
def test_cors_presigned_get_object_tenant():
|
||||
_test_cors_options_presigned_get_object(client=get_tenant_client())
|
||||
|
||||
@pytest.mark.tagging
|
||||
def test_set_bucket_tagging():
|
||||
bucket_name = get_new_bucket()
|
||||
|
|
Loading…
Reference in a new issue