mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-28 03:05:04 -06:00
598e5cb439
Using the lovely testscript package with a couple of helpers. Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
45 lines
1.3 KiB
Plaintext
45 lines
1.3 KiB
Plaintext
# Verify that the "Bundle loaded and activated successfully" log appears
|
|
# after a bundle is downloaded and activated. This is a regression test:
|
|
# the log was lost when the BufferedLogger was introduced because plugins
|
|
# cached the logger at creation time, and the buffer was flushed before
|
|
# the async bundle load completed.
|
|
|
|
exec $OPA build -o bundles/bundle.tar.gz --bundle policy/
|
|
|
|
http_server bundles
|
|
|
|
exec $OPA run --server --config-file config.yaml --addr unix://opa.sock --log-format json &opa&
|
|
retry curl -sf --unix-socket opa.sock 'http://localhost/health?bundles'
|
|
|
|
exec curl -sf --unix-socket opa.sock -d '{"input": {"admin": true}}' http://localhost/v1/data/example/allow
|
|
jq stdout '.result == true'
|
|
|
|
exec curl -sf --unix-socket opa.sock -d '{"input": {"admin": false}}' http://localhost/v1/data/example/allow
|
|
jq stdout '.result == false'
|
|
|
|
kill -INT opa
|
|
wait opa
|
|
|
|
jq -s stderr '[.[] | select(.msg == "Bundle loaded and activated successfully." and .plugin == "bundle" and .name == "test")] | length == 1'
|
|
|
|
-- config.yaml --
|
|
services:
|
|
bundle-server:
|
|
url: "http://${HTTP_ADDR}"
|
|
bundles:
|
|
test:
|
|
service: bundle-server
|
|
resource: bundle.tar.gz
|
|
polling:
|
|
min_delay_seconds: 300
|
|
max_delay_seconds: 300
|
|
|
|
-- policy/example.rego --
|
|
package example
|
|
|
|
default allow := false
|
|
|
|
allow if input.admin == true
|
|
|
|
-- bundles/.gitkeep --
|