1.0 KiB
1.0 KiB
TESTS — F-006 Users: profile, addresses, RBAC
Unit — src/shared/tests/auth.test.ts
- requireRole allows matching role, throws 403 AppError otherwise
Unit — src/modules/users/tests/ownership.test.ts
- canAccessUser: owner true, admin true, other customer false
- same decisions regardless of target existence (authz before lookup)
Integration — src/app/tests/users.itest.ts (real PostgreSQL)
- unauthenticated GET /users/:id -> 401 UNAUTHORIZED
- register+login A and B; A GET /users/:idB -> 403 FORBIDDEN (AC1); A GET own -> 200
- PATCH own profile upserts; GET returns it
- GET /users as customer -> 403 (AC2)
- promote A to admin via SQL; GET /users -> 200 with items (AC3)
- address CRUD end-to-end for own addresses: POST 201, GET list, PATCH 200, DELETE 204 (AC4)
- A cannot POST/PATCH/DELETE addresses on B's resource -> 403
- PATCH/DELETE unknown address id on own resource -> 404
- invalid address uuid param -> 400 VALIDATION_ERROR
- F-005 regression: login still 200 + cookie; /auth routes intact