feat: init commit
This commit is contained in:
10
crates/burrego/test_data/trace/Makefile
Normal file
10
crates/burrego/test_data/trace/Makefile
Normal file
@@ -0,0 +1,10 @@
|
||||
test: policy.wasm
|
||||
bats e2e.bats
|
||||
|
||||
policy.wasm: policy.rego
|
||||
opa build -t wasm -e policy/main -o policy.tar.gz policy.rego
|
||||
tar -xf policy.tar.gz /policy.wasm
|
||||
rm policy.tar.gz
|
||||
|
||||
clean:
|
||||
rm -f *.wasm *.tar.gz
|
||||
23
crates/burrego/test_data/trace/e2e.bats
Normal file
23
crates/burrego/test_data/trace/e2e.bats
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
@test "input message is not valid" {
|
||||
run cargo run --example cli -- -v eval policy.wasm -i '{ "message": "mondo" }'
|
||||
# this prints the output when one the checks below fails
|
||||
echo "output = ${output}"
|
||||
|
||||
# request rejected
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(expr "$output" : '.*"result":.*false') -ne 0 ]
|
||||
[ $(expr "$output" : ".*input\.message has been set to 'mondo'") -ne 0 ]
|
||||
}
|
||||
|
||||
@test "input message is valid" {
|
||||
run cargo run --example cli -- -v eval policy.wasm -i '{ "message": "world" }'
|
||||
# this prints the output when one the checks below fails
|
||||
echo "output = ${output}"
|
||||
|
||||
# request rejected
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(expr "$output" : '.*"result":.*true') -ne 0 ]
|
||||
[ $(expr "$output" : ".*input\.message has been set to 'world'") -ne 0 ]
|
||||
}
|
||||
9
crates/burrego/test_data/trace/policy.rego
Normal file
9
crates/burrego/test_data/trace/policy.rego
Normal file
@@ -0,0 +1,9 @@
|
||||
package policy
|
||||
|
||||
default main = false
|
||||
|
||||
main {
|
||||
trace(sprintf("input.message has been set to '%v'", [input.message]));
|
||||
m := input.message;
|
||||
m == "world"
|
||||
}
|
||||
Reference in New Issue
Block a user