70 lines
1.8 KiB
Rego
70 lines
1.8 KiB
Rego
package proofedmesh.data_sources.per_diem_rates_test
|
|
|
|
import data.proofedmesh.data_sources.per_diem_rates as pdr
|
|
import rego.v1
|
|
|
|
base := {
|
|
"data_source": "ds:per-diem-rates",
|
|
"user_sub": "user-12345",
|
|
"session_id": "SES-abc",
|
|
"operation": "read",
|
|
"resource": "rates",
|
|
}
|
|
|
|
test_allow_calculator_country_valid_on if {
|
|
pdr.allow with input as object.union(base, {
|
|
"agent_id": "agent-per-diem-calculator",
|
|
"filters": {"country": "DE", "valid_on": "2026-10-02"},
|
|
})
|
|
}
|
|
|
|
test_allow_calculator_with_city if {
|
|
pdr.allow with input as object.union(base, {
|
|
"agent_id": "agent-per-diem-calculator",
|
|
"filters": {"country": "DE", "city": "Berlin", "valid_on": "2026-10-02"},
|
|
})
|
|
}
|
|
|
|
test_deny_missing_country if {
|
|
not pdr.allow with input as object.union(base, {
|
|
"agent_id": "agent-per-diem-calculator",
|
|
"filters": {"valid_on": "2026-10-02"},
|
|
})
|
|
}
|
|
|
|
test_deny_missing_valid_on if {
|
|
not pdr.allow with input as object.union(base, {
|
|
"agent_id": "agent-per-diem-calculator",
|
|
"filters": {"country": "DE"},
|
|
})
|
|
}
|
|
|
|
test_deny_other_agent if {
|
|
not pdr.allow with input as object.union(base, {
|
|
"agent_id": "agent-travel",
|
|
"filters": {"country": "DE", "valid_on": "2026-10-02"},
|
|
})
|
|
}
|
|
|
|
test_deny_write_operation if {
|
|
not pdr.allow with input as object.union(base, {
|
|
"agent_id": "agent-per-diem-calculator",
|
|
"operation": "write",
|
|
"filters": {"country": "DE", "valid_on": "2026-10-02"},
|
|
})
|
|
}
|
|
|
|
test_deny_no_user_session if {
|
|
not pdr.allow with input as object.union(base, {
|
|
"agent_id": "agent-per-diem-calculator",
|
|
"user_sub": "",
|
|
"filters": {"country": "DE", "valid_on": "2026-10-02"},
|
|
})
|
|
}
|
|
|
|
test_deny_extra_filter_key if {
|
|
not pdr.allow with input as object.union(base, {
|
|
"agent_id": "agent-per-diem-calculator",
|
|
"filters": {"country": "DE", "valid_on": "2026-10-02", "max_rate": "99"},
|
|
})
|
|
}
|