Change exception type from HTTPBadRequest to HTTPForbidden
When user without admin permission wants to get a list of servers which are in 'deleted' state, currently it raises HTTPBadRequest. This should be changed to HTTPForbidden exception. Change-Id: I29da5f055c69e8aba66ffb068a3601ae69b2fc94 Closes-Bug: #1281904
This commit is contained in:
@@ -233,7 +233,7 @@ class ServersController(wsgi.Controller):
|
||||
search_opts['deleted'] = True
|
||||
else:
|
||||
msg = _("Only administrators may list deleted instances")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
raise exc.HTTPForbidden(explanation=msg)
|
||||
|
||||
# If tenant_id is passed as a search parameter this should
|
||||
# imply that all_tenants is also enabled unless explicitly
|
||||
|
||||
@@ -560,7 +560,7 @@ class Controller(wsgi.Controller):
|
||||
search_opts['deleted'] = True
|
||||
else:
|
||||
msg = _("Only administrators may list deleted instances")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
raise exc.HTTPForbidden(explanation=msg)
|
||||
|
||||
# If all tenants is passed with 0 or false as the value
|
||||
# then remove it from the search options. Nothing passed as
|
||||
|
||||
@@ -1003,7 +1003,7 @@ class ServersControllerTest(ControllerTest):
|
||||
def test_get_servers_deleted_status_as_user(self):
|
||||
req = fakes.HTTPRequestV3.blank('/servers?status=deleted',
|
||||
use_admin_context=False)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.assertRaises(webob.exc.HTTPForbidden,
|
||||
self.controller.detail, req)
|
||||
|
||||
def test_get_servers_deleted_status_as_admin(self):
|
||||
|
||||
@@ -923,7 +923,7 @@ class ServersControllerTest(ControllerTest):
|
||||
def test_get_servers_deleted_status_as_user(self):
|
||||
req = fakes.HTTPRequest.blank('/fake/servers?status=deleted',
|
||||
use_admin_context=False)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.assertRaises(webob.exc.HTTPForbidden,
|
||||
self.controller.detail, req)
|
||||
|
||||
def test_get_servers_deleted_status_as_admin(self):
|
||||
|
||||
Reference in New Issue
Block a user