Skip to content
Merged
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
26 changes: 20 additions & 6 deletions packages/google-auth/tests/test_impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,19 @@ def _sign_bytes_helper(

assert signature == b"signature"

@mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel", autospec=True)
def test_sign_bytes_configures_mtls(self, mock_configure_mtls, mock_donor_credentials, mock_authorizedsession_sign):
@mock.patch(
"google.auth.transport.requests.AuthorizedSession.configure_mtls_channel",
autospec=True,
)
def test_sign_bytes_configures_mtls(
self, mock_configure_mtls, mock_donor_credentials, mock_authorizedsession_sign
):
credentials = self.make_credentials(lifetime=None)
# Refresh is needed to make credentials valid before signing
request = self.make_request(
data=json.dumps({"accessToken": "token", "expireTime": "2026-06-09T00:00:00Z"}),
data=json.dumps(
{"accessToken": "token", "expireTime": "2026-06-09T00:00:00Z"}
),
status=http_client.OK,
)
credentials.refresh(request)
Expand Down Expand Up @@ -764,8 +771,13 @@ def test_with_scopes_provide_default_scopes(self):
)
assert credentials._target_scopes == ["fake_scope1"]

@mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel", autospec=True)
def test_id_token_refresh_configures_mtls(self, mock_configure_mtls, mock_donor_credentials):
@mock.patch(
"google.auth.transport.requests.AuthorizedSession.configure_mtls_channel",
autospec=True,
)
def test_id_token_refresh_configures_mtls(
self, mock_configure_mtls, mock_donor_credentials
):
credentials = self.make_credentials(lifetime=None)
credentials.token = "token"
id_creds = impersonated_credentials.IDTokenCredentials(
Expand All @@ -775,7 +787,9 @@ def test_id_token_refresh_configures_mtls(self, mock_configure_mtls, mock_donor_
with mock.patch(
"google.auth.transport.requests.AuthorizedSession.post", autospec=True
) as mock_post:
mock_post.return_value = MockResponse({"token": ID_TOKEN_DATA}, http_client.OK)
mock_post.return_value = MockResponse(
{"token": ID_TOKEN_DATA}, http_client.OK
)
id_creds.refresh(None)

mock_configure_mtls.assert_called_once()
Expand Down