Skip to content

Commit

Permalink
remove unnecessary gce serviceaccounts assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
zshihang committed Feb 15, 2020
1 parent 9659f28 commit 27b6e22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 0 additions & 4 deletions apitools/base/py/credentials_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,6 @@ def _ScopesFromMetadataServer(self, scopes):
if not util.DetectGce():
raise exceptions.ResourceUnavailableError(
'GCE credentials requested outside a GCE instance')
if not self.GetServiceAccount(self.__service_account_name):
raise exceptions.ResourceUnavailableError(
'GCE credentials requested but service account '
'%s does not exist.' % self.__service_account_name)
if scopes:
scope_ls = util.NormalizeScopes(scopes)
instance_scopes = self.GetInstanceScopes()
Expand Down
6 changes: 3 additions & 3 deletions apitools/base/py/credentials_lib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _GetServiceCreds(self, service_account_name=None, scopes=None):
credentials = self._RunGceAssertionCredentials(
service_account_name=service_account_name,
scopes=scopes)
self.assertEqual(3, opener_mock.call_count)
self.assertEqual(2, opener_mock.call_count)
return credentials

def testGceServiceAccounts(self):
Expand Down Expand Up @@ -119,10 +119,10 @@ def testGceServiceAccountsCached(self, mock_detect):
finally:
shutil.rmtree(tempd)
self.assertEqual(creds1.client_id, creds2.client_id)
self.assertEqual(pre_cache_call_count, 3)
self.assertEqual(pre_cache_call_count, 2)
# Caching obviates the need for extra metadata server requests.
# Only one metadata request is made if the cache is hit.
self.assertEqual(opener_mock.call_count, 4)
self.assertEqual(opener_mock.call_count, 3)

def testGetServiceAccount(self):
# We'd also like to test the metadata calls, which requires
Expand Down

0 comments on commit 27b6e22

Please sign in to comment.