File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
packages/google-auth/tests/oauth2 Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -309,6 +309,7 @@ def test_apply_with_quota_project_id(self):
309309 headers = {}
310310 creds .apply (headers )
311311 assert headers ["x-goog-user-project" ] == "quota-project-123"
312+ assert "token" in headers ["authorization" ]
312313
313314 def test_apply_with_no_quota_project_id (self ):
314315 creds = credentials .Credentials (
@@ -322,6 +323,7 @@ def test_apply_with_no_quota_project_id(self):
322323 headers = {}
323324 creds .apply (headers )
324325 assert "x-goog-user-project" not in headers
326+ assert "token" in headers ["authorization" ]
325327
326328 def test_with_quota_project (self ):
327329 creds = credentials .Credentials (
Original file line number Diff line number Diff line change @@ -178,6 +178,31 @@ def test__make_authorization_grant_assertion_subject(self):
178178 payload = jwt .decode (token , PUBLIC_CERT_BYTES )
179179 assert payload ["sub" ] == subject
180180
181+ def test_apply_with_quota_project_id (self ):
182+ credentials = service_account .Credentials (
183+ SIGNER ,
184+ self .SERVICE_ACCOUNT_EMAIL ,
185+ self .TOKEN_URI ,
186+ quota_project_id = "quota-project-123" ,
187+ )
188+
189+ headers = {}
190+ credentials .apply (headers , token = "token" )
191+
192+ assert headers ["x-goog-user-project" ] == "quota-project-123"
193+ assert "token" in headers ["authorization" ]
194+
195+ def test_apply_with_no_quota_project_id (self ):
196+ credentials = service_account .Credentials (
197+ SIGNER , self .SERVICE_ACCOUNT_EMAIL , self .TOKEN_URI
198+ )
199+
200+ headers = {}
201+ credentials .apply (headers , token = "token" )
202+
203+ assert "x-goog-user-project" not in headers
204+ assert "token" in headers ["authorization" ]
205+
181206 @mock .patch ("google.oauth2._client.jwt_grant" , autospec = True )
182207 def test_refresh_success (self , jwt_grant ):
183208 credentials = self .make_credentials ()
You can’t perform that action at this time.
0 commit comments