aboutsummaryrefslogtreecommitdiff
path: root/tests/test_forms.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-13 21:20:40 +0100
committerDennis Fink2026-11-13 21:20:40 +0100
commita285fdf29e59c3b957247ea9241943c7202e9a28 (patch)
tree17ceeb703de23af1e67081d99a8864bbe353fb46 /tests/test_forms.py
parent78ecd8bc227bdcbbd0e45eea025f7223252ed0da (diff)
downloadwebmentions-ssg-a285fdf29e59c3b957247ea9241943c7202e9a28.tar.gz
webmentions-ssg-a285fdf29e59c3b957247ea9241943c7202e9a28.zip
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.
Diffstat (limited to 'tests/test_forms.py')
-rw-r--r--tests/test_forms.py12
1 files changed, 12 insertions, 0 deletions
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(