From 860b4ce03ebce7e5ea09a9f19db570596ccd0ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 31 Jul 2026 15:01:06 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=9A=AB=20keep=20parents=20off=20th?= =?UTF-8?q?e=20whiteboard=20entirely?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A parent is the school's read-only observer, but every board route was `CurrentUser` only — so a parent could open a board and draw on it. The cut that does the work is in `resolve_participants`: a parent id is refused as a participant, so a parent is never on a roster. That alone makes `board_for` and the room's door answer the outsider's 404 on every id-scoped route. `POST /boards` and `GET /boards` take `RequireStudent` (a 403 there leaks nothing — no board exists to hide), while the read path and the socket door re-check the role and answer 404, never 403, which would confirm the board is there. Refusing the door is also what stops a parent drawing: no socket, no `stroke` frame, and no per-stroke role read on the hot path. A board row written earlier that still lists a parent is inert — that parent now sees a 404 for it like any stranger. --- README.md | 26 ++++++++++--- src/lib.rs | 2 +- src/web/board_ws.rs | 10 +++-- src/web/boards.rs | 40 ++++++++++++++------ tests/e2e.rs | 66 ++++++++++++++++++++++++++++++++ tests/integration.rs | 89 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 211 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index fc4883b..42c1142 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ attendance, pomodoro, and homework reports — that's the whole role. Notes are per-file size cap is school policy in settings (`max_file_bytes`, default 5 MiB). Any two users can **message** each other, mail-style — subject + body into the recipient's inbox, each side filing its own copy through -archive/trash with a read flag the sender sees as a receipt (one of the two -places a `parent` writes — whiteboards below are the other). Attendance is event + attendees: create an event with an **audience** +archive/trash with a read flag the sender sees as a receipt (the only place a +`parent` writes). Attendance is event + attendees: create an event with an **audience** (the whole school, one role, a course's enrollment, or a **registration** signup list — omit for school-wide), then teachers mark the expected attendees present / absent / late / excused (students never self-mark), and a **roster @@ -111,8 +111,10 @@ inference outlives a request: the turn plus an empty `pending` answer are written *first*, the call goes out after, so a reload never loses an answer; the client then polls the message or reads it off an SSE stream (see "Chatbot"). -Any signed-in account (a `parent` included) can also open a **collaborative -whiteboard**: a titled board whose membership is an **ad-hoc invite list** — +Any account from `student` upwards can also open a **collaborative +whiteboard** (a `parent` gets no whiteboard access at all — it can neither open +one nor be invited onto one): a titled board whose membership is an **ad-hoc +invite list** — the creator names participant user ids, and no course, session or appointment is involved. Every participant draws over a WebSocket, the creator alone clears, locks, closes or deletes, and someone who is not on a board gets a @@ -2503,10 +2505,22 @@ context without either end having to be redeployed in lockstep. A board is a shared canvas whose membership is an **ad-hoc invite list**: the creator names participant user ids at `POST /boards` and that is the whole -model — no course, no lesson session, no appointment. Any signed-in account -(a `parent` included) may open one. **Every participant draws; the creator +model — no course, no lesson session, no appointment. Any account from +`student` upwards may open one. **Every participant draws; the creator alone clears, locks, closes or deletes.** +**No parents, anywhere.** The `parent` role is the school's read-only observer, +and it has no whiteboard access at all — not a view-only tier, none. It is +refused `POST /boards` and `GET /boards` with a `403`, and it cannot be *named* +in an invite list either: `resolve_participants` rejects a parent id with a +`400`, so a parent is never on a roster in the first place. That one cut is +what closes the rest — never on a roster means the id-scoped routes and the +room's door already answer the outsider's `404` (never a `403`, which would +confirm the board is there), and no socket opens, so no `stroke` frame can be +sent. The role bar is re-checked on the read path and at the door as well, so a +board row written before this rule that still lists a parent is inert: that +parent sees a `404` for it like any stranger. + **Two doors, two statuses.** A caller who is not on a board gets a `404` on every route, its existence included — an outsider must never learn a board is there. A participant who is not the creator has already been told it exists, so diff --git a/src/lib.rs b/src/lib.rs index 700a53d..ca30871 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,7 +63,7 @@ use crate::state::AppState; (name = "settings", description = "School policy, one singleton: exam kinds with their course-average weights, attendance statuses, grade-display bands, and the per-file upload size limit (`max_file_bytes` — note files and question images alike). An exam kind whose exams already carry marks cannot be removed from the list (409) — those marks would silently re-weight. Also the food program: the meal slots menus are published for — each with an optional `serving_minute`, the minutes past midnight **UTC** at which it is served (there is deliberately no school-timezone setting, so a UTC+3 school enters `540` for a noon meal; `null` = unset, and the cutoff then counts from midnight UTC) — the dietary tags a dish or a student's profile may carry, and `meal_cancel_cutoff_minutes` — one knob closing both booking and cancelling ahead of a slot's serving time (`null` = no cutoff). A slot a menu was already published for cannot be removed (409), same reason. Read: any authenticated user; edit: manager+"), (name = "subjects", description = "A course's curriculum topics. Created and listed under `/courses/{id}/subjects`; lookup/edit/delete at `/subjects/{id}`. Every exam question links to one of its course's subjects, so a subject in use cannot be deleted (409) — re-tag or delete the questions first. View follows the course (enrolled users, creator, assigned teachers, manager+); edit follows course management rights"), (name = "homework", description = "Course homework: a teacher assigns it per course (`POST /courses/{id}/homework`), tagged with one of the course's subjects (re-taggable; a subject with homework refuses deletion until it is re-tagged or removed) and given a future `due_at`, to the whole enrolled course or an optional `assigned` subset (empty means the whole course — whoever is enrolled when they submit; a subset cannot later be narrowed so as to strand work that already exists). Students submit optional text plus files — any content type, up to 10 per submission, each capped by the school's `max_file_bytes`, always served back as forced attachment downloads (never inline); a submission touched after `due_at` is flagged late (computed from the moving last-touch stamp, never stored — the first-submit stamp is immutable) and stays editable until it is graded. A teacher grades a status (`done`/`incomplete`/`missing`) with an optional 0–100 mark — grading freezes the submission until the grade is removed (un-grading reopens it), never targets the grader themselves, and covers work never handed in (that is how `missing` is set; the student reads the verdict at `GET /homework/{id}/result`). Beyond a teacher-set `missing` the roster and reports also compute a `missing` for anyone unsubmitted past due, and the roster keeps a straggler's stale work visible (flagged `unenrolled`) after an unenrollment or promotion. Homework marks stay out of the weighted `/marks` averages. Students see and fetch only the homework they are assigned (others 404, so a subset assignment never leaks); a linked parent reads a student's homework report — statuses, late flags, marks — but never the submitted files"), - (name = "boards", description = "Collaborative whiteboards. Anyone opens a board (`POST /boards`) with a title and an ad-hoc invite list of user ids — no course, session or appointment is involved — and every participant draws on it; the creator alone clears, locks, closes or deletes it. A caller who is not on a board gets a `404` for it on every route, existence included, while a participant who is not the creator gets a `403` on those four commands (they are already rendering the board, so hiding it from them would be a lie their client cannot act on). Strokes are **append-only and a clear deletes nothing**: it bumps the board's `epoch`, so the live canvas empties while every mark ever drawn stays stored — `GET /boards/{id}/strokes` is the current epoch (what a client draws to catch up), `GET /boards/{id}/history?epoch=` is the whole session or one named epoch, and `GET /boards/{id}/epochs` is the index of `clear` markers, each carrying the epoch it closed, that epoch's final stroke count, who cleared and when (the markers *are* the index, so the open epoch is deliberately absent from it). Two growth caps, both published at `GET /limits`: `max_epoch_strokes` bounds the *live* canvas and is recoverable (clear it and drawing resumes, losing nothing), while `max_board_strokes` bounds the board's *lifetime* storage and stamps `closed_at` on the way past — a closed board is permanently read-only and fully readable, never deleted, and there is no reopen. `POST /boards/{id}/close` is the manual form of that, and idempotent. `DELETE /boards/{id}` is the one operation here that really destroys marks — it takes the whole stroke log with it and frees one of the creator's `max_boards_per_creator` seats. `PATCH /boards/{id}` re-titles (any participant) or changes the roster and the lock (creator only). Not in this spec (WebSocket): the live board room at `GET /boards/{id}/ws`, where the drawing itself happens — JSON frames, cookie-authed, and a **404** at the door for anyone not on the board. A `join` replays the current epoch only (chunked `strokes`, then `synced` with the cursor to resume from); a `stroke` is persisted before it is fanned out, so every canvas in the room is showing rows that committed; `clear` and `lock` are the creator's alone and refuse anyone else with `error{code:\"forbidden\"}` *without* closing their socket. The REST mutations above fan out into the same room, and a roster change drops the socket of anyone it removed. See `src/web/board_ws.rs` for the frame-by-frame protocol"), + (name = "boards", description = "Collaborative whiteboards. Anyone **from `student` upwards** opens a board (`POST /boards`) with a title and an ad-hoc invite list of user ids — no course, session or appointment is involved — and every participant draws on it; the creator alone clears, locks, closes or deletes it. The `parent` role has no whiteboard access whatsoever: it is refused `POST /boards` and `GET /boards` with a `403`, and cannot be named in an invite list at all (`400`) — so a parent is never on a roster, which makes every id-scoped route and the room's door answer the outsider's `404` rather than a `403` that would confirm the board exists. A caller who is not on a board gets a `404` for it on every route, existence included, while a participant who is not the creator gets a `403` on those four commands (they are already rendering the board, so hiding it from them would be a lie their client cannot act on). Strokes are **append-only and a clear deletes nothing**: it bumps the board's `epoch`, so the live canvas empties while every mark ever drawn stays stored — `GET /boards/{id}/strokes` is the current epoch (what a client draws to catch up), `GET /boards/{id}/history?epoch=` is the whole session or one named epoch, and `GET /boards/{id}/epochs` is the index of `clear` markers, each carrying the epoch it closed, that epoch's final stroke count, who cleared and when (the markers *are* the index, so the open epoch is deliberately absent from it). Two growth caps, both published at `GET /limits`: `max_epoch_strokes` bounds the *live* canvas and is recoverable (clear it and drawing resumes, losing nothing), while `max_board_strokes` bounds the board's *lifetime* storage and stamps `closed_at` on the way past — a closed board is permanently read-only and fully readable, never deleted, and there is no reopen. `POST /boards/{id}/close` is the manual form of that, and idempotent. `DELETE /boards/{id}` is the one operation here that really destroys marks — it takes the whole stroke log with it and frees one of the creator's `max_boards_per_creator` seats. `PATCH /boards/{id}` re-titles (any participant) or changes the roster and the lock (creator only). Not in this spec (WebSocket): the live board room at `GET /boards/{id}/ws`, where the drawing itself happens — JSON frames, cookie-authed, and a **404** at the door for anyone not on the board. A `join` replays the current epoch only (chunked `strokes`, then `synced` with the cursor to resume from); a `stroke` is persisted before it is fanned out, so every canvas in the room is showing rows that committed; `clear` and `lock` are the creator's alone and refuse anyone else with `error{code:\"forbidden\"}` *without* closing their socket. The REST mutations above fan out into the same room, and a roster change drops the socket of anyone it removed. See `src/web/board_ws.rs` for the frame-by-frame protocol"), (name = "terms", description = "Academic terms (semester/trimester/quarter — whatever the school runs); courses may link to one. A term still linked by any course cannot be deleted (409) — unlink those courses first. Read: any authenticated user; edit: manager+"), ), )] diff --git a/src/web/board_ws.rs b/src/web/board_ws.rs index 2a4f656..bd3ec4f 100644 --- a/src/web/board_ws.rs +++ b/src/web/board_ws.rs @@ -69,6 +69,7 @@ use crate::constant::{BOARD_REPLAY_CHUNK, BOARD_WS_TICK_SECS, MAX_BOARD_ID_LEN}; use crate::database::Database; use crate::domain::board::{Board, BoardId}; use crate::domain::board_stroke::BoardStroke; +use crate::domain::role::Role; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::AppError; @@ -108,9 +109,12 @@ enum ClientMessage { /// Enter the caller's board room. Every gate runs *before* the upgrade so a /// rejection is an HTTP status rather than an instant close: no session (401), -/// and a board that does not exist — or that the caller is not on — is the +/// and a board that does not exist — or that the caller is not on, or that the +/// caller is a `parent` and so barred from the whiteboard outright — is the /// same **404**, because a non-participant must not learn a board exists (the -/// rationale at `src/lib.rs`). +/// rationale at `src/lib.rs`). Refusing the door is also what stops a parent +/// drawing: no socket, no `stroke` frame, and no per-stroke role read on the +/// hot path. pub async fn board_ws( State(st): State, CurrentUser(user): CurrentUser, @@ -120,7 +124,7 @@ pub async fn board_ws( // Length-capped before the key is read back or echoed in a `state` frame. // A key this long names no board, so it answers like any other stranger's // board: 404. - if id.len() > MAX_BOARD_ID_LEN { + if id.len() > MAX_BOARD_ID_LEN || !user.get_role().at_least(Role::Student) { return Err(AppError::NotFound); } let board = Board::read(&BoardId::from_key(&id), &st.db) diff --git a/src/web/boards.rs b/src/web/boards.rs index 9274816..75c0cc4 100644 --- a/src/web/boards.rs +++ b/src/web/boards.rs @@ -3,8 +3,9 @@ //! lock, close, delete). Live drawing itself rides the board-room WebSocket //! next door; everything here is the REST half it sits beside. //! -//! The permission model is two predicates and nothing else -//! ([`Board::is_participant`], [`Board::is_creator`]), applied in one order on +//! The permission model is a role bar plus two predicates +//! (student-and-above, then [`Board::is_participant`], [`Board::is_creator`]), +//! applied in one order on //! every route: a non-participant gets a **404** even for a board that plainly //! exists (a 403 would confirm it — see the rationale at `src/lib.rs`), while a //! participant who is not the creator gets a **403** on the four commands. They @@ -30,11 +31,12 @@ use crate::constant::MAX_BOARD_PARTICIPANTS; use crate::database::Database; use crate::domain::board::{Board, BoardId, BoardTitle}; use crate::domain::board_stroke::BoardStroke; +use crate::domain::role::Role; use crate::domain::user::{User, UserId}; use crate::error::{AppError, ErrorResponse, ValidationError}; use crate::state::AppState; -use super::{CurrentUser, Page, PageParams, paginate, set_or_clear}; +use super::{CurrentUser, Page, PageParams, RequireStudent, paginate, set_or_clear}; pub fn routes() -> OpenApiRouter { OpenApiRouter::new() @@ -53,11 +55,16 @@ pub fn routes() -> OpenApiRouter { /// The board, or a 404 — including the deliberate 404 for a caller who is not /// on it. Every route starts here, so existence never leaks. +/// +/// A `parent` is treated as an outsider rather than refused with a 403: the +/// role is barred from the whiteboard entirely, and a 403 would confirm the +/// board exists. [`resolve_participants`] keeps parents off every roster, so +/// this arm only ever fires for a row written before that rule. async fn board_for(id: &str, user: &User, db: &Database) -> Result { let board = Board::read(&BoardId::from_key(id), db) .await? .ok_or(AppError::NotFound)?; - if !board.is_participant(user.get_id()) { + if !user.get_role().at_least(Role::Student) || !board.is_participant(user.get_id()) { return Err(AppError::NotFound); } Ok(board) @@ -80,6 +87,10 @@ fn ensure_creator(board: &Board, user: &User) -> Result<(), AppError> { /// but only after this loop would have run one read per id), and an unknown id /// is a 400 rather than a silently dropped invitation. /// +/// A `parent` is refused here, and that is the cut that keeps the role off the +/// whiteboard: never on a roster means [`board_for`] and the room's door already +/// answer 404 on every id-scoped route, and no socket can ever open. +/// /// The creator is a participant by construction, so they are neither injected /// into the list nor rejected from it. async fn resolve_participants( @@ -101,10 +112,11 @@ async fn resolve_participants( let mut users = Vec::with_capacity(ids.len()); for id in ids { let user = UserId::from_key(&id); - if User::read(&user, db).await?.is_none() { + let found = User::read(&user, db).await?; + if !found.is_some_and(|found| found.get_role().at_least(Role::Student)) { return Err(AppError::Validation(ValidationError::Invalid { field: "participants", - reason: "every participant must be an existing user", + reason: "every participant must be an existing user of at least the student role", })); } users.push(user); @@ -205,8 +217,10 @@ struct CreateBoard { /// Open a whiteboard. The caller becomes its creator — the only one who may /// clear, lock, close or delete it — and everyone named in `participant_ids` -/// may draw on it. `409` once the caller holds `max_boards_per_creator` boards -/// (`GET /limits`); delete one to free a seat. +/// may draw on it. Student and above: the `parent` role has no whiteboard +/// access at all, neither as a creator nor as a participant. `409` once the +/// caller holds `max_boards_per_creator` boards (`GET /limits`); delete one to +/// free a seat. #[utoipa::path( post, path = "/", @@ -215,14 +229,15 @@ struct CreateBoard { request_body = CreateBoard, responses( (status = 201, description = "The new board", body = BoardResponse), - (status = 400, description = "Invalid title, or a participant list that is too long or names an unknown user", body = ErrorResponse), + (status = 400, description = "Invalid title, or a participant list that is too long, names an unknown user, or names a parent", body = ErrorResponse), (status = 401, description = "Not authenticated", body = ErrorResponse), + (status = 403, description = "The caller is a parent", body = ErrorResponse), (status = 409, description = "The caller already holds the maximum number of boards", body = ErrorResponse), ), )] async fn create_board( State(st): State, - CurrentUser(user): CurrentUser, + RequireStudent(user): RequireStudent, Json(req): Json, ) -> Result<(StatusCode, Json), AppError> { let title = BoardTitle::try_new(&req.title)?; @@ -244,11 +259,12 @@ async fn create_board( (status = 200, description = "A page of the caller's boards", body = Page), (status = 400, description = "Invalid limit or offset", body = ErrorResponse), (status = 401, description = "Not authenticated", body = ErrorResponse), + (status = 403, description = "The caller is a parent", body = ErrorResponse), ), )] async fn list_boards( State(st): State, - CurrentUser(user): CurrentUser, + RequireStudent(user): RequireStudent, Query(page): Query, ) -> Result>, AppError> { let (limit, offset) = page.resolve()?; @@ -426,7 +442,7 @@ struct UpdateBoard { request_body = UpdateBoard, responses( (status = 200, description = "The updated board", body = BoardResponse), - (status = 400, description = "Invalid title, or a participant list that is too long or names an unknown user", body = ErrorResponse), + (status = 400, description = "Invalid title, or a participant list that is too long, names an unknown user, or names a parent", body = ErrorResponse), (status = 401, description = "Not authenticated", body = ErrorResponse), (status = 403, description = "Only the creator may change the participants or the lock", body = ErrorResponse), (status = 404, description = "Not found, or the caller is not on it", body = ErrorResponse), diff --git a/tests/e2e.rs b/tests/e2e.rs index d786505..6fadb91 100644 --- a/tests/e2e.rs +++ b/tests/e2e.rs @@ -2552,6 +2552,72 @@ async fn the_door_is_a_404_for_an_outsider_and_an_unknown_board() { .expect("a participant is let in"); } +/// Test 6b — the door is shut on a `parent` too, and shut the same way: a 404, +/// never a 403. Proved against the hardest case — the parent is forced onto the +/// roster in the database first, so the roster gate would let them in and only +/// the role bar refuses. No socket is the whole point: a parent that cannot +/// upgrade can never send a `stroke` frame, and the store proves nothing landed. +#[tokio::test] +async fn a_parent_cannot_enter_the_room_or_draw() { + let room = board_room_fixture().await; + let (base, board) = (&room.base, &room.board_id); + let anne = client(); + register(&anne, base, "anne").await; + promote(&room.db, "anne", "parent").await; + login(&anne, base, "anne").await; + let cookie = raw_session_cookie(base, "anne").await; + + // On the roster by force — the stale row this rule leaves behind. + let me: Value = anne + .get(format!("{base}/auth/me")) + .send() + .await + .unwrap() + .json() + .await + .unwrap(); + // Beside `veli`, who stays: the two differ only by role, so the refusal + // below cannot be blamed on the roster. + room.db + .query("UPDATE $b SET participants = [$v, $u]") + .bind(("b", board_record(board))) + .bind(( + "v", + surrealdb::types::RecordId::new("user", room.veli_id.clone()), + )) + .bind(( + "u", + surrealdb::types::RecordId::new("user", me["id"].as_str().unwrap().to_string()), + )) + .await + .unwrap() + .check() + .unwrap(); + + assert_eq!( + board_open(base, board, Some(&cookie)).await.err(), + Some(404), + "a parent on the roster must still be told the board does not exist" + ); + // Not a 403 anywhere: identical to a board that was never minted. + assert_eq!( + board_open(base, "01JZZZZZZZZZZZZZZZZZZZZZZZ", Some(&cookie)) + .await + .err(), + Some(404) + ); + // No socket, so no stroke — asserted against the store, not the wire. + assert!( + stored_stroke_ids(&room.db, board, 0).await.is_empty(), + "a parent must not have drawn" + ); + // And the bar is about the role, not the roster: `veli` sits on the same + // roster and is let straight in. + board_open(base, board, Some(&room.veli_cookie)) + .await + .expect("a student participant is still let in"); +} + /// Test 7 — a participant dropped mid-session stops drawing. Twice over: once /// with the roster frame deliberately withheld (the socket's own gate is what /// actually protects the board), and once through the frame the REST route diff --git a/tests/integration.rs b/tests/integration.rs index 36bf61a..66f3ded 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -24249,6 +24249,95 @@ async fn every_board_route_is_a_404_for_an_outsider() { assert_ne!(mine, board); } +/// The `parent` role has no whiteboard at all. Three cuts in one test, because +/// they only work together: a parent cannot open a board, cannot be *named* on +/// one, and — the stale-row case, forced here by writing a parent straight into +/// a roster — still gets the outsider's `404` rather than a `403` that would +/// confirm the board is there. +#[tokio::test] +async fn a_parent_gets_no_whiteboard_at_all() { + let (app, db) = app_and_db().await; + let ali = login(&app, "ali").await; + let anne = login_as(&app, &db, "anne", "parent").await; + let anne_id = me_id(&app, &anne).await; + + // 1. A parent cannot open one. A 403, not a 404: no board exists to hide. + let res = send( + &app, + "POST", + "/boards", + Some(&anne), + Some(json!({ "title": "Gizli", "participant_ids": [] })), + ) + .await; + assert_eq!(res.status, StatusCode::FORBIDDEN, "{}", res.body); + // And nothing was written on the way to that refusal. + assert_eq!(stored_board_count(&db, &anne_id).await, 0); + + // 2. A parent cannot be named on one either — refused whole, so the board + // is not created half-invited. + let res = send( + &app, + "POST", + "/boards", + Some(&ali), + Some(json!({ "title": "Geometri", "participant_ids": [&anne_id] })), + ) + .await; + assert_eq!(res.status, StatusCode::BAD_REQUEST, "{}", res.body); + assert_eq!(stored_board_count(&db, &me_id(&app, &ali).await).await, 0); + + // The same refusal on the way in through PATCH, on a board that does exist. + let board = create_board(&app, &ali, "Geometri", &[]).await; + let res = send( + &app, + "PATCH", + &format!("/boards/{board}"), + Some(&ali), + Some(json!({ "participants": [&anne_id] })), + ) + .await; + assert_eq!(res.status, StatusCode::BAD_REQUEST, "{}", res.body); + assert!( + stored_board(&db, &board) + .await + .unwrap() + .get_participants() + .is_empty(), + "a refused roster change must leave the old roster" + ); + + // 3. The stale row: a parent already on a roster, written before this rule. + // Every id-scoped route must still answer exactly like a board that was + // never minted — a 403 anywhere here leaks the board's existence. + db.query("UPDATE $b SET participants = [$u]") + .bind(("b", BoardId::from_key(&board).record())) + .bind(("u", UserId::from_key(&anne_id).record())) + .await + .unwrap() + .check() + .unwrap(); + let ghost = board_routes("nosuchboard"); + for (n, (method, uri, body)) in board_routes(&board).into_iter().enumerate() { + let res = send(&app, method, &uri, Some(&anne), body).await; + assert_eq!( + res.status, + StatusCode::NOT_FOUND, + "{method} {uri} must 404 for a parent, got {}", + res.body + ); + let (gm, gu, gb) = ghost[n].clone(); + let gone = send(&app, gm, &gu, Some(&anne), gb).await; + assert_eq!(res.status, gone.status, "{method} {uri}"); + assert_eq!(res.body, gone.body, "{method} {uri} bodies must match too"); + } + // The list route is barred outright — nothing to hide, so a 403 is honest. + let res = send(&app, "GET", "/boards", Some(&anne), None).await; + assert_eq!(res.status, StatusCode::FORBIDDEN, "{}", res.body); + // None of it disturbed the board. + assert!(stored_board(&db, &board).await.is_some()); +} + /// The other half of the two-tier line: a participant sees the board and may /// re-title it, but the four commands and the roster/lock arms of `PATCH` are /// the creator's alone — a 403, because hiding a board they are already