mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-14 12:22:51 -06:00
184d1b553f
The assertions are stricter now, e.g. we're also checking that nothing is emitted to stderr. Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
29 lines
762 B
Plaintext
29 lines
762 B
Plaintext
# input from file
|
|
exec $OPA exec --bundle policy/ --decision /pkg/p ./input.json
|
|
stdout '"result": true'
|
|
! stderr .
|
|
|
|
# input from stdin
|
|
stdin input.json
|
|
exec $OPA exec --bundle policy/ --decision /pkg/p --stdin-input
|
|
stdout '"result": true'
|
|
! stderr .
|
|
|
|
# fail on non-empty inputs
|
|
! exec $OPA exec --bundle policy/ --fail-non-empty --decision /pkg/p ./input.json
|
|
stdout '"result": true'
|
|
stderr '"exec error: there were 1 failures and 0 errors counted in the results list, and --fail-non-empty is set"'
|
|
|
|
# with bundle
|
|
exec $OPA build --bundle policy/
|
|
stdin input.json
|
|
exec $OPA exec --bundle bundle.tar.gz --decision /pkg/p --stdin-input
|
|
stdout '"result": true'
|
|
! stderr .
|
|
|
|
-- policy/pkg.rego --
|
|
package pkg
|
|
p if input.foo == "bar"
|
|
-- input.json --
|
|
{"foo": "bar"}
|