Merge "py3: port proxy/controllers/info.py"
This commit is contained in:
commit
3378a48733
@ -109,15 +109,14 @@ class GatekeeperMiddleware(object):
|
|||||||
]
|
]
|
||||||
|
|
||||||
response_headers = fixed_response_headers()
|
response_headers = fixed_response_headers()
|
||||||
removed = filter(
|
removed = [(header, value) for header, value in response_headers
|
||||||
lambda h: self.outbound_condition(h[0]),
|
if self.outbound_condition(header)]
|
||||||
response_headers)
|
|
||||||
|
|
||||||
if removed:
|
if removed:
|
||||||
self.logger.debug('removed response headers: %s' % removed)
|
self.logger.debug('removed response headers: %s' % removed)
|
||||||
new_headers = filter(
|
new_headers = [
|
||||||
lambda h: not self.outbound_condition(h[0]),
|
(header, value) for header, value in response_headers
|
||||||
response_headers)
|
if not self.outbound_condition(header)]
|
||||||
return start_response(status, new_headers, exc_info)
|
return start_response(status, new_headers, exc_info)
|
||||||
return start_response(status, response_headers, exc_info)
|
return start_response(status, response_headers, exc_info)
|
||||||
return self.app(env, gatekeeper_response)
|
return self.app(env, gatekeeper_response)
|
||||||
|
@ -103,5 +103,5 @@ class InfoController(Controller):
|
|||||||
|
|
||||||
return HTTPOk(request=req,
|
return HTTPOk(request=req,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
body=info,
|
body=info.encode('ascii'),
|
||||||
content_type='application/json; charset=UTF-8')
|
content_type='application/json; charset=UTF-8')
|
||||||
|
@ -649,11 +649,13 @@ class Application(object):
|
|||||||
kwargs['exc_info'] = sys.exc_info()
|
kwargs['exc_info'] = sys.exc_info()
|
||||||
else:
|
else:
|
||||||
log = self.logger.exception
|
log = self.logger.exception
|
||||||
|
if isinstance(additional_info, bytes):
|
||||||
|
additional_info = additional_info.decode('utf-8')
|
||||||
log(_('ERROR with %(type)s server %(ip)s:%(port)s/%(device)s'
|
log(_('ERROR with %(type)s server %(ip)s:%(port)s/%(device)s'
|
||||||
' re: %(info)s'),
|
' re: %(info)s'),
|
||||||
{'type': typ, 'ip': node['ip'],
|
{'type': typ, 'ip': node['ip'],
|
||||||
'port': node['port'], 'device': node['device'],
|
'port': node['port'], 'device': node['device'],
|
||||||
'info': additional_info.decode('utf-8')},
|
'info': additional_info},
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
def modify_wsgi_pipeline(self, pipe):
|
def modify_wsgi_pipeline(self, pipe):
|
||||||
|
@ -62,7 +62,7 @@ class TestInfoController(unittest.TestCase):
|
|||||||
resp = controller.GET(req)
|
resp = controller.GET(req)
|
||||||
self.assertIsInstance(resp, HTTPException)
|
self.assertIsInstance(resp, HTTPException)
|
||||||
self.assertEqual('200 OK', str(resp))
|
self.assertEqual('200 OK', str(resp))
|
||||||
info = json.loads(resp.body)
|
info = json.loads(resp.body.decode('ascii'))
|
||||||
self.assertNotIn('admin', info)
|
self.assertNotIn('admin', info)
|
||||||
self.assertIn('foo', info)
|
self.assertIn('foo', info)
|
||||||
self.assertIn('bar', info['foo'])
|
self.assertIn('bar', info['foo'])
|
||||||
@ -89,7 +89,7 @@ class TestInfoController(unittest.TestCase):
|
|||||||
resp = controller.GET(req)
|
resp = controller.GET(req)
|
||||||
self.assertIsInstance(resp, HTTPException)
|
self.assertIsInstance(resp, HTTPException)
|
||||||
self.assertEqual('200 OK', str(resp))
|
self.assertEqual('200 OK', str(resp))
|
||||||
info = json.loads(resp.body)
|
info = json.loads(resp.body.decode('ascii'))
|
||||||
self.assertNotIn('admin', info)
|
self.assertNotIn('admin', info)
|
||||||
self.assertIn('foo', info)
|
self.assertIn('foo', info)
|
||||||
self.assertIn('bar', info['foo'])
|
self.assertIn('bar', info['foo'])
|
||||||
@ -120,7 +120,7 @@ class TestInfoController(unittest.TestCase):
|
|||||||
resp = controller.GET(req)
|
resp = controller.GET(req)
|
||||||
self.assertIsInstance(resp, HTTPException)
|
self.assertIsInstance(resp, HTTPException)
|
||||||
self.assertEqual('200 OK', str(resp))
|
self.assertEqual('200 OK', str(resp))
|
||||||
info = json.loads(resp.body)
|
info = json.loads(resp.body.decode('ascii'))
|
||||||
self.assertIn('foo', info)
|
self.assertIn('foo', info)
|
||||||
self.assertIn('bar', info['foo'])
|
self.assertIn('bar', info['foo'])
|
||||||
self.assertEqual(info['foo']['bar'], 'baz')
|
self.assertEqual(info['foo']['bar'], 'baz')
|
||||||
@ -156,7 +156,7 @@ class TestInfoController(unittest.TestCase):
|
|||||||
resp = controller.GET(req)
|
resp = controller.GET(req)
|
||||||
self.assertIsInstance(resp, HTTPException)
|
self.assertIsInstance(resp, HTTPException)
|
||||||
self.assertEqual('200 OK', str(resp))
|
self.assertEqual('200 OK', str(resp))
|
||||||
info = json.loads(resp.body)
|
info = json.loads(resp.body.decode('ascii'))
|
||||||
self.assertIn('admin', info)
|
self.assertIn('admin', info)
|
||||||
self.assertIn('qux', info['admin'])
|
self.assertIn('qux', info['admin'])
|
||||||
self.assertIn('quux', info['admin']['qux'])
|
self.assertIn('quux', info['admin']['qux'])
|
||||||
@ -279,7 +279,7 @@ class TestInfoController(unittest.TestCase):
|
|||||||
resp = controller.GET(req)
|
resp = controller.GET(req)
|
||||||
self.assertIsInstance(resp, HTTPException)
|
self.assertIsInstance(resp, HTTPException)
|
||||||
self.assertEqual('200 OK', str(resp))
|
self.assertEqual('200 OK', str(resp))
|
||||||
info = json.loads(resp.body)
|
info = json.loads(resp.body.decode('ascii'))
|
||||||
self.assertNotIn('foo2', info)
|
self.assertNotIn('foo2', info)
|
||||||
self.assertIn('admin', info)
|
self.assertIn('admin', info)
|
||||||
self.assertIn('disallowed_sections', info['admin'])
|
self.assertIn('disallowed_sections', info['admin'])
|
||||||
|
3
tox.ini
3
tox.ini
@ -54,7 +54,8 @@ commands =
|
|||||||
test/unit/common/test_storage_policy.py \
|
test/unit/common/test_storage_policy.py \
|
||||||
test/unit/common/test_swob.py \
|
test/unit/common/test_swob.py \
|
||||||
test/unit/common/test_utils.py \
|
test/unit/common/test_utils.py \
|
||||||
test/unit/common/test_wsgi.py}
|
test/unit/common/test_wsgi.py \
|
||||||
|
test/unit/proxy/controllers/test_info.py}
|
||||||
|
|
||||||
[testenv:py36]
|
[testenv:py36]
|
||||||
commands = {[testenv:py35]commands}
|
commands = {[testenv:py35]commands}
|
||||||
|
Loading…
Reference in New Issue
Block a user