Skip to content

Commit 1cc7df3

Browse files
fix: read universe_domain for external account authorized user (#1450)
* chore: refresh sys test cred * fix: read universe_domain for external account authorized user * update test json file * update
1 parent 30562b8 commit 1cc7df3

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

google/auth/external_account_authorized_user.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ def from_info(cls, info, **kwargs):
342342
revoke_url=info.get("revoke_url"),
343343
quota_project_id=info.get("quota_project_id"),
344344
scopes=info.get("scopes"),
345+
universe_domain=info.get("universe_domain", _DEFAULT_UNIVERSE_DOMAIN),
345346
**kwargs
346347
)
347348

system_tests/secrets.tar.enc

0 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"type": "external_account_authorized_user",
3+
"audience": "//iam.fake_universe_domain/locations/global/workforcePools/$WORKFORCE_POOL_ID/providers/$PROVIDER_ID",
4+
"refresh_token": "refreshToken",
5+
"token_url": "https://sts.fake_universe_domain/v1/oauth/token",
6+
"token_info_url": "https://sts.fake_universe_domain/v1/instrospect",
7+
"client_id": "clientId",
8+
"client_secret": "clientSecret",
9+
"universe_domain": "fake_universe_domain"
10+
}

tests/test__default.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@
157157
DATA_DIR, "external_account_authorized_user.json"
158158
)
159159

160+
EXTERNAL_ACCOUNT_AUTHORIZED_USER_NON_GDU_FILE = os.path.join(
161+
DATA_DIR, "external_account_authorized_user_non_gdu.json"
162+
)
163+
160164
MOCK_CREDENTIALS = mock.Mock(spec=credentials.CredentialsWithQuotaProject)
161165
MOCK_CREDENTIALS.with_quota_project.return_value = MOCK_CREDENTIALS
162166

@@ -576,6 +580,15 @@ def test_load_credentials_from_file_external_account_authorized_user():
576580
assert project_id is None
577581

578582

583+
def test_load_credentials_from_file_external_account_authorized_user_non_gdu():
584+
credentials, _ = _default.load_credentials_from_file(
585+
EXTERNAL_ACCOUNT_AUTHORIZED_USER_NON_GDU_FILE, request=mock.sentinel.request
586+
)
587+
588+
assert isinstance(credentials, external_account_authorized_user.Credentials)
589+
assert credentials.universe_domain == "fake_universe_domain"
590+
591+
579592
def test_load_credentials_from_file_external_account_authorized_user_bad_format(tmpdir):
580593
filename = tmpdir.join("external_account_authorized_user_bad.json")
581594
filename.write(json.dumps({"type": "external_account_authorized_user"}))

0 commit comments

Comments
 (0)