Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: tools/telemetry/third_party/gsutilz/third_party/apitools/apitools/base/py/credentials_lib_test.py

Issue 1376593003: Roll gsutil version to 4.15. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/third_party/gsutilz/third_party/apitools/apitools/base/py/credentials_lib_test.py
diff --git a/tools/telemetry/third_party/gsutilz/third_party/apitools/apitools/base/py/credentials_lib_test.py b/tools/telemetry/third_party/gsutilz/third_party/apitools/apitools/base/py/credentials_lib_test.py
index cf4e5df3ec147fbe6d334710bc1c435c676ba976..067b874618fc2bffc947486a06cf5dda3dad3d96 100644
--- a/tools/telemetry/third_party/gsutilz/third_party/apitools/apitools/base/py/credentials_lib_test.py
+++ b/tools/telemetry/third_party/gsutilz/third_party/apitools/apitools/base/py/credentials_lib_test.py
@@ -26,16 +26,15 @@ def CreateUriValidator(uri_regexp, content=''):
class CredentialsLibTest(unittest2.TestCase):
def _GetServiceCreds(self, service_account_name=None, scopes=None):
- scopes = scopes or ['scope1']
kwargs = {}
if service_account_name is not None:
kwargs['service_account_name'] = service_account_name
service_account_name = service_account_name or 'default'
- def MockMetadataCalls(request):
- request_url = request.get_full_url()
+ def MockMetadataCalls(request_url):
+ default_scopes = scopes or ['scope1']
if request_url.endswith('scopes'):
- return six.StringIO(''.join(scopes))
+ return six.StringIO(''.join(default_scopes))
elif request_url.endswith('service-accounts'):
return six.StringIO(service_account_name)
elif request_url.endswith(
@@ -43,7 +42,7 @@ class CredentialsLibTest(unittest2.TestCase):
return six.StringIO('{"access_token": "token"}')
self.fail('Unexpected HTTP request to %s' % request_url)
- with mock.patch.object(credentials_lib, '_OpenNoProxy',
+ with mock.patch.object(credentials_lib, '_GceMetadataRequest',
side_effect=MockMetadataCalls,
autospec=True) as opener_mock:
with mock.patch.object(util, 'DetectGce',
@@ -58,8 +57,11 @@ class CredentialsLibTest(unittest2.TestCase):
self.assertEqual(3, opener_mock.call_count)
def testGceServiceAccounts(self):
+ scopes = ['scope1']
self._GetServiceCreds()
- self._GetServiceCreds(service_account_name='my_service_account')
+ self._GetServiceCreds(scopes=scopes)
+ self._GetServiceCreds(service_account_name='my_service_account',
+ scopes=scopes)
class TestGetRunFlowFlags(unittest2.TestCase):

Powered by Google App Engine
This is Rietveld 408576698