summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-03-23 18:58:29 +0000
committerGerrit Code Review <review@openstack.org>2012-03-23 18:58:29 +0000
commit112af23d623cbbd68bf6e09a6e507170c57abe6b (patch)
treec561104876cce24c7270f0a29c21c9883f2cc014
parenta5088664a7e433be15bac6405f361513aeacfe06 (diff)
parent71172ac4bb190496c4ef668c3cba6fa9bf5834aa (diff)
downloadnova-112af23d623cbbd68bf6e09a6e507170c57abe6b.tar.gz
nova-112af23d623cbbd68bf6e09a6e507170c57abe6b.tar.xz
nova-112af23d623cbbd68bf6e09a6e507170c57abe6b.zip
Merge "Send a more appropriate error response for 403 in osapi"
-rw-r--r--nova/api/openstack/wsgi.py2
-rw-r--r--nova/tests/api/openstack/test_faults.py13
2 files changed, 14 insertions, 1 deletions
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
index 26c51d8f4..f65425246 100644
--- a/nova/api/openstack/wsgi.py
+++ b/nova/api/openstack/wsgi.py
@@ -1022,7 +1022,7 @@ class Fault(webob.exc.HTTPException):
_fault_names = {
400: "badRequest",
401: "unauthorized",
- 403: "resizeNotAllowed",
+ 403: "forbidden",
404: "itemNotFound",
405: "badMethod",
409: "conflictingRequest",
diff --git a/nova/tests/api/openstack/test_faults.py b/nova/tests/api/openstack/test_faults.py
index 96a62017b..3eb2bb8dc 100644
--- a/nova/tests/api/openstack/test_faults.py
+++ b/nova/tests/api/openstack/test_faults.py
@@ -96,6 +96,19 @@ class TestFaults(test.TestCase):
self.assertEqual(resp.status_int, 404)
self.assertTrue('whut?' in resp.body)
+ def test_raise_403(self):
+ """Ensure the ability to raise :class:`Fault` in WSGI-ified methods."""
+ @webob.dec.wsgify
+ def raiser(req):
+ raise wsgi.Fault(webob.exc.HTTPForbidden(explanation='whut?'))
+
+ req = webob.Request.blank('/.xml')
+ resp = req.get_response(raiser)
+ self.assertEqual(resp.content_type, "application/xml")
+ self.assertEqual(resp.status_int, 403)
+ self.assertTrue('resizeNotAllowed' not in resp.body)
+ self.assertTrue('forbidden' in resp.body)
+
def test_fault_has_status_int(self):
"""Ensure the status_int is set correctly on faults"""
fault = wsgi.Fault(webob.exc.HTTPBadRequest(explanation='what?'))