I am new to OPA and rego files. I have created a rego file like this :
package sample.access
import data.myaccess
default allow = false
allow = true {
myaccess.is_user_allowed(input.user)
}
And, I have created test rego file like this :
package sample.access
test_allow_positive{
allow with input as {
"user": "user1"
} with data.myaccess as {
{
{"user": "user1"},
{"user": "user2"}
}
}
}
When I run this test case, I am getting error like "rego_type_error: undefined function data.myaccess.is_user_allowed". Help me to fix this. Thanks
I was facing a similar issue, probably the below solution might help.
I had a function make_err, in the file myutils.rego which I was using in myModule-test.rego file.
When I ran the command like this:
user@ubuntu:~/rules$./opa test myModule-test.rego
Got this error:
1 error occurred: myModule-test.rego:7: rego_type_error: undefined function data.myutils.make_err
When I gave the below command, it worked:
user@ubuntu:~/rules$ ./opa test myutils.rego myModule-test.rego
PASS: 11/11
It seems we need to load all the modules on which the current test depends.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With