Skip to content

Commit a98f33f

Browse files
authored
Merge pull request #9 from sacha-development-stuff/codex/fix-token-exchange-implementation-for-test-failures
Fix token exchange metadata tests
2 parents 5976e77 + bde2448 commit a98f33f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tests/client/test_auth.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import httpx
1313
import pytest
14-
from pydantic import AnyHttpUrl
14+
from pydantic import AnyHttpUrl, AnyUrl
1515

1616
from mcp.client.auth import (
1717
ClientCredentialsProvider,
@@ -91,6 +91,7 @@ def oauth_metadata():
9191
"authorization_code",
9292
"refresh_token",
9393
"client_credentials",
94+
"token-exchange",
9495
],
9596
code_challenge_methods_supported=["S256"],
9697
)
@@ -1014,6 +1015,7 @@ def test_build_metadata(
10141015
"authorization_code",
10151016
"refresh_token",
10161017
"client_credentials",
1018+
"token-exchange",
10171019
],
10181020
token_endpoint_auth_methods_supported=["client_secret_post"],
10191021
service_documentation=AnyHttpUrl(service_documentation_url),

tests/server/fastmcp/auth/test_auth_integration.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ async def test_metadata_endpoint(self, test_client: httpx.AsyncClient):
417417
"authorization_code",
418418
"refresh_token",
419419
"client_credentials",
420+
"token-exchange",
420421
]
421422
assert metadata["service_documentation"] == "https://docs.example.com/"
422423

@@ -1030,7 +1031,7 @@ async def test_client_registration_invalid_grant_type(
10301031
assert error_data["error"] == "invalid_client_metadata"
10311032
assert error_data["error_description"] == (
10321033
"grant_types must be authorization_code and "
1033-
"refresh_token or client_credentials"
1034+
"refresh_token or client_credentials or token exchange"
10341035
)
10351036

10361037
@pytest.mark.anyio
@@ -1361,10 +1362,7 @@ async def test_metadata_includes_token_exchange(
13611362
response = await test_client.get("/.well-known/oauth-authorization-server")
13621363
assert response.status_code == 200
13631364
metadata = response.json()
1364-
assert (
1365-
"token-exchange"
1366-
in metadata["grant_types_supported"]
1367-
)
1365+
assert "token-exchange" in metadata["grant_types_supported"]
13681366

13691367
@pytest.mark.anyio
13701368
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)