|
| 1 | +--- |
| 2 | +name: unit-tests-security-authz-template |
| 3 | +description: Provides a repeatable case template for auth, permission, and security-sensitive unit tests in Metaboost. Use when testing JWT, assertion validation, cookie/session helpers, bucket policy, or similar allow/deny logic. |
| 4 | +version: 1.0.0 |
| 5 | +--- |
| 6 | + |
| 7 | +# Unit Tests - Security/Authz Template |
| 8 | + |
| 9 | +## Use This Skill When |
| 10 | + |
| 11 | +- Testing auth token helpers and claim validation. |
| 12 | +- Testing permission policy (bucket/admin/role/message CRUD decisions). |
| 13 | +- Testing security-sensitive request binding and replay controls. |
| 14 | + |
| 15 | +## Standard Case Template |
| 16 | + |
| 17 | +For each function/module, cover these case buckets: |
| 18 | + |
| 19 | +1. **Accept valid input** |
| 20 | + - Confirm expected allow/success behavior. |
| 21 | +2. **Reject invalid input** |
| 22 | + - Missing/empty/malformed token, claim, id, or mask. |
| 23 | +3. **Enforce boundary rule** |
| 24 | + - Time window, max TTL, min/max limits, bitmask edge. |
| 25 | +4. **Enforce deny precedence** |
| 26 | + - Non-owner/non-admin or missing permission bit remains denied. |
| 27 | +5. **Preserve safe failure** |
| 28 | + - Errors return non-privileged result (`null`, `false`, or explicit reject response). |
| 29 | + |
| 30 | +## Assertions Checklist |
| 31 | + |
| 32 | +- Assert on outcome and error code/message contract where relevant. |
| 33 | +- Verify no accidental allow behavior in negative paths. |
| 34 | +- Keep fixtures minimal and explicit. |
| 35 | +- Mock only unstable boundaries (network, time, cache, external services). |
| 36 | + |
| 37 | +## Matrix Update Rule |
| 38 | + |
| 39 | +When introducing a new auth/authz/security module: |
| 40 | + |
| 41 | +1. Add the module to the active test target matrix plan. |
| 42 | +2. Add at least one test from each relevant case bucket above. |
| 43 | +3. Record any intentionally deferred cases and why they are lower priority. |
0 commit comments