@@ -48,10 +48,10 @@ def reset_cache():
48
48
class TestAsyncAuthMethods :
49
49
"""Tests for asynchronous Google ID token fetching."""
50
50
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" )
53
53
@patch (
54
- "google.auth.default" ,
54
+ "toolbox_core.auth_methods. google.auth.default" ,
55
55
return_value = (MagicMock (id_token = None ), MOCK_PROJECT_ID ),
56
56
)
57
57
async def test_aget_google_id_token_success_first_call (
@@ -70,7 +70,7 @@ async def test_aget_google_id_token_success_first_call(
70
70
assert auth_methods ._token_cache ["token" ] == MOCK_ID_TOKEN
71
71
assert auth_methods ._token_cache ["expires_at" ] == MOCK_EXPIRY_DATETIME
72
72
73
- @patch ("google.auth.default" )
73
+ @patch ("toolbox_core.auth_methods. google.auth.default" )
74
74
async def test_aget_google_id_token_success_uses_cache (self , mock_default ):
75
75
"""Tests that subsequent calls use the cached token if valid."""
76
76
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):
84
84
mock_default .assert_not_called ()
85
85
assert token == f"{ auth_methods .BEARER_TOKEN_PREFIX } { MOCK_ID_TOKEN } "
86
86
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" )
89
89
@patch (
90
- "google.auth.default" ,
90
+ "toolbox_core.auth_methods. google.auth.default" ,
91
91
return_value = (MagicMock (id_token = None ), MOCK_PROJECT_ID ),
92
92
)
93
93
async def test_aget_google_id_token_refreshes_expired_cache (
@@ -110,9 +110,9 @@ async def test_aget_google_id_token_refreshes_expired_cache(
110
110
assert token == f"{ auth_methods .BEARER_TOKEN_PREFIX } { MOCK_ID_TOKEN } "
111
111
assert auth_methods ._token_cache ["token" ] == MOCK_ID_TOKEN
112
112
113
- @patch ("google.oauth2 .id_token.fetch_id_token" )
113
+ @patch ("toolbox_core.auth_methods .id_token.fetch_id_token" )
114
114
@patch (
115
- "google.auth.default" ,
115
+ "toolbox_core.auth_methods. google.auth.default" ,
116
116
return_value = (MagicMock (id_token = None ), MOCK_PROJECT_ID ),
117
117
)
118
118
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(
131
131
class TestSyncAuthMethods :
132
132
"""Tests for synchronous Google ID token fetching."""
133
133
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" )
138
138
def test_get_google_id_token_success_local_creds (
139
139
self , mock_default , mock_session , mock_request , mock_verify
140
140
):
@@ -159,7 +159,7 @@ def test_get_google_id_token_success_local_creds(
159
159
assert auth_methods ._token_cache ["token" ] == MOCK_ID_TOKEN
160
160
assert auth_methods ._token_cache ["expires_at" ] == MOCK_EXPIRY_DATETIME
161
161
162
- @patch ("google.auth.default" )
162
+ @patch ("toolbox_core.auth_methods. google.auth.default" )
163
163
def test_get_google_id_token_success_uses_cache (self , mock_default ):
164
164
"""Tests that subsequent calls use the cached token if valid."""
165
165
auth_methods ._token_cache ["token" ] = MOCK_ID_TOKEN
@@ -173,10 +173,10 @@ def test_get_google_id_token_success_uses_cache(self, mock_default):
173
173
mock_default .assert_not_called ()
174
174
assert token == f"{ auth_methods .BEARER_TOKEN_PREFIX } { MOCK_ID_TOKEN } "
175
175
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" )
178
178
@patch (
179
- "google.auth.default" ,
179
+ "toolbox_core.auth_methods. google.auth.default" ,
180
180
return_value = (MagicMock (id_token = None ), MOCK_PROJECT_ID ),
181
181
)
182
182
def test_get_google_id_token_fetch_failure (
@@ -193,10 +193,10 @@ def test_get_google_id_token_fetch_failure(
193
193
mock_fetch .assert_called_once ()
194
194
mock_verify .assert_not_called ()
195
195
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" )
198
198
@patch (
199
- "google.auth.default" ,
199
+ "toolbox_core.auth_methods. google.auth.default" ,
200
200
return_value = (MagicMock (id_token = None ), MOCK_PROJECT_ID ),
201
201
)
202
202
def test_get_google_id_token_validation_failure (
@@ -213,9 +213,9 @@ def test_get_google_id_token_validation_failure(
213
213
214
214
assert auth_methods ._token_cache ["token" ] is None
215
215
216
- @patch ("google.oauth2 .id_token.fetch_id_token" )
216
+ @patch ("toolbox_core.auth_methods .id_token.fetch_id_token" )
217
217
@patch (
218
- "google.auth.default" ,
218
+ "toolbox_core.auth_methods. google.auth.default" ,
219
219
return_value = (MagicMock (id_token = None ), MOCK_PROJECT_ID ),
220
220
)
221
221
def test_get_raises_if_no_audience_and_no_local_token (
0 commit comments