add domain_remap to /info
Also added the value of default_reseller_prefix to /info. I did not add the reseller_prefixes value to /info because deployers may not want to expose all of the resellers that are available. Change-Id: I9ca2f002dc395913bb646390d6908dfb8f554df1
This commit is contained in:
parent
26af0aee3e
commit
e87a74695e
@ -51,6 +51,7 @@ sync destinations.
|
||||
"""
|
||||
|
||||
from swift.common.swob import Request, HTTPBadRequest
|
||||
from swift.common.utils import list_from_csv, register_swift_info
|
||||
|
||||
|
||||
class DomainRemapMiddleware(object):
|
||||
@ -71,8 +72,7 @@ class DomainRemapMiddleware(object):
|
||||
self.storage_domain = '.' + self.storage_domain
|
||||
self.path_root = conf.get('path_root', 'v1').strip('/')
|
||||
prefixes = conf.get('reseller_prefixes', 'AUTH')
|
||||
self.reseller_prefixes = [x.strip() for x in prefixes.split(',')
|
||||
if x.strip()]
|
||||
self.reseller_prefixes = list_from_csv(prefixes)
|
||||
self.reseller_prefixes_lower = [x.lower()
|
||||
for x in self.reseller_prefixes]
|
||||
self.default_reseller_prefix = conf.get('default_reseller_prefix')
|
||||
@ -136,6 +136,10 @@ def filter_factory(global_conf, **local_conf):
|
||||
conf = global_conf.copy()
|
||||
conf.update(local_conf)
|
||||
|
||||
register_swift_info(
|
||||
'domain_remap',
|
||||
default_reseller_prefix=conf.get('default_reseller_prefix'))
|
||||
|
||||
def domain_filter(app):
|
||||
return DomainRemapMiddleware(app, conf)
|
||||
return domain_filter
|
||||
|
@ -17,6 +17,7 @@ import unittest
|
||||
|
||||
from swift.common.swob import Request
|
||||
from swift.common.middleware import domain_remap
|
||||
from swift.common import utils
|
||||
|
||||
|
||||
class FakeApp(object):
|
||||
@ -155,5 +156,26 @@ class TestDomainRemap(unittest.TestCase):
|
||||
self.assertEquals(resp, '/v1/AUTH_uuid/test')
|
||||
|
||||
|
||||
class TestSwiftInfo(unittest.TestCase):
|
||||
def setUp(self):
|
||||
utils._swift_info = {}
|
||||
utils._swift_admin_info = {}
|
||||
|
||||
def test_registered_defaults(self):
|
||||
domain_remap.filter_factory({})
|
||||
swift_info = utils.get_swift_info()
|
||||
self.assertTrue('domain_remap' in swift_info)
|
||||
self.assertTrue(
|
||||
swift_info['domain_remap'].get('default_reseller_prefix') is None)
|
||||
|
||||
def test_registered_nondefaults(self):
|
||||
domain_remap.filter_factory({'default_reseller_prefix': 'cupcake'})
|
||||
swift_info = utils.get_swift_info()
|
||||
self.assertTrue('domain_remap' in swift_info)
|
||||
self.assertEquals(
|
||||
swift_info['domain_remap'].get('default_reseller_prefix'),
|
||||
'cupcake')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user