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
1 change: 1 addition & 0 deletions google/auth/impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ def from_impersonated_service_account_info(cls, info, scopes=None):
target_principal = impersonation_url[start_index + 1 : end_index]
delegates = info.get("delegates")
quota_project_id = info.get("quota_project_id")
scopes = scopes or info.get("scopes")
trust_boundary = info.get("trust_boundary")

return cls(
Expand Down
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.
17 changes: 17 additions & 0 deletions tests/test_impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,23 @@ def test_from_impersonated_service_account_info_with_invalid_impersonation_url(
)
assert excinfo.match(r"Cannot extract target principal from")

def test_from_impersonated_service_account_info_with_scopes(self):
info = copy.deepcopy(IMPERSONATED_SERVICE_ACCOUNT_AUTHORIZED_USER_SOURCE_INFO)
info["scopes"] = ["scope1", "scope2"]
credentials = impersonated_credentials.Credentials.from_impersonated_service_account_info(
info
)
assert credentials._target_scopes == ["scope1", "scope2"]

def test_from_impersonated_service_account_info_with_scopes_param(self):
info = copy.deepcopy(IMPERSONATED_SERVICE_ACCOUNT_AUTHORIZED_USER_SOURCE_INFO)
info["scopes"] = ["scope_from_info_1", "scope_from_info_2"]
scopes_param = ["scope_from_param_1", "scope_from_param_2"]
credentials = impersonated_credentials.Credentials.from_impersonated_service_account_info(
info, scopes=scopes_param
)
assert credentials._target_scopes == scopes_param

def test_get_cred_info(self):
credentials = self.make_credentials()
assert not credentials.get_cred_info()
Expand Down