Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 8ea69b7

Browse files
committed
Remove unused _trust_boundary field and update unit tests.
1 parent 6458f5a commit 8ea69b7

7 files changed

Lines changed: 4 additions & 32 deletions

File tree

google/auth/credentials.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ def __init__(self):
6161
If this is None, the token is assumed to never expire."""
6262
self._quota_project_id = None
6363
"""Optional[str]: Project to use for quota and billing purposes."""
64-
self._trust_boundary = None
65-
"""Optional[dict]: Cache of a trust boundary response which has a list
66-
of allowed regions and an encoded string representation of credentials
67-
trust boundary."""
6864
self._universe_domain = DEFAULT_UNIVERSE_DOMAIN
6965
"""Optional[str]: The universe domain value, default is googleapis.com
7066
"""

google/oauth2/credentials.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ def __init__(
8787
refresh_handler=None,
8888
enable_reauth_refresh=False,
8989
granted_scopes=None,
90-
trust_boundary=None,
9190
universe_domain=credentials.DEFAULT_UNIVERSE_DOMAIN,
9291
account=None,
9392
):
@@ -131,7 +130,6 @@ def __init__(
131130
granted_scopes (Optional[Sequence[str]]): The scopes that were consented/granted by the user.
132131
This could be different from the requested scopes and it could be empty if granted
133132
and requested scopes were same.
134-
trust_boundary (str): String representation of trust boundary meta.
135133
universe_domain (Optional[str]): The universe domain. The default
136134
universe domain is googleapis.com.
137135
account (Optional[str]): The account associated with the credential.
@@ -154,7 +152,6 @@ def __init__(
154152
self._rapt_token = rapt_token
155153
self.refresh_handler = refresh_handler
156154
self._enable_reauth_refresh = enable_reauth_refresh
157-
self._trust_boundary = trust_boundary
158155
self._universe_domain = universe_domain or credentials.DEFAULT_UNIVERSE_DOMAIN
159156
self._account = account or ""
160157
self._cred_file_path = None
@@ -192,7 +189,6 @@ def __setstate__(self, d):
192189
self._quota_project_id = d.get("_quota_project_id")
193190
self._rapt_token = d.get("_rapt_token")
194191
self._enable_reauth_refresh = d.get("_enable_reauth_refresh")
195-
self._trust_boundary = d.get("_trust_boundary")
196192
self._universe_domain = (
197193
d.get("_universe_domain") or credentials.DEFAULT_UNIVERSE_DOMAIN
198194
)
@@ -300,7 +296,6 @@ def _make_copy(self):
300296
quota_project_id=self.quota_project_id,
301297
rapt_token=self.rapt_token,
302298
enable_reauth_refresh=self._enable_reauth_refresh,
303-
trust_boundary=self._trust_boundary,
304299
universe_domain=self._universe_domain,
305300
account=self._account,
306301
)
@@ -494,7 +489,6 @@ def from_authorized_user_info(cls, info, scopes=None):
494489
quota_project_id=info.get("quota_project_id"), # may not exist
495490
expiry=expiry,
496491
rapt_token=info.get("rapt_token"), # may not exist
497-
trust_boundary=info.get("trust_boundary"), # may not exist
498492
universe_domain=info.get("universe_domain"), # may not exist
499493
account=info.get("account", ""), # may not exist
500494
)

tests/oauth2/test_service_account.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,6 @@ def test_refresh_success(self, jwt_grant):
529529
# Check that the credentials are valid (have a token and are not expired).
530530
assert credentials.valid
531531

532-
# Trust boundary should be None since env var is not set and no initial
533-
# boundary was provided.
534-
assert credentials._trust_boundary is None
535-
536532
@mock.patch("google.oauth2._client.jwt_grant", autospec=True)
537533
def test_before_request_refreshes(self, jwt_grant):
538534
credentials = self.make_credentials()

tests/test_aws.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,9 +2053,6 @@ def test_refresh_success_with_impersonation_ignore_default_scopes(
20532053
"authorization": "Bearer {}".format(self.SUCCESS_RESPONSE["access_token"]),
20542054
"x-goog-user-project": QUOTA_PROJECT_ID,
20552055
"x-goog-api-client": IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE,
2056-
# TODO(negarb): Uncomment and update when trust boundary is supported
2057-
# for external account credentials.
2058-
# "x-allowed-locations": "0x0",
20592056
}
20602057
impersonation_request_data = {
20612058
"delegates": None,
@@ -2148,7 +2145,6 @@ def test_refresh_success_with_impersonation_use_default_scopes(
21482145
"authorization": "Bearer {}".format(self.SUCCESS_RESPONSE["access_token"]),
21492146
"x-goog-user-project": QUOTA_PROJECT_ID,
21502147
"x-goog-api-client": IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE,
2151-
# "x-allowed-locations": "0x0",
21522148
}
21532149
impersonation_request_data = {
21542150
"delegates": None,
@@ -2343,7 +2339,6 @@ def test_refresh_success_with_supplier_with_impersonation(
23432339
"authorization": "Bearer {}".format(self.SUCCESS_RESPONSE["access_token"]),
23442340
"x-goog-user-project": QUOTA_PROJECT_ID,
23452341
"x-goog-api-client": IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE,
2346-
# "x-allowed-locations": "0x0",
23472342
}
23482343
impersonation_request_data = {
23492344
"delegates": None,

tests/test_credentials.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -533,20 +533,14 @@ def test_maybe_start_refresh_is_skipped_if_non_default_universe_domain(
533533
@mock.patch(
534534
"google.auth._regional_access_boundary_utils._RegionalAccessBoundaryRefreshManager.start_refresh"
535535
)
536-
@mock.patch("urllib.parse.urlparse")
537-
def test_maybe_start_refresh_handles_url_parse_errors(
538-
self, mock_urlparse, mock_start_refresh
539-
):
540-
mock_urlparse.side_effect = ValueError("Malformed URL")
536+
def test_maybe_start_refresh_handles_url_parse_errors(self, mock_start_refresh):
541537
creds = CredentialsImpl()
542538
request = mock.Mock()
543539
with mock.patch.dict(
544540
os.environ,
545541
{environment_vars.GOOGLE_AUTH_TRUST_BOUNDARY_ENABLED: "true"},
546542
):
547-
creds._maybe_start_regional_access_boundary_refresh(
548-
request, "http://malformed-url"
549-
)
543+
creds._maybe_start_regional_access_boundary_refresh(request, "http://[")
550544
mock_start_refresh.assert_called_once_with(creds, request)
551545

552546
@mock.patch("google.oauth2._client._lookup_regional_access_boundary")

tests/test_identity_pool.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,6 @@ def assert_underlying_credentials_refresh(
385385
"Content-Type": "application/json",
386386
"authorization": "Bearer {}".format(token_response["access_token"]),
387387
"x-goog-api-client": metrics_header_value,
388-
# TODO(negarb): Uncomment and update when trust boundary is supported
389-
# for external account credentials.
390-
# "x-allowed-locations": "0x0",
391388
}
392389
impersonation_request_data = {
393390
"delegates": None,

tests/test_impersonated_credentials.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ def test_refresh_success(self, use_data_bytes, mock_donor_credentials):
324324
== ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE
325325
)
326326

327-
def test_refresh_source_creds_no_trust_boundary(self):
328-
# Use a source credential that does not support trust boundaries.
327+
def test_refresh_source_creds_no_regional_access_boundary(self):
328+
# Use a source credential that does not support regional access boundaries.
329329
source_credentials = credentials.Credentials(token="source_token")
330330
creds = self.make_credentials(source_credentials=source_credentials)
331331
token = "impersonated_token"

0 commit comments

Comments
 (0)