Skip to content

Commit 227a06d

Browse files
committed
fix patches
1 parent f71f902 commit 227a06d

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

packages/toolbox-core/tests/test_auth_methods.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def reset_cache():
4848
class TestAsyncAuthMethods:
4949
"""Tests for asynchronous Google ID token fetching."""
5050

51-
@patch("google.oauth2.id_token.verify_oauth2_token")
52-
@patch("google.oauth2.id_token.fetch_id_token")
51+
@patch("toolbox_core.auth_methods.id_token.verify_oauth2_token")
52+
@patch("toolbox_core.auth_methods.id_token.fetch_id_token")
5353
@patch(
54-
"google.auth.default",
54+
"toolbox_core.auth_methods.google.auth.default",
5555
return_value=(MagicMock(id_token=None), MOCK_PROJECT_ID),
5656
)
5757
async def test_aget_google_id_token_success_first_call(
@@ -70,7 +70,7 @@ async def test_aget_google_id_token_success_first_call(
7070
assert auth_methods._token_cache["token"] == MOCK_ID_TOKEN
7171
assert auth_methods._token_cache["expires_at"] == MOCK_EXPIRY_DATETIME
7272

73-
@patch("google.auth.default")
73+
@patch("toolbox_core.auth_methods.google.auth.default")
7474
async def test_aget_google_id_token_success_uses_cache(self, mock_default):
7575
"""Tests that subsequent calls use the cached token if valid."""
7676
auth_methods._token_cache["token"] = MOCK_ID_TOKEN
@@ -84,10 +84,10 @@ async def test_aget_google_id_token_success_uses_cache(self, mock_default):
8484
mock_default.assert_not_called()
8585
assert token == f"{auth_methods.BEARER_TOKEN_PREFIX}{MOCK_ID_TOKEN}"
8686

87-
@patch("google.oauth2.id_token.verify_oauth2_token")
88-
@patch("google.oauth2.id_token.fetch_id_token")
87+
@patch("toolbox_core.auth_methods.id_token.verify_oauth2_token")
88+
@patch("toolbox_core.auth_methods.id_token.fetch_id_token")
8989
@patch(
90-
"google.auth.default",
90+
"toolbox_core.auth_methods.google.auth.default",
9191
return_value=(MagicMock(id_token=None), MOCK_PROJECT_ID),
9292
)
9393
async def test_aget_google_id_token_refreshes_expired_cache(
@@ -110,9 +110,9 @@ async def test_aget_google_id_token_refreshes_expired_cache(
110110
assert token == f"{auth_methods.BEARER_TOKEN_PREFIX}{MOCK_ID_TOKEN}"
111111
assert auth_methods._token_cache["token"] == MOCK_ID_TOKEN
112112

113-
@patch("google.oauth2.id_token.fetch_id_token")
113+
@patch("toolbox_core.auth_methods.id_token.fetch_id_token")
114114
@patch(
115-
"google.auth.default",
115+
"toolbox_core.auth_methods.google.auth.default",
116116
return_value=(MagicMock(id_token=None), MOCK_PROJECT_ID),
117117
)
118118
async def test_aget_raises_if_no_audience_and_no_local_token(
@@ -131,10 +131,10 @@ async def test_aget_raises_if_no_audience_and_no_local_token(
131131
class TestSyncAuthMethods:
132132
"""Tests for synchronous Google ID token fetching."""
133133

134-
@patch("google.oauth2.id_token.verify_oauth2_token")
135-
@patch("google.auth.transport.requests.Request")
136-
@patch("google.auth.transport.requests.AuthorizedSession")
137-
@patch("google.auth.default")
134+
@patch("toolbox_core.auth_methods.id_token.verify_oauth2_token")
135+
@patch("toolbox_core.auth_methods.Request")
136+
@patch("toolbox_core.auth_methods.AuthorizedSession")
137+
@patch("toolbox_core.auth_methods.google.auth.default")
138138
def test_get_google_id_token_success_local_creds(
139139
self, mock_default, mock_session, mock_request, mock_verify
140140
):
@@ -159,7 +159,7 @@ def test_get_google_id_token_success_local_creds(
159159
assert auth_methods._token_cache["token"] == MOCK_ID_TOKEN
160160
assert auth_methods._token_cache["expires_at"] == MOCK_EXPIRY_DATETIME
161161

162-
@patch("google.auth.default")
162+
@patch("toolbox_core.auth_methods.google.auth.default")
163163
def test_get_google_id_token_success_uses_cache(self, mock_default):
164164
"""Tests that subsequent calls use the cached token if valid."""
165165
auth_methods._token_cache["token"] = MOCK_ID_TOKEN
@@ -173,10 +173,10 @@ def test_get_google_id_token_success_uses_cache(self, mock_default):
173173
mock_default.assert_not_called()
174174
assert token == f"{auth_methods.BEARER_TOKEN_PREFIX}{MOCK_ID_TOKEN}"
175175

176-
@patch("google.oauth2.id_token.verify_oauth2_token")
177-
@patch("google.oauth2.id_token.fetch_id_token")
176+
@patch("toolbox_core.auth_methods.id_token.verify_oauth2_token")
177+
@patch("toolbox_core.auth_methods.id_token.fetch_id_token")
178178
@patch(
179-
"google.auth.default",
179+
"toolbox_core.auth_methods.google.auth.default",
180180
return_value=(MagicMock(id_token=None), MOCK_PROJECT_ID),
181181
)
182182
def test_get_google_id_token_fetch_failure(
@@ -193,10 +193,10 @@ def test_get_google_id_token_fetch_failure(
193193
mock_fetch.assert_called_once()
194194
mock_verify.assert_not_called()
195195

196-
@patch("google.oauth2.id_token.verify_oauth2_token")
197-
@patch("google.oauth2.id_token.fetch_id_token")
196+
@patch("toolbox_core.auth_methods.id_token.verify_oauth2_token")
197+
@patch("toolbox_core.auth_methods.id_token.fetch_id_token")
198198
@patch(
199-
"google.auth.default",
199+
"toolbox_core.auth_methods.google.auth.default",
200200
return_value=(MagicMock(id_token=None), MOCK_PROJECT_ID),
201201
)
202202
def test_get_google_id_token_validation_failure(
@@ -213,9 +213,9 @@ def test_get_google_id_token_validation_failure(
213213

214214
assert auth_methods._token_cache["token"] is None
215215

216-
@patch("google.oauth2.id_token.fetch_id_token")
216+
@patch("toolbox_core.auth_methods.id_token.fetch_id_token")
217217
@patch(
218-
"google.auth.default",
218+
"toolbox_core.auth_methods.google.auth.default",
219219
return_value=(MagicMock(id_token=None), MOCK_PROJECT_ID),
220220
)
221221
def test_get_raises_if_no_audience_and_no_local_token(

0 commit comments

Comments
 (0)