Skip to content

Commit 35627dd

Browse files
committed
chore(tests): allow expired secret in system tests
1 parent b0993c7 commit 35627dd

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

system_tests/system_tests_async/test_default.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,23 @@
1616
import pytest
1717

1818
from google.auth import _default_async
19+
from google.auth.exceptions import RefreshError
1920

2021
EXPECT_PROJECT_ID = os.environ.get("EXPECT_PROJECT_ID")
22+
CREDENTIALS = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
23+
2124

2225
@pytest.mark.asyncio
2326
async 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

system_tests/system_tests_sync/test_default.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import os
1616

1717
import google.auth
18+
from google.auth.exceptions import RefreshError
1819

1920
EXPECT_PROJECT_ID = os.environ.get("EXPECT_PROJECT_ID")
21+
CREDENTIALS = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
2022

2123

2224
def 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

0 commit comments

Comments
 (0)