Skip to content

Commit bce9046

Browse files
BabyChrist666claude
andcommitted
fix: update tests to expect issuer URLs without trailing slash
Update test_build_metadata to expect stripped trailing slashes from issuer URLs, matching the serializer behavior. Remove the xfail marker on the simple-url test case since the serializer now handles Pydantic's AnyHttpUrl trailing slash addition. Update test_auth_integration to expect issuer without trailing slash. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d2f445d commit bce9046

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tests/client/test_auth.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,29 +1414,27 @@ async def mock_callback() -> tuple[str, str | None]:
14141414
@pytest.mark.parametrize(
14151415
(
14161416
"issuer_url",
1417+
"expected_issuer",
14171418
"service_documentation_url",
14181419
"authorization_endpoint",
14191420
"token_endpoint",
14201421
"registration_endpoint",
14211422
"revocation_endpoint",
14221423
),
14231424
(
1424-
# Pydantic's AnyUrl incorrectly adds trailing slash to base URLs
1425-
# This is being fixed in https://github.com/pydantic/pydantic-core/pull/1719 (Pydantic 2.12+)
14261425
pytest.param(
1426+
"https://auth.example.com",
14271427
"https://auth.example.com",
14281428
"https://auth.example.com/docs",
14291429
"https://auth.example.com/authorize",
14301430
"https://auth.example.com/token",
14311431
"https://auth.example.com/register",
14321432
"https://auth.example.com/revoke",
14331433
id="simple-url",
1434-
marks=pytest.mark.xfail(
1435-
reason="Pydantic AnyUrl adds trailing slash to base URLs - fixed in Pydantic 2.12+"
1436-
),
14371434
),
14381435
pytest.param(
14391436
"https://auth.example.com/",
1437+
"https://auth.example.com", # trailing slash stripped per RFC 8414
14401438
"https://auth.example.com/docs",
14411439
"https://auth.example.com/authorize",
14421440
"https://auth.example.com/token",
@@ -1445,6 +1443,7 @@ async def mock_callback() -> tuple[str, str | None]:
14451443
id="with-trailing-slash",
14461444
),
14471445
pytest.param(
1446+
"https://auth.example.com/v1/mcp",
14481447
"https://auth.example.com/v1/mcp",
14491448
"https://auth.example.com/v1/mcp/docs",
14501449
"https://auth.example.com/v1/mcp/authorize",
@@ -1457,6 +1456,7 @@ async def mock_callback() -> tuple[str, str | None]:
14571456
)
14581457
def test_build_metadata(
14591458
issuer_url: str,
1459+
expected_issuer: str,
14601460
service_documentation_url: str,
14611461
authorization_endpoint: str,
14621462
token_endpoint: str,
@@ -1472,7 +1472,7 @@ def test_build_metadata(
14721472

14731473
assert metadata.model_dump(exclude_defaults=True, mode="json") == snapshot(
14741474
{
1475-
"issuer": Is(issuer_url),
1475+
"issuer": Is(expected_issuer),
14761476
"authorization_endpoint": Is(authorization_endpoint),
14771477
"token_endpoint": Is(token_endpoint),
14781478
"registration_endpoint": Is(registration_endpoint),

tests/server/mcpserver/auth/test_auth_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ async def test_metadata_endpoint(self, test_client: httpx.AsyncClient):
312312
assert response.status_code == 200
313313

314314
metadata = response.json()
315-
assert metadata["issuer"] == "https://auth.example.com/"
315+
assert metadata["issuer"] == "https://auth.example.com"
316316
assert metadata["authorization_endpoint"] == "https://auth.example.com/authorize"
317317
assert metadata["token_endpoint"] == "https://auth.example.com/token"
318318
assert metadata["registration_endpoint"] == "https://auth.example.com/register"

0 commit comments

Comments
 (0)