freshyo/docs/test-cases/authorization-api-contracts.md
2026-10-18 10:59:18 +05:30

5.3 KiB

Authorization, isolation and API contracts

Scope: all public/customer/staff/superadmin procedures, ownership, current staff assignments and mutation failures. These are direct API checks; hidden screens do not prove enforcement.

Identity matrix

For each relevant route, test anonymous, U1, U2, staff A, staff B, superadmin, expired token and deleted/reassigned identity. Public discovery is public; customer private data is owner-scoped; regional operations are staff-region-scoped; global authoring/configuration is superadmin-only. Exact staff-role privileges need a documented policy matrix, not assumed universal access.

ID Priority Action / input Expected result
SEC-01 P0 Anonymous/customer calls every admin/superadmin mutation. Denied before DB/assets/job writes; no private payload.
SEC-02 P0 Regional staff calls superadmin region/staff/global CRUD/config. No escalation, including legacy global-config endpoints.
SEC-03 P0 Staff B probes A product/store/slot/tag/group/banner/coupon IDs. Read/write/delete denied; no existence-sensitive private content.
SEC-04 P0 Authorized A object save with B SKU/store/group/related IDs. Entire invalid association rejected without hidden partial writes.
SEC-05 P0 U2 probes U1 address/order/complaint/coupon IDs. Ownership always enforced on every customer-private surface.
SEC-06 P0 Forged/expired/malformed JWT, altered identity/region/role fields. Verification fails; no default or fallback privilege.
SEC-07 P0 Removed staff/deleted user token; staff reassigned A→B. Current identity/assignment enforced; old region claim not trusted alone.
SEC-08 P0 Regional edit of global product structural fields/global suspension. Only authorized market fields writable; globally shared structure protected.
SEC-09 P0 Public catalog/detail/summary upload/token routes inspected. Only intended public fields/contexts; no internal notes or credentials.
SEC-10 P0 Mixed-region checkout and foreign address-bound pairing. Coherent region/address/SKU/slot/bound validation; no fee manipulation.
SEC-11 P0 Item packaging with unrelated item ID or vendor authority. Item association/allowed snippet scope checked server-side.
SEC-12 P0 Invalid/empty ID, whitespace/numeric-prefix string, huge/nonfinite IDs. Schema rejects malformed identity; no accidental parseInt target.
SEC-13 P1 Unknown key, wrong-scope constant key, incorrect type, null vs omission. Contract explicit; unexpected write fields don't bypass restrictions.
SEC-14 P0 Customer-supplied money, creator ID, user ID, cancellation actor. Server-owned fields not trusted; financial/audit identity correct.
SEC-15 P0 Business rejection OOS/full slot/protected delete/invalid coupon. Correct actionable 4xx/error contract, no misleading 500 or success.
SEC-16 P0 Failure at each relation/image/status write boundary. No partial row or asset deletion; unauthorized scope untouched.
SEC-17 P1 Duplicate deletes/toggles/cancels, concurrent conflicting requests. Defined conflict/idempotence; no duplicate financial/history side effects.
SEC-18 P0 Limited-use coupon and reserved redemption races. Authoritative one-time/per-user invariants; no overuse/dual claim.
SEC-19 P1 Large arrays/string payloads and unsupported query/page limits. Bounded safe validation; no dropped/partial unreported batches.
SEC-20 P0 Script/HTML in names/notes/links/filenames. Safe rendering/navigation/storage; no script execution or arbitrary object delete.
SEC-21 P0 SQL-special strings/filter/order input. Parameterized/safe handling; no injection or unintended query scope.
SEC-22 P0 Private response/error/log inspection. No password hashes, signed secrets, full tokens, other-user PII.
SEC-23 P1 Untrusted browser origin and supported CORS/auth transport. Approved origin policy; credential handling secure; no unintended cross-origin mutation.
SEC-24 P1 Repeated auth/code requests in approved bounded harness. Approved rate/abuse controls; no real SMS/notification flood.
SEC-25 P0 Reads/mutations after UI logout or account switch with cached queries. Private stale data cleared; API still denies unauthorized access.
SEC-26 P1 Public health/legacy operational/deep-link routes. Sensitive operations require intended authority, not merely knowledge of URL.
SEC-27 P1 Authorization failure followed by valid retry. No poisoned transaction/loading guard; valid request succeeds once.
SEC-28 P0 Customer token calls admin getStaff, createStaffUser, getRoles and savePushToken directly. Staff-only expectation: denied before any staff/role data or write. If customers are intentionally allowed, document it and downgrade the case.

Evidence requirements

For each denial, record sanitized status/body plus target and sibling pre/post values. For list authorization, test filters, pagination and direct-ID endpoints, not only the default list. For global entities, distinguish intentionally public/shared structural reads from prohibited writes. Record capacity and order-idempotency deferred policies separately; do not replace specified one-time coupon protections with characterization of an existing race.