Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Add fga test command#21

Merged
atainter merged 3 commits intomainfrom
at-fga-test
Jun 3, 2025
Merged

Add fga test command#21
atainter merged 3 commits intomainfrom
at-fga-test

Conversation

@atainter
Copy link
Contributor

@atainter atainter commented May 30, 2025

Adds fga test command to the WorkOS CLI. Example Usage:

Run FGA permission tests from a YAML or JSON file, or all .test.yaml/.test.json files in a directory, setting up and tearing down warrants and resources as specified.

Test file format (YAML or JSON):

YAML:
  setup:
    warrants:
      - subject: user:admin
        relation: owner
        resource: doc:1
  tests:
    - name: Admin is owner
      check:
        subject: user:admin
        relation: owner
        resource: doc:1
	context:
          key: "some_value"
      expect: true
  
  # Optional teardown section, alternatively pass the --cleanup flag to the test command to clean up all resources from the setup section
  teardown:
    resources:
      - doc:1
      - user:admin

JSON:
{
  "setup": {
    "warrants": [
      { "subject": "user:admin", "relation": "owner", "resource": "doc:1" }
    ]
  },
  "tests": [
    {
      "name": "Admin is owner",
      "check": { "subject": "user:admin", "relation": "owner", "resource": "doc:1", "context": { "key": "some_value" } },
      "expect": true
    }
  ],
}

Each test file must have a 'setup' section, a 'tests' array, and an optional 'teardown' section.

@atainter atainter marked this pull request as ready for review June 2, 2025 19:36
@atainter atainter merged commit eefc61b into main Jun 3, 2025
2 checks passed
@atainter atainter deleted the at-fga-test branch June 3, 2025 17:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants