aboutsummaryrefslogtreecommitdiff
path: root/tests/test_views.py
diff options
context:
space:
mode:
authorDennis Fink2026-10-31 17:42:00 +0100
committerDennis Fink2026-10-31 17:42:00 +0100
commit6924ad7e52033365c55d5afacdd916c502cc80cb (patch)
tree8a52b8e8fbae7a6bcc85d250cac2436a2c42e748 /tests/test_views.py
parent3494eab1208dc18478485e02c61e292556502fa6 (diff)
downloadwebmentions-ssg-6924ad7e52033365c55d5afacdd916c502cc80cb.tar.gz
webmentions-ssg-6924ad7e52033365c55d5afacdd916c502cc80cb.zip
feat(receiver): add resource limits and retention
Bound incoming request and URL sizes so untrusted Webmention submissions cannot consume unbounded application or database resources. Purge old failed and deleted received Webmentions on a schedule, and use portable SHA-256 URL fingerprints to preserve uniqueness for long URLs.
Diffstat (limited to '')
-rw-r--r--tests/test_views.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/test_views.py b/tests/test_views.py
index 21a33bf..f5e301f 100644
--- a/tests/test_views.py
+++ b/tests/test_views.py
@@ -760,7 +760,7 @@ def test_endpoint_recovers_from_concurrent_insert(
initial_result = Mock()
initial_result.scalar_one_or_none.return_value = None
competing_result = Mock()
- competing_result.scalar_one.return_value = competing_webmention
+ competing_result.scalar_one_or_none.return_value = competing_webmention
execute = Mock(side_effect=[initial_result, competing_result])
add = Mock()
@@ -1184,3 +1184,13 @@ def test_admin_only_links_safe_existing_status_urls(
html = response.get_data(as_text=True)
assert (f'href="{status_url}"' in html) is safe
assert status_url in html
+
+
+def test_endpoint_rejects_request_bodies_over_configured_maximum(
+ app: Flask, client: FlaskClient
+) -> None:
+ app.config["MAX_CONTENT_LENGTH"] = 128
+ response = client.post(
+ "/endpoint", data={"source": SOURCE_URL + "x" * 150, "target": TARGET_URL}
+ )
+ assert response.status_code == 413