|
5 | 5 | import base64 |
6 | 6 | import time |
7 | 7 | from unittest import mock |
8 | | -from urllib.parse import unquote |
| 8 | +from urllib.parse import parse_qs, quote, unquote, urlparse |
9 | 9 |
|
10 | 10 | import httpx |
11 | 11 | import pytest |
|
27 | 27 | is_valid_client_metadata_url, |
28 | 28 | should_use_client_metadata_url, |
29 | 29 | ) |
| 30 | +from mcp.server.auth.routes import build_metadata |
| 31 | +from mcp.server.auth.settings import ClientRegistrationOptions, RevocationOptions |
30 | 32 | from mcp.shared.auth import ( |
31 | 33 | OAuthClientInformationFull, |
32 | 34 | OAuthClientMetadata, |
@@ -758,8 +760,6 @@ async def test_resource_param_included_with_recent_protocol_version(self, oauth_ |
758 | 760 | content = request.content.decode() |
759 | 761 | assert "resource=" in content |
760 | 762 | # Check URL-encoded resource parameter |
761 | | - from urllib.parse import quote |
762 | | - |
763 | 763 | expected_resource = quote(oauth_provider.context.get_resource_url(), safe="") |
764 | 764 | assert f"resource={expected_resource}" in content |
765 | 765 |
|
@@ -1226,8 +1226,6 @@ async def capture_redirect(url: str) -> None: |
1226 | 1226 | "%3A", ":" |
1227 | 1227 | ).replace("+", " ") |
1228 | 1228 | # Extract state from redirect URL |
1229 | | - from urllib.parse import parse_qs, urlparse |
1230 | | - |
1231 | 1229 | parsed = urlparse(url) |
1232 | 1230 | params = parse_qs(parsed.query) |
1233 | 1231 | captured_state = params.get("state", [None])[0] |
@@ -1336,9 +1334,6 @@ def test_build_metadata( |
1336 | 1334 | registration_endpoint: str, |
1337 | 1335 | revocation_endpoint: str, |
1338 | 1336 | ): |
1339 | | - from mcp.server.auth.routes import build_metadata |
1340 | | - from mcp.server.auth.settings import ClientRegistrationOptions, RevocationOptions |
1341 | | - |
1342 | 1337 | metadata = build_metadata( |
1343 | 1338 | issuer_url=AnyHttpUrl(issuer_url), |
1344 | 1339 | service_documentation_url=AnyHttpUrl(service_documentation_url), |
|
0 commit comments