Skip to content

Commit 4a4c007

Browse files
committed
Update auth tests to fix mock behavior
1 parent c3c6725 commit 4a4c007

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/client/test_auth.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ async def test_oauth_discovery_fallback_order(self, oauth_provider):
265265
]
266266

267267
@pytest.mark.anyio
268-
async def test_oauth_discovery_fallback_conditions(self, oauth_provider):
268+
async def test_oauth_discovery_fallback_conditions(self, oauth_provider: OAuthClientProvider):
269269
"""Test the conditions during which an AS metadata discovery fallback will be attempted."""
270270
# Ensure no tokens are stored
271271
oauth_provider.context.current_tokens = None
@@ -349,7 +349,9 @@ async def test_oauth_discovery_fallback_conditions(self, oauth_provider):
349349
)
350350

351351
# Mock the authorization process to minimize unnecessary state in this test
352-
oauth_provider._perform_authorization = mock.AsyncMock(return_value=("test_auth_code", "test_code_verifier"))
352+
oauth_provider._perform_authorization_code_grant = mock.AsyncMock(
353+
return_value=("test_auth_code", "test_code_verifier")
354+
)
353355

354356
# Next request should fall back to legacy behavior and auth with the RS (mocked /authorize, next is /token)
355357
token_request = await auth_flow.asend(oauth_metadata_response_3)
@@ -662,7 +664,7 @@ async def test_auth_flow_with_valid_tokens(self, oauth_provider, mock_storage, v
662664
pass # Expected
663665

664666
@pytest.mark.anyio
665-
async def test_auth_flow_with_no_tokens(self, oauth_provider, mock_storage):
667+
async def test_auth_flow_with_no_tokens(self, oauth_provider: OAuthClientProvider, mock_storage):
666668
"""Test auth flow when no tokens are available, triggering the full OAuth flow."""
667669
# Ensure no tokens are stored
668670
oauth_provider.context.current_tokens = None
@@ -731,7 +733,9 @@ async def test_auth_flow_with_no_tokens(self, oauth_provider, mock_storage):
731733
)
732734

733735
# Mock the authorization process
734-
oauth_provider._perform_authorization = mock.AsyncMock(return_value=("test_auth_code", "test_code_verifier"))
736+
oauth_provider._perform_authorization_code_grant = mock.AsyncMock(
737+
return_value=("test_auth_code", "test_code_verifier")
738+
)
735739

736740
# Next request should be to exchange token
737741
token_request = await auth_flow.asend(registration_response)

0 commit comments

Comments
 (0)