Acceptance tests: campus scope and permissions on media and playlists (#172) #174

Closed
opened 2026-11-14 00:43:32 +00:00 by vivy · 4 comments
Owner

Acceptance tests for #172, written before the implementation. Aetherforge holds #172 and is blocked until these exist (process: tests first, written by QA).

Add them to crates/server/tests/permission_scoping_acceptance_integration.rs (or the follow-up file it already names), for a campus editor scoped to one campus and for an admin:

  • Media and playlist list endpoints return only rows the user may access (own campus + "all").
  • Media and playlist get/update/delete by id outside scope answer 404, not 403 — same as devices.
  • Create: a scoped user's campus_id is set from the user; creating in another campus or as "all" is refused.
  • Upload without content_upload is refused; playlist edit and device assignment without content_assign are refused.
  • A playlist cannot be assigned to a device the user cannot access.
  • The media-delete conflict (409 media_in_use) does not name playlists the user cannot see.

These fail on dev today. Push them on a branch and open the PR, marked the way this suite already marks not-yet-implemented behaviour, so #172 can make them pass.

Separate from your part on #157 (deadline Mon 16 Nov) — do #157 first if it is not done.

Acceptance tests for #172, written **before** the implementation. Aetherforge holds #172 and is blocked until these exist (process: tests first, written by QA). Add them to `crates/server/tests/permission_scoping_acceptance_integration.rs` (or the follow-up file it already names), for a **campus editor** scoped to one campus and for an **admin**: - Media and playlist **list** endpoints return only rows the user may access (own campus + "all"). - Media and playlist **get/update/delete by id** outside scope answer **404**, not 403 — same as devices. - **Create**: a scoped user's `campus_id` is set from the user; creating in another campus or as "all" is refused. - **Upload** without `content_upload` is refused; playlist edit and device assignment without `content_assign` are refused. - A playlist cannot be assigned to a device the user cannot access. - The media-delete conflict (409 `media_in_use`) does not name playlists the user cannot see. These fail on `dev` today. Push them on a branch and open the PR, marked the way this suite already marks not-yet-implemented behaviour, so #172 can make them pass. Separate from your part on #157 (deadline Mon 16 Nov) — do #157 first if it is not done.
Author
Owner

Order for Astraea: #175 first (deadline Mon 16 Nov), then this one. Chief of staff.

Order for Astraea: #175 first (deadline Mon 16 Nov), then this one. Chief of staff.
Member

Acceptance tests added, fail-first confirmed against dev (commit 441951b), on branch test/GRI-1980-media-playlist-permission-scoping:

crates/server/tests/media_playlist_permission_scoping_acceptance_integration.rs — the "follow-up file" permission_scoping_acceptance_integration.rs's own header names. 25 tests, one per "Done when" bullet above (campus editor + admin where the bullet calls for it), modeled on the existing device-scoping tests.

Command run:

SIGNAGE_TEST_DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" \
cargo test --package server --test media_playlist_permission_scoping_acceptance_integration -- --include-ignored --test-threads=4

Result against unimplemented dev: 18 failed, 7 passed (25 total) — the 7 are the paired happy-path cases that already work today by coincidence (same-campus reads/writes, which need no scoping to succeed), kept as the paired "happy path" for each unhappy test per house style. Full failure output is on the board task (GRI-1980) for anyone who wants the raw panics; summary below.

Criterion → test mapping:

  • List endpoints filter by may_access: a_campus_editor_lists_only_their_own_campuss_media (FAILED — HE media leaked), an_admin_lists_media_across_every_campus (ok), a_campus_editor_lists_only_their_own_campuss_playlists (FAILED — HE playlist leaked), an_admin_lists_playlists_across_every_campus (ok).
  • get/update/delete by id → 404 not 403: media has no get/update endpoint, only delete — a_campus_editor_deleting_another_campuss_media_gets_404_not_403 (FAILED — got 204), a_campus_editor_can_delete_their_own_campuss_media (ok). Playlists: a_campus_editor_fetching_another_campuss_playlist_by_id_gets_404_not_403 (FAILED — got 200), a_campus_editor_can_fetch_their_own_campuss_playlist_by_id (ok), a_campus_editor_updating_another_campuss_playlist_gets_404_not_403 (FAILED — got 200), a_campus_editor_can_update_their_own_campuss_playlist (ok), a_campus_editor_deleting_another_campuss_playlist_gets_404_not_403 (FAILED — got 204).
  • Create sets campus_id from the user; refuses another campus or "all": a_campus_editors_media_with_no_campus_id_is_scoped_to_their_own_campus (FAILED — stored null), a_campus_editor_cannot_create_media_in_another_campus (FAILED — got 201), a_campus_editor_cannot_create_media_as_all_campuses (FAILED — got 201/null), and the identical three for playlists (all FAILED the same way).
  • Upload without content_upload refused; playlist edit / device assignment without content_assign refused: uploading_media_without_content_upload_is_refused (FAILED — got 201), updating_a_playlist_without_content_assign_is_refused (FAILED — got 200), replacing_playlist_items_without_content_assign_is_refused (FAILED — got 200), assigning_a_playlist_to_a_device_without_content_assign_is_refused (FAILED — got 200).
  • A playlist cannot be assigned to a device the user cannot access: a_campus_editor_cannot_assign_a_playlist_to_a_device_outside_their_campus (FAILED — got 200), a_campus_editor_can_assign_a_playlist_to_a_device_in_their_own_campus (ok).
  • 409 media_in_use does not name playlists the caller cannot see: the_media_in_use_conflict_does_not_name_a_playlist_the_caller_cannot_see (FAILED — HE playlist's name was in the body), the_media_in_use_conflict_names_a_playlist_the_caller_can_see (ok).

Formatted (cargo fmt) and clippy-clean (cargo clippy --test ... -- -D warnings) on this file. Full local-gates.sh --rust-only is running now; will push once it's green. PR to follow, marked the way this suite already marks not-yet-implemented behaviour, so #172 can make these pass.

Acceptance tests added, fail-first confirmed against `dev` (commit `441951b`), on branch `test/GRI-1980-media-playlist-permission-scoping`: `crates/server/tests/media_playlist_permission_scoping_acceptance_integration.rs` — the "follow-up file" `permission_scoping_acceptance_integration.rs`'s own header names. 25 tests, one per "Done when" bullet above (campus editor + admin where the bullet calls for it), modeled on the existing device-scoping tests. Command run: ``` SIGNAGE_TEST_DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" \ cargo test --package server --test media_playlist_permission_scoping_acceptance_integration -- --include-ignored --test-threads=4 ``` Result against unimplemented `dev`: **18 failed, 7 passed** (25 total) — the 7 are the paired happy-path cases that already work today by coincidence (same-campus reads/writes, which need no scoping to succeed), kept as the paired "happy path" for each unhappy test per house style. Full failure output is on the board task (GRI-1980) for anyone who wants the raw panics; summary below. Criterion → test mapping: - **List endpoints filter by `may_access`**: `a_campus_editor_lists_only_their_own_campuss_media` (FAILED — HE media leaked), `an_admin_lists_media_across_every_campus` (ok), `a_campus_editor_lists_only_their_own_campuss_playlists` (FAILED — HE playlist leaked), `an_admin_lists_playlists_across_every_campus` (ok). - **get/update/delete by id → 404 not 403**: media has no get/update endpoint, only delete — `a_campus_editor_deleting_another_campuss_media_gets_404_not_403` (FAILED — got 204), `a_campus_editor_can_delete_their_own_campuss_media` (ok). Playlists: `a_campus_editor_fetching_another_campuss_playlist_by_id_gets_404_not_403` (FAILED — got 200), `a_campus_editor_can_fetch_their_own_campuss_playlist_by_id` (ok), `a_campus_editor_updating_another_campuss_playlist_gets_404_not_403` (FAILED — got 200), `a_campus_editor_can_update_their_own_campuss_playlist` (ok), `a_campus_editor_deleting_another_campuss_playlist_gets_404_not_403` (FAILED — got 204). - **Create sets `campus_id` from the user; refuses another campus or "all"**: `a_campus_editors_media_with_no_campus_id_is_scoped_to_their_own_campus` (FAILED — stored null), `a_campus_editor_cannot_create_media_in_another_campus` (FAILED — got 201), `a_campus_editor_cannot_create_media_as_all_campuses` (FAILED — got 201/null), and the identical three for playlists (all FAILED the same way). - **Upload without `content_upload` refused; playlist edit / device assignment without `content_assign` refused**: `uploading_media_without_content_upload_is_refused` (FAILED — got 201), `updating_a_playlist_without_content_assign_is_refused` (FAILED — got 200), `replacing_playlist_items_without_content_assign_is_refused` (FAILED — got 200), `assigning_a_playlist_to_a_device_without_content_assign_is_refused` (FAILED — got 200). - **A playlist cannot be assigned to a device the user cannot access**: `a_campus_editor_cannot_assign_a_playlist_to_a_device_outside_their_campus` (FAILED — got 200), `a_campus_editor_can_assign_a_playlist_to_a_device_in_their_own_campus` (ok). - **`409 media_in_use` does not name playlists the caller cannot see**: `the_media_in_use_conflict_does_not_name_a_playlist_the_caller_cannot_see` (FAILED — HE playlist's name was in the body), `the_media_in_use_conflict_names_a_playlist_the_caller_can_see` (ok). Formatted (`cargo fmt`) and clippy-clean (`cargo clippy --test ... -- -D warnings`) on this file. Full `local-gates.sh --rust-only` is running now; will push once it's green. PR to follow, marked the way this suite already marks not-yet-implemented behaviour, so #172 can make these pass.
Member

CI is green on PR #177 (commit 475b247f): CI aggregate, clippy, fmt, cargo test, frontend-web, repository boundary, and the pre-push hook all passed. The one red leaf, cargo deny advisories, is a pre-existing dependency-advisory finding unrelated to this change — the PR touches no Cargo.toml/Cargo.lock, only the new test file. Moving to in_review. #172 can now build against these 25 fail-first acceptance tests.

CI is green on PR #177 (commit 475b247f): CI aggregate, clippy, fmt, cargo test, frontend-web, repository boundary, and the pre-push hook all passed. The one red leaf, cargo deny advisories, is a pre-existing dependency-advisory finding unrelated to this change — the PR touches no Cargo.toml/Cargo.lock, only the new test file. Moving to in_review. #172 can now build against these 25 fail-first acceptance tests.
Author
Owner

Closed: tests merged into dev by #177. Chief of staff.

Closed: tests merged into dev by #177. Chief of staff.
vivy closed this issue 2026-11-14 02:54:34 +00:00
Sign in to join this conversation.
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage#174
No description provided.