summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2012-07-11 14:57:55 -0400
committerDan Prince <dprince@redhat.com>2012-07-12 14:44:26 -0400
commitad9ac0c6dce5b2a8da72bb4860a353aeb0bd09d9 (patch)
treed19a542ed5ed698d601c151ac15c2e4d93f61dff /nova/api
parent31dfb9736cf73df3c0a86d0505bce3e1aae3a8f9 (diff)
downloadnova-ad9ac0c6dce5b2a8da72bb4860a353aeb0bd09d9.tar.gz
nova-ad9ac0c6dce5b2a8da72bb4860a353aeb0bd09d9.tar.xz
nova-ad9ac0c6dce5b2a8da72bb4860a353aeb0bd09d9.zip
Raise HTTP 500 if service catalog is not json.
Updates the Nova API auth middleware so that it returns a HTTP 500 error if invalid JSON is found. Adds a unit test. Change-Id: I236ced13bac2164e103060e78845a410ceb6cdd4
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/auth.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/nova/api/auth.py b/nova/api/auth.py
index 5191189f2..a118b271e 100644
--- a/nova/api/auth.py
+++ b/nova/api/auth.py
@@ -99,7 +99,12 @@ class NovaKeystoneContext(wsgi.Middleware):
service_catalog = None
if req.headers.get('X_SERVICE_CATALOG') is not None:
- service_catalog = json.loads(req.headers.get('X_SERVICE_CATALOG'))
+ try:
+ catalog_header = req.headers.get('X_SERVICE_CATALOG')
+ service_catalog = json.loads(catalog_header)
+ except ValueError:
+ raise webob.exc.HTTPInternalServerError(
+ _('Invalid service catalog json.'))
ctx = context.RequestContext(user_id,
project_id,