From ec7b94d2ef008b716f4cc3d7c1fc7e8150858eeb Mon Sep 17 00:00:00 2001 From: Dolph Mathews Date: Thu, 13 Dec 2012 10:01:21 -0600 Subject: [PATCH] Render content-type appropriate 404 (bug 1089987) Change-Id: I8d6acdaa7f8220341bca15cc4acba807910f6891 --- keystone/common/wsgi.py | 3 ++- tests/test_content_types.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py index 91f38d09c8..9c133470b1 100644 --- a/keystone/common/wsgi.py +++ b/keystone/common/wsgi.py @@ -415,7 +415,8 @@ class Router(object): """ match = req.environ['wsgiorg.routing_args'][1] if not match: - return webob.exc.HTTPNotFound() + return render_exception( + exception.NotFound('The resource could not be found.')) app = match['controller'] return app diff --git a/tests/test_content_types.py b/tests/test_content_types.py index 30db457596..78086e655e 100644 --- a/tests/test_content_types.py +++ b/tests/test_content_types.py @@ -312,6 +312,18 @@ class CoreApiTests(object): self.assertIsNotNone(tenant.get('id')) self.assertIsNotNone(tenant.get('name')) + def test_public_not_found(self): + r = self.public_request( + path='/%s' % uuid.uuid4().hex, + expected_status=404) + self.assertValidErrorResponse(r) + + def test_admin_not_found(self): + r = self.admin_request( + path='/%s' % uuid.uuid4().hex, + expected_status=404) + self.assertValidErrorResponse(r) + def test_public_multiple_choice(self): r = self.public_request(path='/', expected_status=300) self.assertValidMultipleChoiceResponse(r)