Decode content before checking
Decode before checking for py3 compatibility.
Related-Bug:
MODIFY
heatclient/common/http.py
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:

MODIFY
heatclient/tests/unit/test_common_http.py
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

Decode content before checking

Decode before checking for py3 compatibility.

Change-Id: Ic62ebc385146ab1406dd64384044d92be8171052
Related-Bug: #1695144