-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues with GceAssertionCredentials in Python 3 #254
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,12 +34,12 @@ def __init__(self, scopes=None, service_account_name=None): | |
|
||
def __call__(self, request_url): | ||
if request_url.endswith('scopes'): | ||
return six.StringIO(''.join(self._scopes)) | ||
return six.BytesIO(''.join(self._scopes).encode('utf-8')) | ||
elif request_url.endswith('service-accounts'): | ||
return six.StringIO(self._sa) | ||
return six.BytesIO(self._sa.encode('utf-8')) | ||
elif request_url.endswith( | ||
'/service-accounts/%s/token' % self._sa): | ||
return six.StringIO('{"access_token": "token"}') | ||
return six.BytesIO('{"access_token": "token"}'.encode('utf-8')) | ||
self.fail('Unexpected HTTP request to %s' % request_url) | ||
|
||
|
||
|
@@ -132,11 +132,11 @@ def testGetServiceAccount(self): | |
creds = self._GetServiceCreds() | ||
opener = mock.MagicMock() | ||
opener.open = mock.MagicMock() | ||
opener.open.return_value = six.StringIO('default/\nanother') | ||
opener.open.return_value = six.BytesIO(b'default/\nanother') | ||
with mock.patch.object(six.moves.urllib.request, 'build_opener', | ||
return_value=opener, | ||
autospec=True) as build_opener: | ||
creds.GetServiceAccount('default') | ||
creds.GetServiceAccount(b'default') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this might be at fault for the Python 3.5 regression mentioned in this comment. Maybe something like this would help remedy the regression:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Marking this above comment "request changes", sorry I'm still a little new to the github workflow. 🙂 |
||
self.assertEqual(1, build_opener.call_count) | ||
self.assertEqual(1, opener.open.call_count) | ||
req = opener.open.call_args[0][0] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like #271 fixes this Py3 incompatibility, but not the one in _do_refresh_request below.