Testing policies
Authorization bugs are security bugs. ZStrike’s testing tools let you prove policy behavior before a policy is live in front of your application.
The simulator
Section titled “The simulator”The Console’s Simulator evaluates authorization requests entirely in your browser, using the same Cedar engine the Policy Decision Point runs. What the simulator decides is what production will decide, given the same policies and data.
Build a request from its four parts:
- Principal — who is asking (
App::User::"alice") - Action — what they want to do (
App::Action::"read") - Resource — what they want to do it to (
App::Document::"doc123") - Context — request-time facts your policies reference (
{ "mfa_verified": true })
Run it and you get the decision — Allow or Deny — plus the exact policies that determined it, so an unexpected result points straight at the rule responsible.
Requests as test cases
Section titled “Requests as test cases”Set an expected result on any simulator request and it becomes a pass/fail test case. Save request sets per project and re-run them after every policy change — a regression suite for your authorization model.
A practical starting suite:
- Happy paths — each role can do what it should.
- Boundaries — each role is denied its neighbors’ privileges (a
READERcannot write). - Conditions —
when/unlessclauses flip correctly as context changes. - Absences — principals with no matching policy are denied (Cedar’s default holds).
Test entities
Section titled “Test entities”The simulator can run against test entities — a fixture dataset kept separate from your project’s real entity data. Model tricky scenarios (deep group nesting, missing attributes, deactivated users) without polluting production entities, and evolve fixtures alongside your policies.
Impact analysis
Section titled “Impact analysis”Before saving a policy change, you can ask what it would change. In the Console’s policy editor, the Impact panel analyzes your edited (or new) policy against everything currently active in the project, in two ways:
-
Symbolic comparison. A solver compares the current policy set with the candidate set over all possible requests and returns a verdict:
Verdict Meaning equivalentNo request’s decision changes. more_permissiveSome requests that were denied would now be allowed. less_permissiveSome requests that were allowed would now be denied. mixedChanges in both directions. unknownThe analysis couldn’t decide (for example, the policy fails schema validation). For a change, it includes up to 10 witnesses: concrete example requests whose decision flips, and in which direction.
-
Replay of real traffic. The project’s last 24 hours of audit events are re-evaluated against the candidate set. The report counts requests that would flip
allowToDenyordenyToAllowand the requests leftunchanged, with the highest-volume examples of each. Very large windows are capped (the report says so).
Nothing is saved or deployed by an analysis. The project must be attached to a PDP, because the PDP performs the evaluation.
The same analysis is available over the API: POST /projects/:projectId/policy/analyze with { "policy": "<cedar text>", "policyId": "<id of the policy being edited>" } (omit policyId for a new policy). The response contains verdict, witnesses, replay, and caveats. Caveats explain anything the analysis couldn’t cover, such as a skipped replay.
Versioning as a safety net
Section titled “Versioning as a safety net”Every policy edit creates a new version with a diff view, and policies can be deactivated rather than deleted. From the Console’s version history you can restore any earlier version, which saves it as the newest version. A rollout that fails its simulator suite can be reverted by restoring or deactivating, with no destructive changes required.
Watch the real thing
Section titled “Watch the real thing”After a change ships, the Console’s Live Request Logs stream real decisions as your applications make them. If the simulator suite passed but production behavior surprises you, the live stream and the audit log show the exact request, decision, and determining policy to reconcile against your test cases.