Return 404 on unknown tenants

These aren't exceptional, so don't log them as such.

Change-Id: I5eb9b0ff2732fb55d21ea066f1b896507b5dba1f
This commit is contained in:
Clint Byrum 2017-08-17 09:54:08 -07:00
parent 9ed33e2345
commit 4c3776047c
2 changed files with 9 additions and 0 deletions

View File

@ -110,3 +110,10 @@ class TestWebapp(ZuulTestCase):
self.webapp.unregister_path('/custom')
self.assertRaises(urllib.error.HTTPError, urllib.request.urlopen, req)
def test_webapp_404_on_unknown_tenant(self):
req = urllib.request.Request(
"http://localhost:{}/non-tenant/status.json".format(self.port))
e = self.assertRaises(
urllib.error.HTTPError, urllib.request.urlopen, req)
self.assertEqual(404, e.code)

View File

@ -153,6 +153,8 @@ class WebApp(threading.Thread):
return webob.Response(body=self.cache[tenant_name],
content_type='application/json',
charset='utf8')
if tenant_name not in self.scheduler.abide.tenants:
raise webob.exc.HTTPNotFound()
return self._response_with_status_cache(func, tenant_name)
def change(self, path, tenant_name, request):