test_the_comment_endpoint_refuses_what_it_must¶
Tests › tests/test_wiki_hub.py
What this test is for
Why it exists
SAME DOOR AS EVERY PAGE: the session cookie, JSON only (a cross-site form cannot send it without a preflight), the hub's own origin when one is sent, a size cap, and the store's own refusals (empty, over the limit) passed back with their reason.
Verifies REQ-DDB-WIKI-032 REQ-DDB-WIKI-033
Given
server, builder, live, _gone = hubbuilder.release.set()
5 more
url = f"http://127.0.0.1:{server.port}/api/{live.slug}/comment"cookie = f"clew_wiki={server.token}"good = json.dumps({"page": "a.html", "anchor": "", "quote": "", "body": "hi"}).encode()empty = json.dumps({"page": "a.html", "anchor": "", "quote": "", "body": " "}).encode()status, reply = _post(url, empty, cookie)
When
- —
Then
- ✓ _post(url, good)[0] equals 403
- ✓ _post(url, good, cookie, kind="text/plain")[0] equals 415
- ✓ _post(url, good, cookie, origin="http://evil.example")[0] equals 403
- ✓ _post(url, b"x" * 70_000, cookie)[0] equals 413
- ✓ status equals 400
- ✓ reply contains "empty"
- ✓ _post(f"http://127.0.0.1:{server.port}/api/nosuch/comment", good, cookie)[0] equals 404
- ✓ CommentStore.for_repo(server.home, live.repo_path).unread() equals []
What it exercises
The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.
Build this wiki from the index · 37 of 400 steps
… 7 steps between
… 343 later steps
4 more
- thread `clew-first-build-` — `_first_build_worker` (clew/mcp_server/server.py) · 2 of 142 steps
- Look up one name: everything the index holds about it · 2 of 226 steps
- clew — `main` (clew/cli.py) · 2 of 400 steps
- `main` (clew/guard/main.py) · 2 of 357 steps
tests/test_wiki_hub.py:410 · its file's page
What it checks (7)
assert _post(url, good)[0] == 403observes_postassert _post(url, good, cookie, kind="text/plain")[0] == 415observes_postassert _post(url, good, cookie, origin="http://evil.example")[0] == 403observes_postassert _post(url, b"x" * 70_000, cookie)[0] == 413observes_postassert status == 400 and "empty" in replynot attributedassert _post(f"http://127.0.0.1:{server.port}/api/nosuch/comment", good, cookie)[0] == 404observes_postassert CommentStore.for_repo(server.home, live.repo_path).unread() == []not attributed
Where the product reaches it
No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.
Call flow
test_the_comment_endpoint_refuses_what_it_must→_postWhat it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Requirements it verifies (2)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-WIKI-032 | catalog | unknown |
| REQ-DDB-WIKI-033 | catalog | unknown |
Also reaches 2 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-MCP-001 measured
- REQ-DDB-WIKI-054 measured