production · 27 minute study
Turn access claims into falsifiable tests
The dangerous test is one that passes because it never attempted the forbidden action. Security evidence must name the actor, path, expected outcome and unchanged state.
Useful preparation · 2 prerequisites
Use this as a map, not a lock. If these ideas are familiar, continue.
- An RPC is an exposed function, not a permission shortcut — A database function can put related work into one boundary. It can also accidentally expose privileged behavior if the caller and execution context are not understood.
- Reconcile claims against evidence — A status label can say paid while the underlying evidence disagrees. Engineering needs an independent way to detect impossible or unexplained state.
First, build a mental model
An access claim is a matrix of allowed and denied cases. A useful test tries to break one invariant and checks both the response and the resulting data.
- Keep fixture setup separate from the tested actor. A privileged client may create synthetic test data but must not perform the supposedly ordinary-user request.
- Test SELECT, INSERT, UPDATE and DELETE separately; include foreign IDs, mixed-company references, proposed owner/company changes and missing or stale identity.
- Assert outcomes precisely: permission error, policy error, filtered empty result, expected row count and unchanged forbidden rows are not interchangeable.
- The local simulator verifies its own model. Real acceptance needs disposable PostgreSQL/Supabase execution through the intended API/RPC, effective grants/policies and a reviewed candidate.
[
{"actor":"alice","operation":"SELECT A note","expect":"visible"},
{"actor":"alice","operation":"SELECT B note","expect":"filtered"},
{"actor":"guest","operation":"INSERT private note","expect":"denied"},
{"actor":"alice","operation":"UPDATE A note into B","expect":"denied"},
{"actor":"alice","operation":"UPDATE B note by ID","expect":"zero affected"},
{"actor":"alice","operation":"repeat accepted request","expect":"same effect once"}
]- Contract
State expected access independently from the implementation being tested.
- Adversarial action
Submit the foreign ID or changed company through the same boundary a real caller uses.
- Evidence
Preserve actor, revision, response, affected-row count and the forbidden row's unchanged state.
Production thinking
Take this beyond the example.
Report IMPLEMENTED, TESTED, BUILT and DEPLOYED separately. List blocked or unrun proofs honestly. Do not weaken policy expectations or use bypass roles to obtain a green result.
Sources and further reading
Your evidence
unseen is a local learning signal, not a credential or proof of production competence.
Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.
Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.