diff options
Diffstat (limited to 'tests/forms/test_init.py')
| -rw-r--r-- | tests/forms/test_init.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/forms/test_init.py b/tests/forms/test_init.py index 0f5cb23..2a68509 100644 --- a/tests/forms/test_init.py +++ b/tests/forms/test_init.py @@ -145,3 +145,26 @@ def test_endpoint_handles_malformed_ipv6_without_crashing(app: Flask) -> None: ) assert not form.validate() assert "Invalid input." in form.errors["target"] + + +def test_endpoint_form_applies_configurable_url_byte_limit_to_both_fields( + app: Flask, +) -> None: + with app.test_request_context("/endpoint", method="POST"): + app.config["MAX_WEBMENTION_URL_BYTES"] = len(VALID_SOURCE.encode("utf-8")) + form = EndpointForm( + formdata=MultiDict({"source": VALID_SOURCE + "x", "target": VALID_TARGET}), + meta={"csrf": False}, + ) + assert not form.validate() + assert "source" in form.errors + assert any("bytes" in message for message in form.errors["source"]) + + app.config["MAX_WEBMENTION_URL_BYTES"] = len(VALID_TARGET.encode("utf-8")) + form = EndpointForm( + formdata=MultiDict({"source": VALID_SOURCE, "target": VALID_TARGET + "x"}), + meta={"csrf": False}, + ) + assert not form.validate() + assert "target" in form.errors + assert any("bytes" in message for message in form.errors["target"]) |
