Update redirect checks for x-amz-website-redirect-location

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
This commit is contained in:
Robin H. Johnson 2015-06-21 05:06:26 +00:00 committed by Robin H. Johnson
parent c1f7ad54ce
commit 5d158567fd

View file

@ -625,9 +625,11 @@ def test_websute_xredirect_nonwebsite():
k = bucket.new_key('page') k = bucket.new_key('page')
content = 'wrong-content' content = 'wrong-content'
headers = {'x-amz-website-redirect-location': '/relative'} redirect_dest = '/relative'
k.set_contents_from_string(content, headers=headers) headers = {'x-amz-website-redirect-location': redirect_dest}
k.make_public() k.set_contents_from_string(content, headers=headers, policy='public-read')
redirect = k.get_redirect()
ok(k.get_redirect(), redirect_dest)
res = _website_request(bucket.name, '/page') res = _website_request(bucket.name, '/page')
# RGW returns "302 Found" per RFC2616 # RGW returns "302 Found" per RFC2616
@ -654,15 +656,17 @@ def test_websute_xredirect_relative():
k = bucket.new_key('page') k = bucket.new_key('page')
content = 'wrong-content' content = 'wrong-content'
headers = {'x-amz-website-redirect-location': '/relative'} redirect_dest = '/relative'
k.set_contents_from_string(content, headers=headers) headers = {'x-amz-website-redirect-location': redirect_dest}
k.make_public() k.set_contents_from_string(content, headers=headers, policy='public-read')
redirect = k.get_redirect()
ok(k.get_redirect(), redirect_dest)
res = _website_request(bucket.name, '/page') res = _website_request(bucket.name, '/page')
# RGW returns "302 Found" per RFC2616 # RGW returns "302 Found" per RFC2616
# S3 returns 302 Moved Temporarily per RFC1945 # S3 returns 302 Moved Temporarily per RFC1945
new_url = get_website_url(bucket_name=bucket.name, path='/relative') new_url = get_website_url(bucket_name=bucket.name, path=redirect_dest)
_website_expected_redirect_response(res, 302, ['Found', 'Moved Temporarily'], new_url) _website_expected_redirect_response(res, 301, ['Moved Permanently'], new_url)
k.delete() k.delete()
bucket.delete() bucket.delete()
@ -680,15 +684,17 @@ def test_websute_xredirect_abs():
k = bucket.new_key('page') k = bucket.new_key('page')
content = 'wrong-content' content = 'wrong-content'
headers = {'x-amz-website-redirect-location': 'http://example.com/foo'} redirect_dest = 'http://example.com/foo'
k.set_contents_from_string(content, headers=headers) headers = {'x-amz-website-redirect-location': redirect_dest}
k.make_public() k.set_contents_from_string(content, headers=headers, policy='public-read')
redirect = k.get_redirect()
ok(k.get_redirect(), redirect_dest)
res = _website_request(bucket.name, '/page') res = _website_request(bucket.name, '/page')
# RGW returns "302 Found" per RFC2616 # RGW returns "302 Found" per RFC2616
# S3 returns 302 Moved Temporarily per RFC1945 # S3 returns 302 Moved Temporarily per RFC1945
new_url = get_website_url(proto='http', hostname='example.com', path='/foo') new_url = get_website_url(proto='http', hostname='example.com', path='/foo')
_website_expected_redirect_response(res, 302, ['Found', 'Moved Temporarily'], new_url) _website_expected_redirect_response(res, 301, ['Moved Permanently'], new_url)
k.delete() k.delete()
bucket.delete() bucket.delete()