Merge pull request #192 from joke-lee/cors_option_header_check

rgw: test cors option request with Access-Control-Request-Headers

Reviewed-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
Casey Bodley 2018-04-23 09:01:53 -04:00 committed by GitHub
commit 24ab8ecf07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5968,6 +5968,29 @@ def test_cors_origin_wildcard():
_cors_request_and_check(requests.get, url, {'Origin': 'example.origin'}, 200, '*', 'GET') _cors_request_and_check(requests.get, url, {'Origin': 'example.origin'}, 200, '*', 'GET')
@attr(resource='bucket')
@attr(method='get')
@attr(operation='check cors response when Access-Control-Request-Headers is set in option request')
@attr(assertion='returning cors header')
def test_cors_header_option():
cfg = CORSConfiguration()
bucket = get_new_bucket()
bucket.set_acl('public-read')
cfg.add_rule('GET', '*',allowed_header="x-amz-meta-header1")
e = assert_raises(boto.exception.S3ResponseError, bucket.get_cors)
eq(e.status, 404)
bucket.set_cors(cfg)
time.sleep(3)
url = _get_post_url(s3.main, bucket)
obj_url = '{u}/{o}'.format(u=url, o='bar')
_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)
class FakeFile(object): class FakeFile(object):
""" """
file that simulates seek, tell, and current character file that simulates seek, tell, and current character