Register cname_lookup on /info

Change-Id: I4f68b2f84f32e2c9e567c08f7e66ce0a81b7d867
This commit is contained in:
Romain LE DISEZ
2017年02月18日 14:25:33 +01:00
parent 11bd6c82ec
commit e6245d198f

View File

@@ -43,7 +43,8 @@ else: # executed if the try block finishes with no errors
MODULE_DEPENDENCY_MET = True
from swift.common.swob import Request, HTTPBadRequest
from swift.common.utils import cache_from_env, get_logger, list_from_csv
from swift.common.utils import cache_from_env, get_logger, list_from_csv, \
register_swift_info
def lookup_cname(domain): # pragma: no cover
@@ -176,6 +177,9 @@ def filter_factory(global_conf, **local_conf): # pragma: no cover
conf = global_conf.copy()
conf.update(local_conf)
register_swift_info('cname_lookup',
lookup_depth=int(conf.get('lookup_depth', '1')))
def cname_filter(app):
return CNAMELookupMiddleware(app, conf)
return cname_filter

View File

@@ -24,6 +24,7 @@ except ImportError:
skip = True
else: # executed if the try has no errors
skip = False
from swift.common import utils
from swift.common.middleware import cname_lookup
from swift.common.swob import Request
@@ -237,3 +238,21 @@ class TestCNAMELookup(unittest.TestCase):
bad_domain = ['CNAME lookup failed to resolve to a valid domain']
resp = do_test('c.badtest.com')
self.assertEqual(resp, bad_domain)
class TestSwiftInfo(unittest.TestCase):
def setUp(self):
utils._swift_info = {}
utils._swift_admin_info = {}
def test_registered_defaults(self):
cname_lookup.filter_factory({})
swift_info = utils.get_swift_info()
self.assertIn('cname_lookup', swift_info)
self.assertEqual(swift_info['cname_lookup'].get('lookup_depth'), 1)
def test_registered_nondefaults(self):
cname_lookup.filter_factory({'lookup_depth': '2'})
swift_info = utils.get_swift_info()
self.assertIn('cname_lookup', swift_info)
self.assertEqual(swift_info['cname_lookup'].get('lookup_depth'), 2)
Reference in New Issue
openstack/swift
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.

The note is not visible to the blocked user.