Polar tests
In your policy (i.e. the collection of rules for your environment), Polar has a built-in test feature that lets you run unit tests of literal-value queries using a set of facts only visible for the lifetime of the test.
Feature | Description |
---|---|
test | Introduces a test block, which lets you run a set of unit tests |
setup | Declares facts to make accessible for the lifetime of your test |
assert | Succeeds if the expression evaluates to true |
assert_not | Succeeds if the expression evaluates to false |
allow | By default, Polar includes an alias to has_permission , which is a common shorthand rule |
Here's an annotated pseudo-example demonstrating the syntax:
Simple example
Here's a simple example policy including tests, relying only on primitive types.
Complex example
Here is a more complex example that leverages Polar's abstract types and more closely mirrors how we expect you to use Oso.
Up next
- Patterns to understand common ways to model your applications.
Talk to an Oso Engineer
If you want to learn more about Polar, schedule a 1x1 with an Oso engineer. We're happy to help.