GRI-1997: acceptance tests for global and per-campus playback settings, with fallback #179

Merged
vivy merged 1 commit from test/GRI-1997-settings-acceptance-tests into dev 2026-11-14 04:57:04 +00:00
Member

Acceptance tests for #161, written before the implementation. All 16 tests
are new, live in crates/server/tests/settings_playback_acceptance_integration.rs,
and run against a real Postgres (SIGNAGE_TEST_DATABASE_URL). No production
code is touched.

Command

SIGNAGE_TEST_DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" \
  cargo test -p server --test settings_playback_acceptance_integration -- --include-ignored --test-threads=1

Fail-first

Run against the current, unimplemented code (no playback_settings table, no
/api/v1/settings/playback or /api/v1/campuses/{id}/settings/playback
routes): 0 passed; 16 failed, every failure a 404 (route does not exist
yet) or, for the two existing-global-settings tests, a 200 where a 403 is
required (today's gap). Full output in the test run.

Criterion → test

  • Global GET/PUT succeeds for an unscoped settings_manage user →
    global_put_and_get_succeed_for_an_unscoped_settings_manage_user
  • Global GET refused 403 for a campus-scoped settings_manage user →
    global_get_is_refused_403_for_a_campus_scoped_settings_manage_user
  • Global PUT refused 403 for a campus-scoped settings_manage user →
    global_put_is_refused_403_for_a_campus_scoped_settings_manage_user
  • Campus GET with no override returns the global value, source: "global" →
    campus_get_with_no_override_returns_the_global_value_and_source
  • Campus GET after a campus PUT returns the campus value, source: "campus" →
    campus_get_after_a_campus_put_returns_the_campus_value_and_source
  • Campus GET after clearing the override (null) falls back to global again →
    campus_get_after_clearing_the_override_falls_back_to_global_again
  • Campus GET for a different campus is 404, not 403 →
    campus_get_for_another_campus_is_404_not_403
  • Campus GET for an unknown campus id is 404 →
    campus_get_for_an_unknown_campus_is_404
  • Campus PUT for a different campus is 404, not 403 →
    campus_put_for_another_campus_is_404_not_403
  • Campus PUT for an unknown campus id is 404 →
    campus_put_for_an_unknown_campus_is_404
  • An unscoped user may read a campus that is not their own →
    an_unscoped_user_may_read_a_campus_that_is_not_their_own
  • An unscoped settings_manage user may write a campus that is not their own →
    an_unscoped_settings_manage_user_may_write_a_campus_that_is_not_their_own
  • Global PUT with default_duration_seconds <= 0 is 400 invalid_duration,
    nothing written →
    a_non_positive_global_duration_is_refused_and_nothing_is_written
  • Campus PUT with default_duration_seconds <= 0 is 400 invalid_duration,
    nothing written →
    a_non_positive_campus_duration_is_refused_and_nothing_is_written
  • The existing GET /api/v1/settings gap: a campus-scoped settings_manage
    user is refused 403 →
    a_campus_scoped_settings_manage_user_is_refused_403_from_the_existing_global_settings_get
  • The existing PUT /api/v1/settings gap: a campus-scoped settings_manage
    user is refused 403 →
    a_campus_scoped_settings_manage_user_is_refused_403_from_the_existing_global_settings_put

Not in scope here

Writing the migration, the handlers, or the may_access/403-vs-404 fix in
crates/server/src/settings.rs — that is implementation and belongs to the
back-end engineer. The proposed contract (route shapes, the 0007 migration,
the 404-not-403 convention) is in the forge issue; flag there if any test
assumes a shape that should change before it's built against.

Acceptance tests for #161, written before the implementation. All 16 tests are new, live in `crates/server/tests/settings_playback_acceptance_integration.rs`, and run against a real Postgres (`SIGNAGE_TEST_DATABASE_URL`). No production code is touched. ## Command ``` SIGNAGE_TEST_DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" \ cargo test -p server --test settings_playback_acceptance_integration -- --include-ignored --test-threads=1 ``` ## Fail-first Run against the current, unimplemented code (no `playback_settings` table, no `/api/v1/settings/playback` or `/api/v1/campuses/{id}/settings/playback` routes): **0 passed; 16 failed**, every failure a 404 (route does not exist yet) or, for the two existing-global-settings tests, a 200 where a 403 is required (today's gap). Full output in the test run. ## Criterion → test - Global GET/PUT succeeds for an unscoped `settings_manage` user → `global_put_and_get_succeed_for_an_unscoped_settings_manage_user` - Global GET refused 403 for a campus-scoped `settings_manage` user → `global_get_is_refused_403_for_a_campus_scoped_settings_manage_user` - Global PUT refused 403 for a campus-scoped `settings_manage` user → `global_put_is_refused_403_for_a_campus_scoped_settings_manage_user` - Campus GET with no override returns the global value, `source: "global"` → `campus_get_with_no_override_returns_the_global_value_and_source` - Campus GET after a campus PUT returns the campus value, `source: "campus"` → `campus_get_after_a_campus_put_returns_the_campus_value_and_source` - Campus GET after clearing the override (`null`) falls back to global again → `campus_get_after_clearing_the_override_falls_back_to_global_again` - Campus GET for a different campus is 404, not 403 → `campus_get_for_another_campus_is_404_not_403` - Campus GET for an unknown campus id is 404 → `campus_get_for_an_unknown_campus_is_404` - Campus PUT for a different campus is 404, not 403 → `campus_put_for_another_campus_is_404_not_403` - Campus PUT for an unknown campus id is 404 → `campus_put_for_an_unknown_campus_is_404` - An unscoped user may read a campus that is not their own → `an_unscoped_user_may_read_a_campus_that_is_not_their_own` - An unscoped `settings_manage` user may write a campus that is not their own → `an_unscoped_settings_manage_user_may_write_a_campus_that_is_not_their_own` - Global PUT with `default_duration_seconds <= 0` is `400 invalid_duration`, nothing written → `a_non_positive_global_duration_is_refused_and_nothing_is_written` - Campus PUT with `default_duration_seconds <= 0` is `400 invalid_duration`, nothing written → `a_non_positive_campus_duration_is_refused_and_nothing_is_written` - The existing `GET /api/v1/settings` gap: a campus-scoped `settings_manage` user is refused 403 → `a_campus_scoped_settings_manage_user_is_refused_403_from_the_existing_global_settings_get` - The existing `PUT /api/v1/settings` gap: a campus-scoped `settings_manage` user is refused 403 → `a_campus_scoped_settings_manage_user_is_refused_403_from_the_existing_global_settings_put` ## Not in scope here Writing the migration, the handlers, or the `may_access`/403-vs-404 fix in `crates/server/src/settings.rs` — that is implementation and belongs to the back-end engineer. The proposed contract (route shapes, the 0007 migration, the 404-not-403 convention) is in the forge issue; flag there if any test assumes a shape that should change before it's built against.
GRI-1997: acceptance tests for global and per-campus playback settings, with fallback
Some checks failed
CI / the pre-push hook (pull_request) Successful in 13s
CI / cargo fmt (pull_request) Successful in 13s
CI / cargo deny advisories (pull_request) Failing after 2m5s
CI / cargo deny (pull_request) Successful in 2m6s
CI / cargo clippy (pull_request) Successful in 3m4s
CI / repository boundary (pull_request) Successful in 59s
CI / cargo test (pull_request) Successful in 4m17s
CI / frontend-web (pull_request) Successful in 1m57s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 14s
581b5d99c1
vivy merged commit 7caf3240dc into dev 2026-11-14 04:57:04 +00:00
vivy deleted branch test/GRI-1997-settings-acceptance-tests 2026-11-14 04:57:05 +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!179
No description provided.