From a285fdf29e59c3b957247ea9241943c7202e9a28 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Fri, 13 Nov 2026 21:20:40 +0100 Subject: refactor(core): consolidate repeated helper logic Centralize SQL row counts, hostname parsing, and content-type normalization so tasks, forms, and scanners share consistent implementations. Simplify periodic task registration and admin lookups with table-driven setup and Flask-SQLAlchemy's built-in 404 helper. --- tests/test_forms.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/test_forms.py') diff --git a/tests/test_forms.py b/tests/test_forms.py index a37a6d0..e636eae 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -178,6 +178,18 @@ def test_endpoint_rejects_private_ip_literals(app: Flask, source: str) -> None: assert "URL must use a public address." in form.errors["source"] +def test_endpoint_rejects_private_ip_literal_with_trailing_dot(app: Flask) -> None: + with app.test_request_context("/endpoint", method="POST"): + form = EndpointForm( + formdata=MultiDict( + {"source": "http://127.0.0.1./", "target": VALID_TARGET} + ), + meta={"csrf": False}, + ) + assert not form.validate() + assert "URL must use a public address." in form.errors["source"] + + def test_endpoint_handles_malformed_ipv6_without_crashing(app: Flask) -> None: with app.test_request_context("/endpoint", method="POST"): form = EndpointForm( -- cgit v1.3.1