Skip to content

Commit

Permalink
Merge "Send a more appropriate error response for 403 in osapi" into …
Browse files Browse the repository at this point in the history
…milestone-proposed
  • Loading branch information
Jenkins authored and openstack-gerrit committed Mar 27, 2012
2 parents 6a5055a + 52f3ba8 commit 11644a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nova/api/openstack/wsgi.py
Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions nova/tests/api/openstack/test_faults.py
Expand Up @@ -96,6 +96,19 @@ def raiser(req):
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?'))
Expand Down

0 comments on commit 11644a2

Please sign in to comment.