@@ -99,18 +99,7 @@ def test_default_state(self):
9999 )
100100 @mock .patch ("google.auth.compute_engine._metadata.get" , autospec = True )
101101 def test_refresh_success (self , get , utcnow ):
102- get .side_effect = [
103- {
104- # First request is for sevice account info.
105- "email" : "service-account@example.com" ,
106- "scopes" : ["one" , "two" ],
107- },
108- {
109- # Second request is for the token.
110- "access_token" : "token" ,
111- "expires_in" : 500 ,
112- },
113- ]
102+ get .side_effect = [{"access_token" : "token" , "expires_in" : 500 }]
114103
115104 # Refresh credentials
116105 self .credentials .refresh (None )
@@ -120,8 +109,8 @@ def test_refresh_success(self, get, utcnow):
120109 assert self .credentials .expiry == (utcnow () + datetime .timedelta (seconds = 500 ))
121110
122111 # Check the credential info
123- assert self .credentials .service_account_email == "service-account@example.com "
124- assert self .credentials ._scopes == [ "one" , "two" ]
112+ assert self .credentials .service_account_email == "default "
113+ assert self .credentials ._scopes is None
125114
126115 # Check that the credentials are valid (have a token and are not
127116 # expired)
@@ -137,18 +126,7 @@ def test_refresh_success(self, get, utcnow):
137126 )
138127 @mock .patch ("google.auth.compute_engine._metadata.get" , autospec = True )
139128 def test_refresh_success_with_scopes (self , get , utcnow , mock_metrics_header_value ):
140- get .side_effect = [
141- {
142- # First request is for sevice account info.
143- "email" : "service-account@example.com" ,
144- "scopes" : ["one" , "two" ],
145- },
146- {
147- # Second request is for the token.
148- "access_token" : "token" ,
149- "expires_in" : 500 ,
150- },
151- ]
129+ get .side_effect = [{"access_token" : "token" , "expires_in" : 500 }]
152130
153131 # Refresh credentials
154132 scopes = ["three" , "four" ]
@@ -160,7 +138,7 @@ def test_refresh_success_with_scopes(self, get, utcnow, mock_metrics_header_valu
160138 assert self .credentials .expiry == (utcnow () + datetime .timedelta (seconds = 500 ))
161139
162140 # Check the credential info
163- assert self .credentials .service_account_email == "service-account@example.com "
141+ assert self .credentials .service_account_email == "default "
164142 assert self .credentials ._scopes == scopes
165143
166144 # Check that the credentials are valid (have a token and are not
@@ -184,18 +162,7 @@ def test_refresh_error(self, get):
184162
185163 @mock .patch ("google.auth.compute_engine._metadata.get" , autospec = True )
186164 def test_before_request_refreshes (self , get ):
187- get .side_effect = [
188- {
189- # First request is for sevice account info.
190- "email" : "service-account@example.com" ,
191- "scopes" : "one two" ,
192- },
193- {
194- # Second request is for the token.
195- "access_token" : "token" ,
196- "expires_in" : 500 ,
197- },
198- ]
165+ get .side_effect = [{"access_token" : "token" , "expires_in" : 500 }]
199166
200167 # Credentials should start as invalid
201168 assert not self .credentials .valid
@@ -473,20 +440,6 @@ def test_with_target_audience_integration(self):
473440 have been mocked.
474441 """
475442
476- # mock information about credentials
477- responses .add (
478- responses .GET ,
479- "http://metadata.google.internal/computeMetadata/v1/instance/"
480- "service-accounts/default/?recursive=true" ,
481- status = 200 ,
482- content_type = "application/json" ,
483- json = {
484- "scopes" : "email" ,
485- "email" : "service-account@example.com" ,
486- "aliases" : ["default" ],
487- },
488- )
489-
490443 # mock information about universe_domain
491444 responses .add (
492445 responses .GET ,
@@ -501,7 +454,7 @@ def test_with_target_audience_integration(self):
501454 responses .add (
502455 responses .GET ,
503456 "http://metadata.google.internal/computeMetadata/v1/instance/"
504- "service-accounts/service-account@example.com /token" ,
457+ "service-accounts/default /token" ,
505458 status = 200 ,
506459 content_type = "application/json" ,
507460 json = {
@@ -641,25 +594,11 @@ def test_with_quota_project_integration(self):
641594 have been mocked.
642595 """
643596
644- # mock information about credentials
645- responses .add (
646- responses .GET ,
647- "http://metadata.google.internal/computeMetadata/v1/instance/"
648- "service-accounts/default/?recursive=true" ,
649- status = 200 ,
650- content_type = "application/json" ,
651- json = {
652- "scopes" : "email" ,
653- "email" : "service-account@example.com" ,
654- "aliases" : ["default" ],
655- },
656- )
657-
658597 # mock token for credentials
659598 responses .add (
660599 responses .GET ,
661600 "http://metadata.google.internal/computeMetadata/v1/instance/"
662- "service-accounts/service-account@example.com /token" ,
601+ "service-accounts/default /token" ,
663602 status = 200 ,
664603 content_type = "application/json" ,
665604 json = {
0 commit comments