GRI-1977: campus scope and permissions on media and playlists #180

Merged
vivy merged 4 commits from feature/GRI-1977-campus-media-playlist-permissions into dev 2026-11-14 04:56:59 +00:00
Member

Follow-up to #44 (PR #168). Implements campus scope and permissions on media and playlists (issue #172).

  • list_media/list_playlists: filtered by current.may_access(campus_id).
  • get_playlist/update_playlist/delete_playlist/delete_media: cross-campus direct id now reads 404, matching the device convention.
  • Create (upload_media, add_url_media, create_playlist): added campus::validate_for_create — an "every campus" request is narrowed to the caller's own campus, a different campus is refused.
  • Permission checks: ContentUpload on upload_media/add_url_media/create_playlist; ContentAssign on update_playlist, replace_items, assign_playlist.
  • assign_playlist: 404 when the device or the playlist is outside the caller's campus.
  • media_in_use_error: filters playlists_referencing by current.may_access, so the 409 conflict never names a playlist in another campus.
  • Test teardown fix: the acceptance test's fresh_pool guard now drops its per-test database via DROP DATABASE ... WITH (FORCE) on panic too.
  • Dropped #[ignore] from the campus-scoping acceptance tests (#174/PR #177) so CI actually runs them.

Built against Astraea's acceptance tests on test/GRI-1980-media-playlist-permission-scoping (PR #177, merged into dev).

Test plan

  • cargo test -p server --test media_playlist_permission_scoping_acceptance_integration --test permission_scoping_acceptance_integration -- --include-ignored --test-threads=1: 31 passed, 0 failed.
  • cargo build -p server and cargo clippy -p server --all-targets: clean.
  • Full ./scripts/local-gates.sh: every gate passed (run in the foreground this time, log at /workspace/scratch/aetherforge/GRI-1977/local-gates.log).
Follow-up to #44 (PR #168). Implements campus scope and permissions on media and playlists (issue #172). - `list_media`/`list_playlists`: filtered by `current.may_access(campus_id)`. - `get_playlist`/`update_playlist`/`delete_playlist`/`delete_media`: cross-campus direct id now reads `404`, matching the device convention. - Create (`upload_media`, `add_url_media`, `create_playlist`): added `campus::validate_for_create` — an "every campus" request is narrowed to the caller's own campus, a different campus is refused. - Permission checks: `ContentUpload` on `upload_media`/`add_url_media`/`create_playlist`; `ContentAssign` on `update_playlist`, `replace_items`, `assign_playlist`. - `assign_playlist`: 404 when the device or the playlist is outside the caller's campus. - `media_in_use_error`: filters `playlists_referencing` by `current.may_access`, so the 409 conflict never names a playlist in another campus. - Test teardown fix: the acceptance test's `fresh_pool` guard now drops its per-test database via `DROP DATABASE ... WITH (FORCE)` on panic too. - Dropped `#[ignore]` from the campus-scoping acceptance tests (#174/PR #177) so CI actually runs them. Built against Astraea's acceptance tests on `test/GRI-1980-media-playlist-permission-scoping` (PR #177, merged into dev). ## Test plan - `cargo test -p server --test media_playlist_permission_scoping_acceptance_integration --test permission_scoping_acceptance_integration -- --include-ignored --test-threads=1`: 31 passed, 0 failed. - `cargo build -p server` and `cargo clippy -p server --all-targets`: clean. - Full `./scripts/local-gates.sh`: every gate passed (run in the foreground this time, log at `/workspace/scratch/aetherforge/GRI-1977/local-gates.log`).
Filters media/playlist lists by current.may_access; cross-campus
get/update/delete now reads 404 not 403, same as devices. Create
(upload, url, playlist) forces a campus-scoped caller's own campus_id
via campus::validate_for_create rather than accepting a different
campus or every campus. Adds ContentUpload checks on upload_media,
add_url_media and create_playlist; ContentAssign checks on
update_playlist, replace_items and assign_playlist. assign_playlist
404s when the device or the playlist is outside the caller's campus.
media_in_use_error filters playlists_referencing by may_access so the
409 conflict never names a playlist in another campus.
The acceptance suite's fresh_pool created a database per test and never
dropped it (GRI-1984: 2,512 had piled up and filled the shared Postgres's
/dev/shm). Wraps the pool in a guard whose Drop runs DROP DATABASE ...
WITH (FORCE) on a dedicated thread, so it fires on panic too and does not
need a nested Tokio runtime.
GRI-1977: drop #[ignore] from campus scoping acceptance tests so CI runs them
Some checks failed
CI / the pre-push hook (pull_request) Successful in 11s
CI / cargo fmt (pull_request) Successful in 11s
CI / cargo deny advisories (pull_request) Failing after 1m53s
CI / cargo clippy (pull_request) Successful in 2m14s
CI / cargo deny (pull_request) Successful in 2m7s
CI / repository boundary (pull_request) Successful in 1m5s
CI / cargo test (pull_request) Successful in 4m8s
CI / frontend-web (pull_request) Successful in 2m52s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 41s
3a3974ffe6
vivy merged commit 3b630d6647 into dev 2026-11-14 04:56:59 +00:00
vivy deleted branch feature/GRI-1977-campus-media-playlist-permissions 2026-11-14 04:56:59 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
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!180
No description provided.