Skip to content

Commit 0b800fe

Browse files
committed
remove uneeded test and rename methods
1 parent 0826232 commit 0b800fe

File tree

2 files changed

+7
-93
lines changed

2 files changed

+7
-93
lines changed

tests/server/auth/test_protected_resource.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
@pytest.fixture
15-
def protected_resource_app():
15+
def test_app():
1616
"""Fixture to create protected resource routes for testing."""
1717

1818
# Create the protected resource routes
@@ -29,21 +29,18 @@ def protected_resource_app():
2929

3030

3131
@pytest.fixture
32-
async def test_client(protected_resource_app: Starlette):
32+
async def test_client(test_app: Starlette):
3333
"""Fixture to create an HTTP client for the protected resource app."""
34-
async with httpx.AsyncClient(
35-
transport=httpx.ASGITransport(app=protected_resource_app), base_url="https://mcptest.com"
36-
) as client:
34+
async with httpx.AsyncClient(transport=httpx.ASGITransport(app=test_app), base_url="https://mcptest.com") as client:
3735
yield client
3836

3937

4038
@pytest.mark.anyio
41-
async def test_metadata_endpoint(self, test_client: httpx.AsyncClient):
39+
async def test_metadata_endpoint(test_client: httpx.AsyncClient):
4240
"""Test the OAuth 2.0 Protected Resource metadata endpoint."""
4341

44-
response = await protected_resource_test_client.get("/.well-known/oauth-protected-resource")
45-
metadata = response.json()
46-
assert metadata == snapshot(
42+
response = await test_client.get("/.well-known/oauth-protected-resource")
43+
assert response.json() == snapshot(
4744
{
4845
"resource": "https://example.com/resource",
4946
"authorization_servers": ["https://auth.example.com/authorization"],

tests/shared/test_auth.py

Lines changed: 1 addition & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""Tests for OAuth 2.0 shared code."""
22

3-
import pytest
4-
5-
from mcp.shared.auth import OAuthMetadata, ProtectedResourceMetadata
3+
from mcp.shared.auth import OAuthMetadata
64

75

86
class TestOAuthMetadata:
@@ -39,84 +37,3 @@ def test_oidc(self):
3937
"userinfo_endpoint": "https://example.com/oauth2/userInfo",
4038
}
4139
)
42-
43-
44-
class TestProtectedResourceMetadataInvalid:
45-
"""Tests for ProtectedResourceMetadata parsing."""
46-
47-
def test_invalid_metadata(self):
48-
"""Should throw when parsing invalid metadata."""
49-
with pytest.raises(ValueError):
50-
ProtectedResourceMetadata.model_validate(
51-
{
52-
"resource": "Not a valid URL",
53-
"authorization_servers": ["https://example.com/oauth2/authorize"],
54-
"scopes_supported": ["read", "write"],
55-
"bearer_methods_supported": ["header"],
56-
}
57-
)
58-
59-
def test_valid_metadata(self):
60-
"""Should not throw when parsing protected resource metadata."""
61-
62-
ProtectedResourceMetadata.model_validate(
63-
{
64-
"resource": "https://example.com/resource",
65-
"authorization_servers": ["https://example.com/oauth2/authorize"],
66-
"scopes_supported": ["read", "write"],
67-
"bearer_methods_supported": ["header"],
68-
}
69-
)
70-
71-
def test_valid_with_resource_metadata(self):
72-
"""Should not throw when parsing metadata with resource_name and resource_documentation."""
73-
74-
ProtectedResourceMetadata.model_validate(
75-
{
76-
"resource": "https://example.com/resource",
77-
"authorization_servers": ["https://example.com/oauth2/authorize"],
78-
"scopes_supported": ["read", "write"],
79-
"bearer_methods_supported": ["header"],
80-
"resource_name": "Example Resource",
81-
"resource_documentation": "https://example.com/resource/documentation",
82-
}
83-
)
84-
85-
def test_valid_with_invalid_resource_documentation(self):
86-
"""Should throw when parsing metadata with resource_name and invalid resource_documentation."""
87-
with pytest.raises(ValueError):
88-
ProtectedResourceMetadata.model_validate(
89-
{
90-
"resource": "https://example.com/resource",
91-
"authorization_servers": ["https://example.com/oauth2/authorize"],
92-
"scopes_supported": ["read", "write"],
93-
"bearer_methods_supported": ["header"],
94-
"resource_name": "Example Resource",
95-
"resource_documentation": "Not a valid URL",
96-
}
97-
)
98-
99-
def test_valid_full_protected_resource_metadata(self):
100-
"""Should not throw when parsing full metadata."""
101-
102-
ProtectedResourceMetadata.model_validate(
103-
{
104-
"resource": "https://example.com/resource",
105-
"authorization_servers": ["https://example.com/oauth2/authorize"],
106-
"jwks_uri": "https://example.com/.well-known/jwks.json",
107-
"scopes_supported": ["read", "write"],
108-
"bearer_methods_supported": ["header"],
109-
"resource_signing_alg_values_supported": ["RS256"],
110-
"resource_name": "Example Resource",
111-
"resource_documentation": "https://example.com/resource/documentation",
112-
"resource_policy_uri": "https://example.com/resource/policy",
113-
"resource_tos_uri": "https://example.com/resource/tos",
114-
"tls_client_certificate_bound_access_tokens": True,
115-
# authorization_details_types_supported is a complex type
116-
# so we use an empty list for simplicity
117-
# see RFC9396
118-
"authorization_details_types_supported": [],
119-
"dpop_signing_alg_values_supported": ["RS256", "ES256"],
120-
"dpop_signing_access_tokens": True,
121-
}
122-
)

0 commit comments

Comments
 (0)