summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Young <sleepsonthefloor@gmail.com>2012-03-23 09:50:39 -0700
committerAnthony Young <sleepsonthefloor@gmail.com>2012-03-23 10:13:46 -0700
commit71172ac4bb190496c4ef668c3cba6fa9bf5834aa (patch)
treed4b89942227f59815ed8c7515d25d0eec7feb003
parent5c5a5fbaa03f1864b434bed47796b7b745a24442 (diff)
Send a more appropriate error response for 403 in osapi
* Don't use resizeNotAllowed for 403 * Fixes bug 949444 Change-Id: Ib2b5acba291a04e0c0296fa5e8438019983dda20
-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?'))