Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: read universe_domain for external account authorized user #1450

Merged
merged 4 commits into from
Jan 11, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions google/auth/external_account_authorized_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ def from_info(cls, info, **kwargs):
revoke_url=info.get("revoke_url"),
quota_project_id=info.get("quota_project_id"),
scopes=info.get("scopes"),
universe_domain=info.get("universe_domain", _DEFAULT_UNIVERSE_DOMAIN),
**kwargs
)

Expand Down
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/data/external_account_authorized_user_non_gdu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "external_account_authorized_user",
"audience": "//iam.fake_universe_domain/locations/global/workforcePools/$WORKFORCE_POOL_ID/providers/$PROVIDER_ID",
"refresh_token": "refreshToken",
"token_url": "https://sts.fake_universe_domain/v1/oauth/token",
"token_info_url": "https://sts.fake_universe_domain/v1/instrospect",
"client_id": "clientId",
"client_secret": "clientSecret",
"universe_domain": "fake_universe_domain"
}
13 changes: 13 additions & 0 deletions tests/test__default.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@
DATA_DIR, "external_account_authorized_user.json"
)

EXTERNAL_ACCOUNT_AUTHORIZED_USER_NON_GDU_FILE = os.path.join(
DATA_DIR, "external_account_authorized_user_non_gdu.json"
)

MOCK_CREDENTIALS = mock.Mock(spec=credentials.CredentialsWithQuotaProject)
MOCK_CREDENTIALS.with_quota_project.return_value = MOCK_CREDENTIALS

Expand Down Expand Up @@ -576,6 +580,15 @@ def test_load_credentials_from_file_external_account_authorized_user():
assert project_id is None


def test_load_credentials_from_file_external_account_authorized_user_non_gdu():
credentials, _ = _default.load_credentials_from_file(
EXTERNAL_ACCOUNT_AUTHORIZED_USER_NON_GDU_FILE, request=mock.sentinel.request
)

assert isinstance(credentials, external_account_authorized_user.Credentials)
assert credentials.universe_domain == "fake_universe_domain"


def test_load_credentials_from_file_external_account_authorized_user_bad_format(tmpdir):
filename = tmpdir.join("external_account_authorized_user_bad.json")
filename.write(json.dumps({"type": "external_account_authorized_user"}))
Expand Down