Common Fate uses authorization policy-as-code powered by Cedar. In this guide, you’ll learn how to write tests to verify the behaviour of your Cedar policies and confirm that Common Fate resource syncing is working as expected.
The Common Fate CLI allows tests to be written using a YAML file in the following format:
Prerequisites
If you’re running a BYOC (“Bring-Your-Own-Cloud”) deployment of Common Fate in your own AWS account, you’ll need to be on v1.31.0 or later of the common-fate/common-fate-deployment/aws Terraform module.
You will need the Common Fate cf CLI installed - v1.15.1 or higher. You can check this by running cf --version. You should see an output similar to the below:
Creating a test file using the CLI
To create a new test file, run the following command:
You should see an output as follows:
After creating a tests file, edit the file in your code editor to add users, groups and entitlements based on your deployment.
Running tests using the CLI
To run tests, use the command:
You should see an output similar to the below, containing the results of the tests:
If any access tests fail, the Cedar policies contributing to the authorization decision will be shown below. For example:
In the output above, the basic.policy0 policy is allowing the user to request access, and there are no policies allowing the user to activate the access. The policies are in the format <policy ID>.policyN, where <policy ID> is the ID of the Cedar policy set specified in Terraform, and N is the index of the policy in the policy set.
Policy sets can contain multiple policies as shown below: