From 71172ac4bb190496c4ef668c3cba6fa9bf5834aa Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Fri, 23 Mar 2012 09:50:39 -0700 Subject: Send a more appropriate error response for 403 in osapi * Don't use resizeNotAllowed for 403 * Fixes bug 949444 Change-Id: Ib2b5acba291a04e0c0296fa5e8438019983dda20 --- nova/tests/api/openstack/test_faults.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'nova/tests') 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?')) -- cgit