Merge "Filter X-Auth-Token in catch_errors"
This commit is contained in:
commit
9891ec95da
@ -37,6 +37,8 @@ class CatchErrors(base.ConfigurableMiddleware):
|
|||||||
try:
|
try:
|
||||||
response = req.get_response(self.application)
|
response = req.get_response(self.application)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
if hasattr(req, 'environ') and 'HTTP_X_AUTH_TOKEN' in req.environ:
|
||||||
|
req.environ['HTTP_X_AUTH_TOKEN'] = '*****'
|
||||||
LOG.exception(_LE('An error occurred during '
|
LOG.exception(_LE('An error occurred during '
|
||||||
'processing the request: %s'), req)
|
'processing the request: %s'), req)
|
||||||
response = webob.exc.HTTPInternalServerError()
|
response = webob.exc.HTTPInternalServerError()
|
||||||
|
@ -26,6 +26,7 @@ class CatchErrorsTest(test_base.BaseTestCase):
|
|||||||
def _test_has_request_id(self, application, expected_code=None):
|
def _test_has_request_id(self, application, expected_code=None):
|
||||||
app = catch_errors.CatchErrors(application)
|
app = catch_errors.CatchErrors(application)
|
||||||
req = webob.Request.blank('/test')
|
req = webob.Request.blank('/test')
|
||||||
|
req.environ['HTTP_X_AUTH_TOKEN'] = 'hello=world'
|
||||||
res = req.get_response(app)
|
res = req.get_response(app)
|
||||||
self.assertEqual(expected_code, res.status_int)
|
self.assertEqual(expected_code, res.status_int)
|
||||||
|
|
||||||
@ -45,3 +46,5 @@ class CatchErrorsTest(test_base.BaseTestCase):
|
|||||||
self._test_has_request_id(application,
|
self._test_has_request_id(application,
|
||||||
webob.exc.HTTPInternalServerError.code)
|
webob.exc.HTTPInternalServerError.code)
|
||||||
self.assertEqual(1, log_exc.call_count)
|
self.assertEqual(1, log_exc.call_count)
|
||||||
|
req_log = log_exc.call_args[0][1]
|
||||||
|
self.assertIn('X-Auth-Token: *****', str(req_log))
|
||||||
|
Loading…
Reference in New Issue
Block a user