Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions system_tests/system_tests_async/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
import pytest

from google.auth import _default_async
from google.auth.exceptions import RefreshError

EXPECT_PROJECT_ID = os.getenv("EXPECT_PROJECT_ID")
CREDENTIALS = os.getenv("GOOGLE_APPLICATION_CREDENTIALS", "")

EXPECT_PROJECT_ID = os.environ.get("EXPECT_PROJECT_ID")

@pytest.mark.asyncio
async def test_application_default_credentials(verify_refresh):
Expand All @@ -26,4 +29,10 @@ async def test_application_default_credentials(verify_refresh):
if EXPECT_PROJECT_ID is not None:
assert project_id is not None

await verify_refresh(credentials)
try:
await verify_refresh(credentials)
except RefreshError as e:
# allow expired credentials for explicit_authorized_user tests
# TODO: https://github.com/googleapis/google-auth-library-python/issues/1882
if not CREDENTIALS.endswith("authorized_user.json") or "Token has been expired or revoked" not in str(e):
raise
12 changes: 10 additions & 2 deletions system_tests/system_tests_sync/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import os

import google.auth
from google.auth.exceptions import RefreshError

EXPECT_PROJECT_ID = os.environ.get("EXPECT_PROJECT_ID")
EXPECT_PROJECT_ID = os.getenv("EXPECT_PROJECT_ID")
CREDENTIALS = os.getenv("GOOGLE_APPLICATION_CREDENTIALS", "")


def test_application_default_credentials(verify_refresh):
Expand All @@ -25,4 +27,10 @@ def test_application_default_credentials(verify_refresh):
if EXPECT_PROJECT_ID is not None:
assert project_id is not None

verify_refresh(credentials)
try:
verify_refresh(credentials)
except RefreshError as e:
# allow expired credentials for explicit_authorized_user tests
# TODO: https://github.com/googleapis/google-auth-library-python/issues/1882
if not CREDENTIALS.endswith("authorized_user.json") or "Token has been expired or revoked" not in str(e):
raise