aboutsummaryrefslogtreecommitdiff
path: root/tests/forms
diff options
context:
space:
mode:
Diffstat (limited to 'tests/forms')
-rw-r--r--tests/forms/test_validators.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/forms/test_validators.py b/tests/forms/test_validators.py
index 2c427d3..1f73e6f 100644
--- a/tests/forms/test_validators.py
+++ b/tests/forms/test_validators.py
@@ -91,3 +91,27 @@ def test_url_max_bytes_rejects_malformed_unicode(app: Flask) -> None:
form = URLForm(MultiDict({"url": "\ud800"}))
with app.app_context(), pytest.raises(ValidationError, match="valid UTF-8"):
MaxURLBytes()(form, form.url)
+
+
+def test_max_url_bytes_skips_empty_field_data(app: Flask) -> None:
+ form = URLForm()
+ form.url.data = None
+ with app.app_context():
+ MaxURLBytes()(form, form.url)
+
+
+def test_strict_http_url_rejects_non_string_field_data() -> None:
+ from wtforms.validators import StopValidation
+
+ from webmentions_ssg.forms.validators import StrictHTTPURL
+
+ form = URLForm()
+ form.url.data = None
+ with pytest.raises(StopValidation, match="Invalid URL"):
+ StrictHTTPURL()(form, form.url)
+
+
+def test_nonpublic_ip_validator_reports_malformed_host() -> None:
+ form = URLForm(MultiDict({"url": "http://[invalid"}))
+ with pytest.raises(ValidationError, match="Invalid input"):
+ RejectNonPublicIPLiteral()(form, form.url)