Add OPA policies tests

This commit is contained in:
Quentin Gliech
2022-06-01 19:41:14 +02:00
parent 0625384042
commit 420647ae65
2 changed files with 31 additions and 0 deletions

View File

@@ -3,3 +3,7 @@ policy.wasm: client_registration.rego login.rego register.rego
tar xzf bundle.tar.gz /policy.wasm
rm -f bundle.tar.gz
touch $@
.PHONY: test
test:
opa test -v .

View File

@@ -0,0 +1,27 @@
package client_registration
test_valid {
allow with input.client_metadata as {
"client_uri": "https://example.com",
"tos_uri": "https://example.com/tos",
"policy_uri": "https://example.com/policy",
"redirect_uris": ["https://example.com/callback"],
}
}
test_missing_client_uri {
not allow with input.client_metadata as {
"tos_uri": "https://example.com/tos",
"policy_uri": "https://example.com/policy",
"redirect_uris": ["https://example.com/callback"],
}
}
test_insecure_client_uri {
not allow with input.client_metadata as {
"client_uri": "http://example.com",
"tos_uri": "https://example.com/tos",
"policy_uri": "https://example.com/policy",
"redirect_uris": ["https://example.com/callback"],
}
}