Include the requested URL in authentication errors
There is a catchall handler that doesn't provide helpful output when there is a configuration problem. Closes-Bug: #1641231 Change-Id: I28732a9737001182b867e66088dd13251e2aa03f
This commit is contained in:
parent
8ff15d3e0f
commit
febddb3ea1
|
@ -527,7 +527,8 @@ class Router(object):
|
|||
"""
|
||||
match = req.environ['wsgiorg.routing_args'][1]
|
||||
if not match:
|
||||
msg = _('The resource could not be found.')
|
||||
msg = (_('(%(url)s): The resource could not be found.') %
|
||||
{'url': req.url})
|
||||
return render_exception(exception.NotFound(msg),
|
||||
request=req,
|
||||
user_locale=best_match_language(req))
|
||||
|
|
|
@ -428,6 +428,23 @@ class ExtensionRouterTest(BaseWSGITest):
|
|||
self.assertIn("testkey", app.kwargs)
|
||||
self.assertEqual("test", app.kwargs["testkey"])
|
||||
|
||||
def test_resource_not_found_message(self):
|
||||
class FakeRouter(wsgi.ExtensionRouter):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.kwargs = kwargs
|
||||
|
||||
factory = FakeRouter.factory({}, testkey="test")
|
||||
app = factory(self.app)
|
||||
req = webob.Request.blank('/WHATWHA')
|
||||
# Force the match in the Router to fail so we can verify
|
||||
# that the URL is included in the 404 error message.
|
||||
req.environ['wsgiorg.routing_args'] = [None, None]
|
||||
resp = app._dispatch(req)
|
||||
body = jsonutils.loads(resp.body)
|
||||
self.assertEqual(body['error']['message'],
|
||||
u'(http://localhost/WHATWHA): The resource could '
|
||||
'not be found.')
|
||||
|
||||
|
||||
class MiddlewareTest(BaseWSGITest):
|
||||
def test_middleware_request(self):
|
||||
|
|
Loading…
Reference in New Issue