s3token: Add an underscore to the end of reseller_prefix if not present

This matches the behavior of tempauth/keystoneauth with regard to reseller_prefix.

Change-Id: I10f8bc354d0f45dd692915de86857679e9ca3446
This commit is contained in:
Tim Burke 2018-11-09 15:00:02 -08:00
parent d016693875
commit 9b694a3324
2 changed files with 12 additions and 2 deletions

View File

@ -67,7 +67,7 @@ from six.moves import urllib
from swift.common.swob import Request, HTTPBadRequest, HTTPUnauthorized, \
HTTPException
from swift.common.utils import config_true_value, split_path, get_logger, \
cache_from_env
cache_from_env, append_underscore
from swift.common.wsgi import ConfigFileError
@ -149,7 +149,8 @@ class S3Token(object):
self._timeout = float(conf.get('http_timeout', '10.0'))
if not (0 < self._timeout <= 60):
raise ValueError('http_timeout must be between 0 and 60 seconds')
self._reseller_prefix = conf.get('reseller_prefix', 'AUTH_')
self._reseller_prefix = append_underscore(
conf.get('reseller_prefix', 'AUTH'))
self._delay_auth_decision = config_true_value(
conf.get('delay_auth_decision'))

View File

@ -372,6 +372,15 @@ class S3TokenMiddlewareTestGood(S3TokenMiddlewareTestBase):
middleware = s3token.filter_factory(config)(self.app)
self.assertIs('false_ind', middleware._verify)
def test_reseller_prefix(self):
def do_test(conf, expected):
conf.update(self.conf)
middleware = s3token.filter_factory(conf)(self.app)
self.assertEqual(expected, middleware._reseller_prefix)
do_test({}, 'AUTH_')
do_test({'reseller_prefix': 'KEY_'}, 'KEY_')
do_test({'reseller_prefix': 'KEY'}, 'KEY_')
def test_auth_uris(self):
for conf, expected in [
({'auth_uri': 'https://example.com/v2.0'},