Testing policies
In v0.9.0, curral check --policy-tests cases.yaml runs declarative dry-run
cases against the loaded policy and catalog, without starting an HTTP server
or executing the case’s SQL. A failed assertion makes the command fail,
so it can gate a deployment in CI.
Write an access matrix
Section titled “Write an access matrix”For the example policy, after creating sales.main.orders as in the
quickstart:
cases: - name: analyst can read orders user: analyst roles: [analyst] database: sales sql: SELECT * FROM orders expect: decision: allow - name: analyst cannot delete orders user: analyst roles: [analyst] database: sales sql: DELETE FROM orders expect: decision: deny decided_by: policyRun with the same catalog and policy files you intend to deploy:
curral check --catalog catalog.yaml --users users.yaml \ --policy policy.rego --policy roles.json --policy-tests cases.yamlInclude --row-filters, --policy-masks-query, --policy-limits-query and
other protection flags when your deployment uses them. The catalog objects
must exist for inspection to resolve the SQL.
Assertions
Section titled “Assertions”expect field |
What it checks |
|---|---|
decision |
Required: allow, deny or error (HTTP 400) |
decided_by |
Optional decision source, such as policy, engine or protection |
row_filters |
Exact set of filtered table names, not SQL predicate text |
masked_columns |
Exact map of table names to masked column names |
max_rows |
Effective row cap |
timeout |
Policy timeout, as a duration such as 5s |
For example, a case for a protected customer table can assert:
expect: decision: allow row_filters: [sales.main.customers] masked_columns: sales.main.customers: [email, ssn] max_rows: 100 timeout: 5sOmit optional assertions to leave them unchecked. Use row_filters: []
and masked_columns: {} to require no filters or masks. Cases may also
set max_rows to test a request-level cap.
Delegated identities
Section titled “Delegated identities”Set actor, optional actor_attributes, and identity (including a
nonempty subject) to exercise policies that use input.actor and
input.identity. The case’s roles are the effective principal’s roles.
Do not put roles, groups or actor inside identity.
These tests construct a principal from the case; they do not log in, verify
credentials or test identity-to-role mapping. They check SQL dry-run
outcomes, not document-write docs_allow decisions or returned row values.