Possible to write rego tests for masks? #507
Answered
by
charlieegan3
leefernandes
asked this question in
OPA and Rego
-
I'm looking at the documentation for masking sensitive data and it's unclear if we can write unit tests with rego to test masks? Does anyone know if this is possible, or the recommended approach for testing masks? https://www.openpolicyagent.org/docs/latest/management-decision-logs/#masking-sensitive-data |
Beta Was this translation helpful? Give feedback.
Answered by
charlieegan3
Oct 30, 2023
Replies: 1 comment 2 replies
-
Hey, sorry for the late reply here. Masking of data is 'just' a Rego policy, so it'd be possible to test the behaviour like this:
package system.log
mask["/input/password"] {
input.input.resource == "user"
}
mask["/input/ssn"]
package system.log
import future.keywords.in
test_password_present_for_user {
result := mask with input as {"input": {"resource": "user", "password": "foobar"}}
"/input/password" in result
}
test_ssn_always_present {
result := mask with input as {}
"/input/ssn" in result
} and to test
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
leefernandes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, sorry for the late reply here. Masking of data is 'just' a Rego policy, so it'd be possible to test the behaviour like this:
masks.rego
masks_test.rego
and to test