mirror of
https://github.com/certbot/certbot.git
synced 2026-06-09 00:32:12 -04:00
Return str rather than bytes (#5585)
* Return str rather than bytes Project id is returned as bytes, which causes issues when constructing the google cloud API url, converting `b'PROJECT_ID'` to `b%27PROJECT_ID%27` causing the request to fail. * Ensure we handle both bytes and str types * project_id should be a str or bytes, not int
This commit is contained in:
parent
f3b23662f1
commit
c3659c300b
2 changed files with 10 additions and 3 deletions
|
|
@ -224,4 +224,7 @@ class _GoogleClient(object):
|
|||
if r.status != 200:
|
||||
raise ValueError("Invalid status code: {0}".format(r))
|
||||
|
||||
return content
|
||||
if isinstance(content, bytes):
|
||||
return content.decode()
|
||||
else:
|
||||
return content
|
||||
|
|
|
|||
|
|
@ -223,9 +223,13 @@ class GoogleClientTest(unittest.TestCase):
|
|||
response = DummyResponse()
|
||||
response.status = 200
|
||||
|
||||
with mock.patch('httplib2.Http.request', return_value=(response, 1234)):
|
||||
with mock.patch('httplib2.Http.request', return_value=(response, 'test-test-1')):
|
||||
project_id = _GoogleClient.get_project_id()
|
||||
self.assertEqual(project_id, 1234)
|
||||
self.assertEqual(project_id, 'test-test-1')
|
||||
|
||||
with mock.patch('httplib2.Http.request', return_value=(response, b'test-test-1')):
|
||||
project_id = _GoogleClient.get_project_id()
|
||||
self.assertEqual(project_id, 'test-test-1')
|
||||
|
||||
failed_response = DummyResponse()
|
||||
failed_response.status = 404
|
||||
|
|
|
|||
Loading…
Reference in a new issue