Use MemoryStore for OAuth proxy tests (#3111)

Co-authored-by: Bill Easton <strawgate@users.noreply.github.com>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
This commit is contained in:
SrzStephen 2026-02-10 10:07:32 +08:00 committed by GitHub
commit 392d38326d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View file

@ -8,6 +8,7 @@ This test suite covers:
"""
import pytest
from key_value.aio.stores.memory import MemoryStore
from mcp.shared.auth import OAuthClientInformationFull
from pydantic import AnyUrl
from starlette.applications import Starlette
@ -42,6 +43,7 @@ class TestEnhancedAuthorizationHandler:
),
base_url="https://myserver.com",
jwt_signing_key="test-secret",
client_storage=MemoryStore(),
)
def test_unregistered_client_returns_html_for_browser(self, oauth_proxy):
@ -303,6 +305,7 @@ class TestContentNegotiation:
),
base_url="https://myserver.com",
jwt_signing_key="test-secret",
client_storage=MemoryStore(),
)
def test_html_preferred_when_both_accepted(self, oauth_proxy):

View file

@ -8,6 +8,7 @@ The fix uses MCP SDK 1.17+ which implements RFC 9728 path-scoped well-known URLs
import httpx
import pytest
from key_value.aio.stores.memory import MemoryStore
from pydantic import AnyHttpUrl
from starlette.applications import Starlette
from starlette.routing import Mount
@ -220,6 +221,7 @@ class TestOAuthMounting:
token_verifier=token_verifier,
base_url="https://api.example.com/api", # Includes mount prefix
issuer_url="https://api.example.com", # Root level
client_storage=MemoryStore(),
)
mcp = FastMCP("test-server", auth=auth_provider)
@ -290,6 +292,7 @@ class TestOAuthMounting:
upstream_client_secret="test-client-secret",
token_verifier=token_verifier,
base_url="https://api.example.com/api", # Has path, no explicit issuer_url
client_storage=MemoryStore(),
)
mcp = FastMCP("test-server", auth=auth_provider)
@ -366,6 +369,7 @@ class TestOAuthMounting:
token_verifier=token_verifier,
base_url="https://api.example.com/api",
issuer_url="https://api.example.com", # Explicitly root
client_storage=MemoryStore(),
)
well_known_routes = auth_provider.get_well_known_routes(mcp_path="/mcp")

View file

@ -1,6 +1,7 @@
"""Tests for OAuth proxy redirect URI validation."""
import pytest
from key_value.aio.stores.memory import MemoryStore
from mcp.shared.auth import InvalidRedirectUriError
from pydantic import AnyUrl
@ -111,6 +112,7 @@ class TestOAuthProxyRedirectValidation:
token_verifier=MockTokenVerifier(),
base_url="http://localhost:8000",
jwt_signing_key="test-secret",
client_storage=MemoryStore(),
)
# The proxy should store None for default (allow all)
@ -129,6 +131,7 @@ class TestOAuthProxyRedirectValidation:
base_url="http://localhost:8000",
allowed_client_redirect_uris=custom_patterns,
jwt_signing_key="test-secret",
client_storage=MemoryStore(),
)
assert proxy._allowed_client_redirect_uris == custom_patterns
@ -144,6 +147,7 @@ class TestOAuthProxyRedirectValidation:
base_url="http://localhost:8000",
allowed_client_redirect_uris=[],
jwt_signing_key="test-secret",
client_storage=MemoryStore(),
)
assert proxy._allowed_client_redirect_uris == []
@ -161,6 +165,7 @@ class TestOAuthProxyRedirectValidation:
base_url="http://localhost:8000",
allowed_client_redirect_uris=custom_patterns,
jwt_signing_key="test-secret",
client_storage=MemoryStore(),
)
# Register a client
@ -194,6 +199,7 @@ class TestOAuthProxyRedirectValidation:
base_url="http://localhost:8000",
allowed_client_redirect_uris=custom_patterns,
jwt_signing_key="test-secret",
client_storage=MemoryStore(),
)
# Get an unregistered client