|
1 | 1 | import pytest |
2 | 2 | from pydantic import AnyHttpUrl |
3 | 3 |
|
4 | | -from mcp.server.auth.routes import build_metadata, validate_issuer_url, validate_redirect_uri |
| 4 | +from mcp.server.auth.routes import build_metadata, validate_issuer_url |
| 5 | +from mcp.server.auth.url_validators import validate_redirect_uri |
5 | 6 | from mcp.server.auth.settings import AuthSettings, ClientRegistrationOptions, RevocationOptions |
6 | 7 |
|
7 | 8 |
|
@@ -88,25 +89,25 @@ def test_validate_redirect_uri_http_ipv6_loopback_allowed(): |
88 | 89 |
|
89 | 90 |
|
90 | 91 | def test_validate_redirect_uri_javascript_scheme_rejected(): |
91 | | - with pytest.raises(ValueError, match='Redirect URI must use HTTPS'): |
| 92 | + with pytest.raises(ValueError, match="Redirect URI must use HTTPS"): |
92 | 93 | validate_redirect_uri(AnyHttpUrl('javascript:alert(1)')) |
93 | 94 |
|
94 | 95 |
|
95 | 96 | def test_validate_redirect_uri_file_scheme_rejected(): |
96 | | - with pytest.raises(ValueError, match='Redirect URI must use HTTPS'): |
| 97 | + with pytest.raises(ValueError, match="Redirect URI must use HTTPS"): |
97 | 98 | validate_redirect_uri(AnyHttpUrl('file:///etc/passwd')) |
98 | 99 |
|
99 | 100 |
|
100 | 101 | def test_validate_redirect_uri_http_non_loopback_rejected(): |
101 | | - with pytest.raises(ValueError, match='Redirect URI must use HTTPS'): |
| 102 | + with pytest.raises(ValueError, match="Redirect URI must use HTTPS"): |
102 | 103 | validate_redirect_uri(AnyHttpUrl('http://evil.com/cb')) |
103 | 104 |
|
104 | 105 |
|
105 | 106 | def test_validate_redirect_uri_fragment_rejected(): |
106 | | - with pytest.raises(ValueError, match='Redirect URI must not contain a fragment'): |
| 107 | + with pytest.raises(ValueError, match="Redirect URI must not contain a fragment"): |
107 | 108 | validate_redirect_uri(AnyHttpUrl('https://example.com/cb#frag')) |
108 | 109 |
|
109 | 110 |
|
110 | 111 | def test_validate_redirect_uri_empty_fragment_rejected(): |
111 | | - with pytest.raises(ValueError, match='Redirect URI must not contain a fragment'): |
| 112 | + with pytest.raises(ValueError, match="Redirect URI must not contain a fragment"): |
112 | 113 | validate_redirect_uri(AnyHttpUrl('https://example.com/cb#')) |
0 commit comments