opa test, run your WASM oracle in isolation, then simulate the full policy end-to-end against the Newton network. This guide covers all three. For diagnosing failures after deployment, see Testing & Debugging.
Unit-test your Rego with opa test
Rego rules are pure functions of input, data.params, and data.wasm, which makes them easy to unit-test without the network. Write a companion policy_test.rego and mock the data with with.
Given a policy like this:
policy_test.rego alongside it. Mock data.params and data.wasm with with, and assert on both allow and membership in the deny set:
- Happy path — clean data allows.
- Each deny rule — one test per rule, asserting the expected reason is in
denyandallowis false. - Param toggles — a deny flag set to
falsedoes not deny. - Edge values —
null, empty, and out-of-range fields behave as intended. - No fail-open under multiple failures — two deny conditions at once still denies.
- Multi-oracle — for chained oracles, wrap each fixture under its own pack id (
{"vaultsfyi": {...}, "webacy": {...}}) and assert deny rules from each namespace fire independently.
Quick local checks with the CLI
The CLI bundles a Rego engine with Newton’s crypto and identity built-ins. Use it to evaluate a query or validate syntax:Pass
--non-strict for OPA-compatible evaluation. -d (data/policy) can be repeated; -i is the input (intent) file. See the CLI Reference.Test your WASM oracle
Run the compiled oracle in isolation to confirm it produces the data shape your Rego expects.Simulate the full policy
The final step before deploying: evaluate the complete policy (Rego + every oracle + merged data) against a sample intent withnewt_simulatePolicy. Pass one entry per oracle in policy_data and namespaced policy_params:
evaluation_result.policy_params_and_data in the response to confirm the merged data.wasm shape, and evaluation_result.result for the allow/deny decision. For multi-oracle policies, see Chaining Multiple Data Oracles.
Recommended workflow
opa testyour Rego rules.policy-data simulateeach oracle locally.- Upload secrets, then
newt_simulatePolicyDataWithClientto verify they resolve. newt_simulatePolicyfor the full end-to-end decision.- Deploy, then submit production tasks.
Next Steps
Testing & Debugging
Diagnose failures after deployment
Chaining Data Oracles
Simulate and test multi-oracle policies
Deployment Checklist
Pre-launch verification steps
Rego Syntax Guide
Rego language reference