s3api: Fix get_container_info missing some sysmeta info.
When get_container_info is called and not authenticated, it will make a HEAD subrequest and get info by passing resp.sw_headers to headers_to_container_info. This will lose all sysmeta stored in resp.sysmeta_headers. The patch fixes this by passing all sw_headers and sysmeta_headers to headers_to_container_info. Change-Id: I6e538ed7a748b60bdb9db7e894eaedc9d72559c1 Closes-Bug: #1765679
This commit is contained in:
parent
29b877de71
commit
a4298fb3ab
|
@ -89,6 +89,8 @@ def _header_strip(value):
|
|||
# behave as though it wasn't provided
|
||||
return None
|
||||
return stripped
|
||||
|
||||
|
||||
_header_strip.re = re.compile('^[\x00-\x20]*|[\x00-\x20]*$')
|
||||
|
||||
|
||||
|
@ -1378,8 +1380,10 @@ class S3Request(swob.Request):
|
|||
else:
|
||||
# otherwise we do naive HEAD request with the authentication
|
||||
resp = self.get_response(app, 'HEAD', self.container_name, '')
|
||||
headers = resp.sw_headers.copy()
|
||||
headers.update(resp.sysmeta_headers)
|
||||
return headers_to_container_info(
|
||||
resp.sw_headers, resp.status_int) # pylint: disable-msg=E1101
|
||||
headers, resp.status_int) # pylint: disable-msg=E1101
|
||||
|
||||
def gen_multipart_manifest_delete_query(self, app, obj=None):
|
||||
if not self.allow_multipart_uploads:
|
||||
|
|
|
@ -299,9 +299,14 @@ class TestRequest(S3ApiTestCase):
|
|||
self.assertTrue(sw_req.environ['swift.proxy_access_log_made'])
|
||||
|
||||
def test_get_container_info(self):
|
||||
s3api_acl = '{"Owner":"owner","Grant":'\
|
||||
'[{"Grantee":"owner","Permission":"FULL_CONTROL"}]}'
|
||||
self.swift.register('HEAD', '/v1/AUTH_test/bucket', HTTPNoContent,
|
||||
{'x-container-read': 'foo',
|
||||
'X-container-object-count': 5,
|
||||
'x-container-sysmeta-versions-location':
|
||||
'bucket2',
|
||||
'x-container-sysmeta-s3api-acl': s3api_acl,
|
||||
'X-container-meta-foo': 'bar'}, None)
|
||||
req = Request.blank('/bucket', environ={'REQUEST_METHOD': 'GET'},
|
||||
headers={'Authorization': 'AWS test:tester:hmac',
|
||||
|
@ -313,6 +318,9 @@ class TestRequest(S3ApiTestCase):
|
|||
self.assertEqual(204, info['status']) # sanity
|
||||
self.assertEqual('foo', info['read_acl']) # sanity
|
||||
self.assertEqual('5', info['object_count']) # sanity
|
||||
self.assertEqual(
|
||||
'bucket2', info['sysmeta']['versions-location']) # sanity
|
||||
self.assertEqual(s3api_acl, info['sysmeta']['s3api-acl']) # sanity
|
||||
self.assertEqual({'foo': 'bar'}, info['meta']) # sanity
|
||||
with patch(
|
||||
'swift.common.middleware.s3api.s3request.get_container_info',
|
||||
|
|
Loading…
Reference in New Issue