GRI-1971: acceptance tests for permission scoping on reads #166
No reviewers
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage!166
Loading…
Reference in a new issue
No description provided.
Delete branch "test/GRI-1971-permission-scoping-reads"
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?
What
Acceptance tests for permission scoping on reads, written independently of
any implementation (there is none yet — forge #44 is open, just released to
the back-end engineer, target Monday 16 Nov).
crates/server/tests/permission_scoping_acceptance_integration.rscovers,against the current, concrete contract settled today on forge #159/#44 and
the
plandocument onGRI-1960:GET /devicesnever lists another campus's devices.404,not
403— the caller must not learn the object exists.paired happy path).
GET /ip-rulesis refused with403— the IP tab isadmin-only, not a campus-scoping question.
can still read the IP rules (two more paired happy paths).
Fail-first evidence
Against
devatafe0f41, with a realPostgreSQL:The three failures are exactly the missing feature (every
_current: CurrentUserindevices/handlers.rsis unused today — no permission orcampus check runs at all). The three passes are controls, proving the test
harness and fixtures are sound independent of the feature under test.
Criterion-to-test mapping
planon GRI-1960)rest-api.md, "Scoping applies to reads")a_campus_editor_lists_only_their_own_campuss_devicesan_admin_lists_devices_across_every_campusa_campus_editor_fetching_another_campuss_device_by_id_gets_404_not_403a_campus_editor_can_fetch_their_own_campuss_device_by_ida_campus_editor_cannot_list_ip_rulesan_admin_can_list_ip_rulesSchema assumption — needs the back-end engineer's confirmation
No role or campus assignment exists on
usersindev. To run at all, thesetests assume
users.role('admin'/'campus_editor') andusers.campus_id(nullable,NULL= all), mirroring the existing nullablecampus_idconvention for every other campus-owned table. This file addsthose two columns to its own per-test database only (
ALTER TABLEinadd_role_and_campus_columns), not tocrates/server/migrations/— thatmigration is #44's design decision, not this file's. If the real shape
differs, only
insert_scoped_userand that one helper need to change; everyassertion tests the public HTTP contract and does not.
Not covered here (follow-up)
/api/v1/mediaand/api/v1/playlistsneed the identical list- andget-by-id-scoping tests (forge #159 says so explicitly). Left out to keep
this file focused on one resource.
/api/v1/settingsbeing hidden from a non-admin needsSettingsState(a full
Config, a settings file, aRestarter) — enough extra fixtureweight to deserve its own file.
GET /api/v1/sessiondoes not expose the caller's permissions yet(
UserViewcarries onlyid/email/name), thoughrest-api.mdsays itmust. Noted as a finding in the file header, not asserted — there is no
field name yet to assert on.
Test plan
cargo test -p server --test permission_scoping_acceptance_integration -- --include-ignoredagainst a real Postgres: 3 pass (controls), 3 fail (the unimplemented feature, as expected)cargo fmt -p server -- --checkcargo clippy -p server --test permission_scoping_acceptance_integration --all-targets -- -D warningscargo test -p server(the rest of the crate's suite, unaffected)