Acceptance tests: settings global and per-campus, with fallback (#161) #178
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage#178
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Acceptance tests for #161, written before the implementation (process: tests first, written by QA, same as #172/#174).
Scope
Playback defaults only, to start:
default_duration_seconds, the field playlists already require ([crates/server/src/playlists/handlers.rs],validate_duration: must be> 0). Two levels — global (one value, server-wide) and per campus (optional override) — with the campus falling back to global when unset.Proposed contract (mine to build; flag here if the shape is wrong before you write against it)
New table, migration
0007:playback_settings(campus_id UUID NULL UNIQUE REFERENCES campus(id) ON DELETE CASCADE, default_duration_seconds INTEGER NOT NULL),campus_id IS NULLis the single global row (a partial unique index guards there only ever being one). SameNULL= "global" conventioncrate::campusalready uses.GET /api/v1/settings/playback— the global default. Requiressettings_manageandcampus_id IS NULLon the caller (unscoped admin or unscopedsettings_manageholder). A campus-scoped caller gets 403, same wording as the existingsettings.manage is requiredon/api/v1/settings.PUT /api/v1/settings/playback— body{"default_duration_seconds": 10}, same permission as the GET,400 invalid_durationwhen<= 0.GET /api/v1/campuses/{campus_id}/settings/playback— the effective value for that campus:{"default_duration_seconds": {"value": 15, "source": "campus"|"global"}}. Any signed-in user may read their own campus; an admin or an unscoped user may read any. A campus-scoped caller naming a different campus, or an unknown campus id, both get 404 — not 403, same rule #172/#174 already use for media/playlists outside scope.PUT /api/v1/campuses/{campus_id}/settings/playback— requiressettings_manageandmay_access(Some(campus_id))(crate::auth::CurrentUser::may_access). Body{"default_duration_seconds": 20}sets an override;{"default_duration_seconds": null}clears it (falls back to global). Same 404-not-403 for out-of-scope/unknown campus, same400 invalid_durationfor<= 0.A gap this closes, worth its own test
Today
SetupOrSignedIn(crates/server/src/settings.rs) lets anysettings_manageholder see and change the existing global-only settings (GET/PUT /api/v1/settings,/api/v1/server/restart, the setup-wizard database routes) — it checksmay(SettingsManage)but nevercampus_id.is_none(). A campus-scoped admin withsettings_managecan today read and rewrite the server's reverse-proxy/public-URL/mail/sign-in settings. Please add a test that a campus-scopedsettings_manageuser gets 403 fromGET/PUT /api/v1/settingsonce this lands — that's "only a user with the global-settings permission sees global settings" from the done-when.Test scenarios
settings_manageuser succeeds; a campus-scopedsettings_manageuser gets 403 on both.source: "global"and the global value; after a PUT with a value, returnssource: "campus"and that value; after a PUT withnull, back tosource: "global".campus_id: None) may act on any campus, including one not their own.PUTwithdefault_duration_seconds <= 0on either endpoint:400 invalid_duration, nothing written.GET/PUT /api/v1/settings(existing global settings): a campus-scopedsettings_manageuser is refused 403 (the gap above).Put these wherever the existing settings tests already live (
crates/server/src/settings.rs's own#[cfg(test)] mod tests, or a newcrates/server/tests/...integration file if you'd rather keep campus-scoping tests together with #172/#174's) — your call on the file. Push on a branch and open the PR, marked the way the suite already marks not-yet-implemented behaviour, so #161 can make them pass.Tests are up on PR #179 (test/GRI-1997-settings-acceptance-tests -> dev): 16 acceptance tests in crates/server/tests/settings_playback_acceptance_integration.rs, one per scenario bullet above.
Fail-first, run against the current (unimplemented) code: 0 passed, 16 failed -- every failure is a 404 (route/table does not exist) or, for the two existing-/api/v1/settings-gap tests, a 200 where a 403 is required.
CI on the PR: green, except CI / cargo deny advisories, which is a pre-existing failure on dev itself, unrelated to this change (GRI-1872: gtk-renderer feature advisories, red on every branch). My branch touches only the new test file and no dependency tree.
Proposed route/migration contract is still above for the back-end engineer to flag against if the shape needs to change. Closing this issue -- tests are written and verified fail-first. Handing off to the CTO to release implementation.