summaryrefslogtreecommitdiff
path: root/heatclient
diff options
context:
space:
mode:
authorrabi <ramishra@redhat.com>2017-06-02 10:43:25 +0530
committerrabi <ramishra@redhat.com>2017-07-26 12:02:31 +0530
commit485a679f3e87d5e38a72c4da07f5fb3ecd6597c8 (patch)
tree7d86730cf47ea80bfa52581ee4f87f141bdcf0b6 /heatclient
parentee6ebb5d116c9373c238c3438cc5c08b59136264 (diff)
downloadpython-heatclient-485a679f3e87d5e38a72c4da07f5fb3ecd6597c8.tar.gz
Decode content before checking
Decode before checking for py3 compatibility. Change-Id: Ic62ebc385146ab1406dd64384044d92be8171052 Related-Bug: #1695144
Diffstat (limited to 'heatclient')
-rw-r--r--heatclient/common/http.py4
-rw-r--r--heatclient/tests/unit/test_common_http.py2
2 files changed, 3 insertions, 3 deletions
diff --git a/heatclient/common/http.py b/heatclient/common/http.py
index f5c5021..4b765df 100644
--- a/heatclient/common/http.py
+++ b/heatclient/common/http.py
@@ -221,10 +221,10 @@ class HTTPClient(object):
raise exc.CommunicationError(message=message)
self.log_http_response(resp)
-
+ txt_content = encodeutils.safe_decode(resp.content, 'utf-8')
if not ('X-Auth-Key' in kwargs['headers']) and (
resp.status_code == 401 or
- (resp.status_code == 500 and "(HTTP 401)" in resp.content)):
+ (resp.status_code == 500 and "(HTTP 401)" in txt_content)):
raise exc.HTTPUnauthorized(_("Authentication failed: %s")
% resp.content)
elif 400 <= resp.status_code < 600:
diff --git a/heatclient/tests/unit/test_common_http.py b/heatclient/tests/unit/test_common_http.py
index 8ce6f18..79cb551 100644
--- a/heatclient/tests/unit/test_common_http.py
+++ b/heatclient/tests/unit/test_common_http.py
@@ -132,7 +132,7 @@ class HttpClientTest(testtools.TestCase):
fake500 = fakes.FakeHTTPResponse(
500, 'ERROR',
{'content-type': 'application/octet-stream'},
- '(HTTP 401)')
+ b'(HTTP 401)')
# no token or credentials
mock_request.return_value = fake500