File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed
Expand file tree Collapse file tree 2 files changed +21
-4
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
20+
21+ EXPECT_PROJECT_ID = os .getenv ("EXPECT_PROJECT_ID" )
22+ CREDENTIALS = os .getenv ("GOOGLE_APPLICATION_CREDENTIALS" , "" )
1923
20- EXPECT_PROJECT_ID = os .environ .get ("EXPECT_PROJECT_ID" )
2124
2225@pytest .mark .asyncio
2326async def test_application_default_credentials (verify_refresh ):
@@ -26,4 +29,10 @@ async def test_application_default_credentials(verify_refresh):
2629 if EXPECT_PROJECT_ID is not None :
2730 assert project_id is not None
2831
29- await verify_refresh (credentials )
32+ try :
33+ await verify_refresh (credentials )
34+ except RefreshError as e :
35+ # allow expired credentials for explicit_authorized_user tests
36+ # TODO: https://github.com/googleapis/google-auth-library-python/issues/1882
37+ if not CREDENTIALS .endswith ("authorized_user.json" ) or "Token has been expired or revoked" not in str (e ):
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
19- EXPECT_PROJECT_ID = os .environ .get ("EXPECT_PROJECT_ID" )
20+ EXPECT_PROJECT_ID = os .getenv ("EXPECT_PROJECT_ID" )
21+ CREDENTIALS = os .getenv ("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 as e :
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" ) or "Token has been expired or revoked" not in str (e ):
36+ raise
You can’t perform that action at this time.
0 commit comments