normogen/backend/tests
goose ff185a60e4
All checks were successful
Lint and Build / format (pull_request) Successful in 38s
Lint and Build / clippy (pull_request) Successful in 1m40s
Lint and Build / build (pull_request) Successful in 3m46s
Lint and Build / test (pull_request) Successful in 4m0s
fix(security): enforce ownership on medication/appointment write paths (#12)
The update/delete handlers for medications and appointments took the
auth Claims but never used them — any authenticated user could update
or delete any other user's records by id (an IDOR). Same gap on
log_dose (could skew another's adherence stats) and get_adherence
(leaked dose history).

Fix: each affected handler now looks up the item first and confirms
user_id == claims.sub before mutating/returning. Mismatches return 404
(not 403) to avoid leaking the existence of other users' records.
Recipients of shared profiles remain read-only per the ADR — writes
stay owner-only.

Covered handlers:
- update_medication, delete_medication, log_dose, get_adherence
- update_appointment, delete_appointment

health_stats update/delete were already checking user_id == claims.sub
(unaffected).

New ownership_tests.rs: cross-user update/delete/log-dose/adherence all
404; the legitimate owner can still do all of the above.

Verification: cargo build/clippy (-D warnings)/fmt clean; existing
tests unaffected (they operate as the same user that created the data).

Closes #12.
2026-07-19 12:00:13 -03:00
..
common feat(backend): dose scheduling + health stats zero-knowledge 2026-07-04 08:41:48 -03:00
auth_tests.rs feat(auth): add per-account X25519 identity keypair (#3) 2026-07-18 20:00:01 -03:00
medication_tests.rs test: E2E ZK integration tests + frontend lifecycle test 2026-07-05 00:35:33 -03:00
ownership_tests.rs fix(security): enforce ownership on medication/appointment write paths (#12) 2026-07-19 12:00:13 -03:00
profile_tests.rs feat: per-profile DEKs + multi-profile (Phase A2, #3) 2026-07-18 23:45:01 -03:00
share_tests.rs test(share): fix query-string encoding + write-status assertion 2026-07-19 10:37:40 -03:00
zk_integration_tests.rs feat: per-profile DEKs + multi-profile (Phase A2, #3) 2026-07-18 23:45:01 -03:00