Skip to content
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

remove unnecessary gce serviceaccounts assertion #289

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that GetInstanceScopes handles a service account that doesn't exist correctly.

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