summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshish Gupta <ashish-kumar.gupta@hp.com>2015-01-27 21:55:39 -0800
committerAshish Kumar Gupta <ashish-kumar.gupta@hp.com>2015-01-28 06:42:51 +0000
commite319a7f4854ca04adafb015660ca7c09c509e3ef (patch)
tree9acd4dfda25dff4376ef9ce61fbc64fd28ad7c7a
parentffd91e2111435268fef7f45af689357925ac453f (diff)
downloadtempest-lib-e319a7f4854ca04adafb015660ca7c09c509e3ef.tar.gz
Separate Forbidden exception from Unauthorized
Closes-Bug:#1415143 Change-Id: I890498b2df6ae8d8f689537c8d6da1b5c06c2bd6
-rw-r--r--tempest_lib/common/rest_client.py5
-rw-r--r--tempest_lib/exceptions.py4
-rw-r--r--tempest_lib/tests/test_rest_client.py2
3 files changed, 9 insertions, 2 deletions
diff --git a/tempest_lib/common/rest_client.py b/tempest_lib/common/rest_client.py
index 683efa5..aa003bd 100644
--- a/tempest_lib/common/rest_client.py
+++ b/tempest_lib/common/rest_client.py
@@ -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)
diff --git a/tempest_lib/exceptions.py b/tempest_lib/exceptions.py
index d97d158..fbf9ee0 100644
--- a/tempest_lib/exceptions.py
+++ b/tempest_lib/exceptions.py
@@ -62,6 +62,10 @@ class Unauthorized(RestClientException):
message = 'Unauthorized'
+class Forbidden(RestClientException):
+ message = "Forbidden"
+
+
class TimeoutException(RestClientException):
message = "Request timed out"
diff --git a/tempest_lib/tests/test_rest_client.py b/tempest_lib/tests/test_rest_client.py
index dc819d0..b48c156 100644
--- a/tempest_lib/tests/test_rest_client.py
+++ b/tempest_lib/tests/test_rest_client.py
@@ -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"))