aboutsummaryrefslogtreecommitdiff
path: root/tests/views/test_endpoint.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-17 22:10:40 +0100
committerDennis Fink2026-11-17 22:10:40 +0100
commit63af533d98aac82b6d4f069b217d3e837285508d (patch)
tree4ac11960f9676d3bb5a6f62204ef139862734209 /tests/views/test_endpoint.py
parentacd1f42847786963fc4aaeed884c3091700c9e35 (diff)
downloadwebmentions-ssg-63af533d98aac82b6d4f069b217d3e837285508d.tar.gz
webmentions-ssg-63af533d98aac82b6d4f069b217d3e837285508d.zip
feat(receiver): explain received Webmention failures
Map known verification failures to human-readable explanations and show suggested next steps only for receiver-controlled problems while retaining raw reasons. Return a specific validation error when targets are outside `ALLOWED_TARGET_HOSTNAMES` and reuse the guidance for status history.
Diffstat (limited to '')
-rw-r--r--tests/views/test_endpoint.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/views/test_endpoint.py b/tests/views/test_endpoint.py
index 4a2abde..cb6f426 100644
--- a/tests/views/test_endpoint.py
+++ b/tests/views/test_endpoint.py
@@ -50,6 +50,22 @@ def test_endpoint_returns_form_errors(
assert response.get_json() == errors
+def test_endpoint_explains_disallowed_target_hostname_without_storing_a_mention(
+ app: Flask, client: FlaskClient
+) -> None:
+ response = client.post(
+ "/endpoint",
+ data={"source": SOURCE_URL, "target": "https://unconfigured.example/post"},
+ )
+
+ assert response.status_code == HTTPStatus.BAD_REQUEST
+ assert response.get_json() == {
+ "target": ["Target hostname is not in ALLOWED_TARGET_HOSTNAMES."]
+ }
+ with app.app_context():
+ assert db.session.scalar(sa.select(ReceivedWebmention)) is None
+
+
def test_endpoint_creates_webmention(
app: Flask,
client: FlaskClient,