Skip to content

Commit 09c05aa

Browse files
committed
- Fixed the test cases.
1 parent 04ffe5a commit 09c05aa

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

tests/client/auth/test_enterprise_managed_auth_client.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,7 @@ async def test_perform_authorization_with_valid_tokens(mock_token_storage: Any):
507507

508508
@pytest.mark.anyio
509509
async def test_exchange_token_with_client_authentication(
510-
sample_id_token: str, sample_id_jag: str,
511-
mock_token_storage: Any
510+
sample_id_token: str, sample_id_jag: str, mock_token_storage: Any
512511
):
513512
"""Test token exchange with client authentication."""
514513
from mcp.shared.auth import OAuthClientInformationFull
@@ -566,10 +565,7 @@ async def test_exchange_token_with_client_authentication(
566565

567566

568567
@pytest.mark.anyio
569-
async def test_exchange_token_with_client_id_only(
570-
sample_id_token: str, sample_id_jag: str,
571-
mock_token_storage: Any
572-
):
568+
async def test_exchange_token_with_client_id_only(sample_id_token: str, sample_id_jag: str, mock_token_storage: Any):
573569
"""Test token exchange with client_id but no client_secret (covers branch 232->235)."""
574570
from mcp.shared.auth import OAuthClientInformationFull
575571

@@ -688,7 +684,7 @@ async def test_exchange_token_non_json_error_response(sample_id_token: str, mock
688684

689685
@pytest.mark.anyio
690686
async def test_exchange_token_warning_for_non_na_token_type(
691-
sample_id_token: str, sample_id_jag: str, mock_token_storage: Any
687+
sample_id_token: str, sample_id_jag: str, mock_token_storage: Any
692688
):
693689
"""Test token exchange logs warning for non-N_A token type."""
694690
token_exchange_params = TokenExchangeParameters.from_id_token(
@@ -726,7 +722,7 @@ async def test_exchange_token_warning_for_non_na_token_type(
726722
import logging
727723

728724
with patch.object(
729-
logging.getLogger("mcp.client.auth.extensions.enterprise_managed_auth"), "warning"
725+
logging.getLogger("mcp.client.auth.extensions.enterprise_managed_auth"), "warning"
730726
) as mock_warning:
731727
id_jag = await provider.exchange_token_for_id_jag(mock_client)
732728
assert id_jag == sample_id_jag
@@ -1035,14 +1031,12 @@ async def test_exchange_token_with_client_info_but_no_client_id(
10351031

10361032
# Verify client_id was not included (None), but client_secret was included
10371033
call_args = mock_client.post.call_args
1038-
assert call_args[1]["data"]["client_id"] is None
1034+
assert "client_id" not in call_args[1]["data"]
10391035
assert call_args[1]["data"]["client_secret"] == "test-secret"
10401036

10411037

10421038
@pytest.mark.anyio
1043-
async def test_exchange_id_jag_with_client_info_but_no_client_id(
1044-
sample_id_jag: str, mock_token_storage: Any
1045-
):
1039+
async def test_exchange_id_jag_with_client_info_but_no_client_id(sample_id_jag: str, mock_token_storage: Any):
10461040
"""Test ID-JAG exchange when client_info exists but client_id is None (covers line 302)."""
10471041
from pydantic import AnyHttpUrl
10481042

@@ -1102,7 +1096,7 @@ async def test_exchange_id_jag_with_client_info_but_no_client_id(
11021096

11031097
# Verify client_id was not included (None), but client_secret was included
11041098
call_args = mock_client.post.call_args
1105-
assert call_args[1]["data"]["client_id"] is None
1099+
assert "client_id" not in call_args[1]["data"]
11061100
assert call_args[1]["data"]["client_secret"] == "test-secret"
11071101

11081102

0 commit comments

Comments
 (0)