Merge "Fix SLO delete for accounts with non-ASCII names."

This commit is contained in:
Zuul 2018-05-24 22:10:24 +00:00 committed by Gerrit Code Review
commit e8ab5c5012
2 changed files with 42 additions and 2 deletions

View File

@ -1367,8 +1367,8 @@ class StaticLargeObject(object):
'%s MultipartDELETE' % new_env.get('HTTP_USER_AGENT') '%s MultipartDELETE' % new_env.get('HTTP_USER_AGENT')
new_env['swift.source'] = 'SLO' new_env['swift.source'] = 'SLO'
new_env['PATH_INFO'] = ( new_env['PATH_INFO'] = (
'/%s/%s/%s' % (vrs, account, obj_name.lstrip('/')) '/%s/%s/%s' % (vrs, account, obj_name.lstrip('/').encode('utf-8'))
).encode('utf-8') )
resp = Request.blank('', new_env).get_response(self.app) resp = Request.blank('', new_env).get_response(self.app)
if resp.is_success: if resp.is_success:

View File

@ -1038,6 +1038,12 @@ class TestSloDeleteManifest(SloTestCase):
'X-Static-Large-Object': 'true'}, 'X-Static-Large-Object': 'true'},
json.dumps([{'name': '/deltest/b_2', 'hash': 'a', 'bytes': '1'}, json.dumps([{'name': '/deltest/b_2', 'hash': 'a', 'bytes': '1'},
{'name': '/deltest/c_3', 'hash': 'b', 'bytes': '2'}])) {'name': '/deltest/c_3', 'hash': 'b', 'bytes': '2'}]))
self.app.register(
'GET', '/v1/AUTH_test-un\xc3\xafcode/deltest/man-all-there',
swob.HTTPOk, {'Content-Type': 'application/json',
'X-Static-Large-Object': 'true'},
json.dumps([{'name': '/deltest/b_2', 'hash': 'a', 'bytes': '1'},
{'name': '/deltest/c_3', 'hash': 'b', 'bytes': '2'}]))
self.app.register( self.app.register(
'DELETE', '/v1/AUTH_test/deltest/man-all-there', 'DELETE', '/v1/AUTH_test/deltest/man-all-there',
swob.HTTPNoContent, {}, None) swob.HTTPNoContent, {}, None)
@ -1059,6 +1065,15 @@ class TestSloDeleteManifest(SloTestCase):
self.app.register( self.app.register(
'DELETE', '/v1/AUTH_test/deltest/d_3', 'DELETE', '/v1/AUTH_test/deltest/d_3',
swob.HTTPNoContent, {}, None) swob.HTTPNoContent, {}, None)
self.app.register(
'DELETE', '/v1/AUTH_test-un\xc3\xafcode/deltest/man-all-there',
swob.HTTPNoContent, {}, None)
self.app.register(
'DELETE', '/v1/AUTH_test-un\xc3\xafcode/deltest/b_2',
swob.HTTPNoContent, {}, None)
self.app.register(
'DELETE', '/v1/AUTH_test-un\xc3\xafcode/deltest/c_3',
swob.HTTPNoContent, {}, None)
self.app.register( self.app.register(
'GET', '/v1/AUTH_test/deltest/manifest-with-submanifest', 'GET', '/v1/AUTH_test/deltest/manifest-with-submanifest',
@ -1190,6 +1205,31 @@ class TestSloDeleteManifest(SloTestCase):
('DELETE', ('/v1/AUTH_test/deltest/' + ('DELETE', ('/v1/AUTH_test/deltest/' +
'man-all-there?multipart-manifest=delete'))])) 'man-all-there?multipart-manifest=delete'))]))
def test_handle_multipart_delete_non_ascii(self):
acct = u'AUTH_test-un\u00efcode'.encode('utf-8')
req = Request.blank(
'/v1/%s/deltest/man-all-there?multipart-manifest=delete' % acct,
environ={'REQUEST_METHOD': 'DELETE'})
status, _, body = self.call_slo(req)
self.assertEqual('200 OK', status)
lines = body.split('\n')
for l in lines:
parts = l.split(':')
if len(parts) == 1:
continue
key, value = parts
if key == 'Response Status':
delete_status = int(value.split()[0])
self.assertEqual(200, delete_status)
self.assertEqual(set(self.app.calls), set([
('GET',
'/v1/%s/deltest/man-all-there?multipart-manifest=get' % acct),
('DELETE', '/v1/%s/deltest/b_2?multipart-manifest=delete' % acct),
('DELETE', '/v1/%s/deltest/c_3?multipart-manifest=delete' % acct),
('DELETE', ('/v1/%s/deltest/'
'man-all-there?multipart-manifest=delete' % acct))]))
def test_handle_multipart_delete_nested(self): def test_handle_multipart_delete_nested(self):
req = Request.blank( req = Request.blank(
'/v1/AUTH_test/deltest/manifest-with-submanifest?' + '/v1/AUTH_test/deltest/manifest-with-submanifest?' +