From 9225572505bb8fb9610bf0e178a13546c4cde582 Mon Sep 17 00:00:00 2001 From: zzstoatzz Date: Mon, 10 Aug 2026 15:02:32 -0500 Subject: [PATCH] test(auth): exercise CIMD audience mismatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with OpenAI Codex --- tests/server/auth/oauth_proxy/test_oauth_proxy.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/server/auth/oauth_proxy/test_oauth_proxy.py b/tests/server/auth/oauth_proxy/test_oauth_proxy.py index 86f61cb1f..c67fe0f48 100644 --- a/tests/server/auth/oauth_proxy/test_oauth_proxy.py +++ b/tests/server/auth/oauth_proxy/test_oauth_proxy.py @@ -1,6 +1,7 @@ """Tests for OAuth proxy initialization and configuration.""" import time +from unittest.mock import patch from urllib.parse import parse_qs, urlparse import httpx @@ -10,6 +11,7 @@ from key_value.aio.stores.memory import MemoryStore from starlette.applications import Starlette from starlette.testclient import TestClient +from fastmcp.server.auth.auth import PrivateKeyJWTClientAuthenticator from fastmcp.server.auth.oauth_proxy import OAuthProxy from fastmcp.server.auth.oauth_proxy.models import OAuthTransaction @@ -443,8 +445,14 @@ class TestCIMDTokenEndpointAudience: client_storage=MemoryStore(), ) - app = Starlette(routes=proxy.get_routes(mcp_path="/mcp")) + with patch( + "fastmcp.server.auth.oauth_proxy.proxy.PrivateKeyJWTClientAuthenticator", + wraps=PrivateKeyJWTClientAuthenticator, + ) as authenticator: + app = Starlette(routes=proxy.get_routes(mcp_path="/mcp")) + with TestClient(app) as client: metadata = client.get("/.well-known/oauth-authorization-server").json() - assert proxy.token_endpoint_url == metadata["token_endpoint"] + expected_audience = authenticator.call_args.kwargs["token_endpoint_url"] + assert expected_audience == metadata["token_endpoint"]