Separate Forbidden exception from Unauthorized
Closes-Bug:#1415143 Change-Id: I890498b2df6ae8d8f689537c8d6da1b5c06c2bd6
This commit is contained in:

committed by
Ashish Kumar Gupta

parent
ffd91e2111
commit
e319a7f485
@@ -423,9 +423,12 @@ class RestClient(object):
|
||||
else:
|
||||
raise exceptions.InvalidContentType(str(resp.status))
|
||||
|
||||
if resp.status == 401 or resp.status == 403:
|
||||
if resp.status == 401:
|
||||
raise exceptions.Unauthorized(resp_body)
|
||||
|
||||
if resp.status == 403:
|
||||
raise exceptions.Forbidden(resp_body)
|
||||
|
||||
if resp.status == 404:
|
||||
raise exceptions.NotFound(resp_body)
|
||||
|
||||
|
@@ -62,6 +62,10 @@ class Unauthorized(RestClientException):
|
||||
message = 'Unauthorized'
|
||||
|
||||
|
||||
class Forbidden(RestClientException):
|
||||
message = "Forbidden"
|
||||
|
||||
|
||||
class TimeoutException(RestClientException):
|
||||
message = "Request timed out"
|
||||
|
||||
|
@@ -315,7 +315,7 @@ class TestRestClientErrorCheckerJSON(base.TestCase):
|
||||
**self.set_data("401"))
|
||||
|
||||
def test_response_403(self):
|
||||
self.assertRaises(exceptions.Unauthorized,
|
||||
self.assertRaises(exceptions.Forbidden,
|
||||
self.rest_client._error_checker,
|
||||
**self.set_data("403"))
|
||||
|
||||
|
Reference in New Issue
Block a user