Testing Regula advanced rules?
christophetd opened this issue · comments
Christophe Tafani-Dereeper commented
Hello,
Is it possible to use fregot test
to run unit tests of Regula advanced rules making use of fugue.resources
, fugue.deny_resource
and similar functions?
So far, simply running fregot test
raises errors because it's not aware of the definition of these functions:
$ frego test rules/aws_s3_bucket_public_access_block.rego
"rules/aws_s3_bucket_public_access_block.rego" (line 12, column 11):
unknown call:
12| buckets = fugue.resources("AWS.S3.Bucket")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unknown call to fugue.resources
...
Thanks!
Jasper Van der Jeugt commented
Right -- fregot needs to be aware of the definitions to run them. You can pass multiple files and/or directories to fregot test
, so you can try something like: fregot test lib rules tests examples
(or anything more fine-tuned as well). But since Regula tests require a little bit of set up, I would start by copying some existing tests in the Regula repository and then go from there.