TestSuite.schema.json
Introduction
In this document, we will explore the Cerbos policy testing framework, which provides a structured way to define and execute tests against your policy definitions.
Test Suite Structure
A typical test suite consists of several key components:
- Name: A unique identifier for the test suite.
- Description: A brief overview of the test suite's purpose.
- Principals: A collection of entities that will be tested against the policies.
- Resources: The entities on which actions will be performed.
- Tests: Individual tests defined within the suite, each specifying inputs and expected outputs.
Example Test Table
Test Table Structure
Each test table includes:
- Name: Unique name for the test.
- Input: Test input data specifying principals, actions, and resources.
- Expected: The expected outcomes of the test.
Sample Test Table
{
"name": "Sample Test",
"input": {
"principals": ["user123"],
"actions": ["read"],
"resources": ["resourceA"]
},
"expected": [
{
"principal": "user123",
"resource": "resourceA",
"actions": {
"read": "EFFECT_ALLOW"
}
}
]
}
Conclusion
Utilizing this structured framework allows for robust testing of your policies, ensuring that they behave as expected.