File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1616import pytest
1717
1818from google .auth import _default_async
19+ from google .auth .exceptions import RefreshError
1920
2021EXPECT_PROJECT_ID = os .environ .get ("EXPECT_PROJECT_ID" )
22+ CREDENTIALS = os .environ .get ("GOOGLE_APPLICATION_CREDENTIALS" )
23+
2124
2225@pytest .mark .asyncio
2326async def test_application_default_credentials (verify_refresh ):
2427 credentials , project_id = _default_async .default_async ()
28+ breakpoint ()
2529
2630 if EXPECT_PROJECT_ID is not None :
2731 assert project_id is not None
2832
29- await verify_refresh (credentials )
33+ try :
34+ await verify_refresh (credentials )
35+ except RefreshError :
36+ # allow expired credentials for explicit user tests
37+ if not CREDENTIALS .endswith ("authorized_user.json" ):
38+ raise
Original file line number Diff line number Diff line change 1515import os
1616
1717import google .auth
18+ from google .auth .exceptions import RefreshError
1819
1920EXPECT_PROJECT_ID = os .environ .get ("EXPECT_PROJECT_ID" )
21+ CREDENTIALS = os .environ .get ("GOOGLE_APPLICATION_CREDENTIALS" )
2022
2123
2224def test_application_default_credentials (verify_refresh ):
@@ -25,4 +27,10 @@ def test_application_default_credentials(verify_refresh):
2527 if EXPECT_PROJECT_ID is not None :
2628 assert project_id is not None
2729
28- verify_refresh (credentials )
30+ try :
31+ verify_refresh (credentials )
32+ except RefreshError :
33+ # allow expired credentials for explicit_authorized_user tests
34+ # TODO: https://github.com/googleapis/google-auth-library-python/issues/1882
35+ if not CREDENTIALS .endswith ("authorized_user.json" ):
36+ raise
You can’t perform that action at this time.
0 commit comments