Merge "s3token: Only replace access_key_id in account"

This commit is contained in:
Zuul 2023-02-10 01:21:15 +00:00 committed by Gerrit Code Review
commit d9bf70ae2b
2 changed files with 14 additions and 2 deletions

View File

@ -403,8 +403,8 @@ class S3Token(object):
tenant_to_connect = tenant_to_connect.encode('utf-8')
self._logger.debug('Connecting with tenant: %s', tenant_to_connect)
new_tenant_name = '%s%s' % (self._reseller_prefix, tenant_to_connect)
environ['PATH_INFO'] = environ['PATH_INFO'].replace(account,
new_tenant_name)
environ['PATH_INFO'] = environ['PATH_INFO'].replace(
account, new_tenant_name, 1)
return self._app(environ, start_response)

View File

@ -956,6 +956,18 @@ class S3TokenMiddlewareTestV3(S3TokenMiddlewareTestBase):
self._assert_authorized(req, account_path='/v1/')
self.assertEqual(req.environ['PATH_INFO'], '/v1/AUTH_PROJECT_ID/c/o')
def test_authorize_with_access_key_in_container(self):
req = Request.blank('/v1/accesskey/accesskey.c/o')
req.environ['s3api.auth_details'] = {
'access_key': u'access',
'signature': u'signature',
'string_to_sign': u'token',
}
req.get_response(self.middleware)
self._assert_authorized(req, account_path='/v1/')
self.assertEqual(req.environ['PATH_INFO'],
'/v1/AUTH_PROJECT_ID/accesskey.c/o')
def test_authorize_with_access_key_and_unquote_chars(self):
req = Request.blank('/v1/ab%c=/c/o')
req.environ['s3api.auth_details'] = {