From 57d62172813310bd4e5819a0fe494efc216d138e Mon Sep 17 00:00:00 2001 From: Rishi Gupta Date: Wed, 21 Oct 2026 22:28:27 +0530 Subject: [PATCH] test(security): cover malformed URL ports --- tests/test_security.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_security.py b/tests/test_security.py index b0729acdd..c311ec07d 100644 --- a/tests/test_security.py +++ b/tests/test_security.py @@ -55,6 +55,16 @@ def test_validate_url_rejects_empty_scheme(): validate_url("//no-scheme.example.com") +@pytest.mark.parametrize("url", [ + "http://example.com:abc/path", + "https://example.com:65536/path", + "http://example.com:0/path", +]) +def test_validate_url_rejects_invalid_port(url): + with pytest.raises(ValueError, match="port"): + validate_url(url) + + # --------------------------------------------------------------------------- # safe_fetch - scheme and redirect guards (mocked network) # ---------------------------------------------------------------------------