rego4k debugger
Query
decision := data.expenses.approval.decision
Write a policy, an input and a query. Then click Debug.
# The tests of the policy. They replace `http.send` with `with`, so they do not need the staff directory. package expenses.approval_test import data.expenses.approval # The response of the staff directory for an employee whose manager is carol. carol_manages(_) := {"status_code": 200, "body": {"name": "alice", "manager": "carol"}} test_manager_approves if { approval.allow with input as {"expense": {"amount": 120, "approver": "carol", "employee": "alice"}} with http.send as carol_manages } test_self_approval_is_denied if { approval.reasons == {"only carol, the manager of alice, can approve"} with input as {"expense": {"amount": 120, "approver": "alice", "employee": "alice"}} with http.send as carol_manages } test_amount_over_the_limit if { "the amount is more than the limit of 1000" in approval.reasons with input as {"expense": {"amount": 5000, "approver": "carol", "employee": "alice"}} with http.send as carol_manages } test_unknown_employee if { approval.reasons == {"the employee is not in the directory"} with input as {"expense": {"amount": 120, "approver": "carol", "employee": "zoe"}} with http.send as {"status_code": 404} }
Input (JSON)
{ "expense": { "amount": 120, "approver": "carol", "employee": "alice" } }