This action can be used to test your authorization model using store test files.
Parameter | Description | Required | Default |
---|---|---|---|
test_path |
The path to your store test file or folder relative to the root of your project. | No | . |
test_files_pattern |
The pattern to match test files. | No | *.fga.yaml |
fga_server_url |
The OpenFGA server to test the Authorization Model against. If empty (which is the default value), the tests are run using the cli built-in OpenFGA instance. If specified, it is mandatory to specify the store id with the fga_server_store_id input, also the model and model_file entries of the tests are ignored |
No | empty |
fga_server_store_id |
The OpenFGA server store id. Must be provided if fga_server_url is configured. | No | empty |
fga_api_token |
The api token to use for testing against an OpenFGA server. Ignored if fga_server_url is not provided. |
No | empty |
Note: the action will fail if no test is found in the specified test path with the given pattern
name: Test Action
on:
workflow_dispatch:
jobs:
test:
name: Run test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: openfga/[email protected]
name: Test Action
on:
workflow_dispatch:
jobs:
test:
name: Run test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: openfga/[email protected]
with:
test_path: example
name: Test Action
on:
workflow_dispatch:
jobs:
test:
name: Run test
runs-on: ubuntu-latest
steps:
- uses: openfga/[email protected]
with:
test_path: example/model.fga.yaml
name: Test Action
on:
workflow_dispatch:
jobs:
test:
name: Run test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: openfga
POSTGRES_PASSWORD: '1234'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
OPENFGA_DATASTORE_ENGINE: 'postgres'
OPENFGA_DATASTORE_URI: 'postgres://openfga:[email protected]:5432/openfga'
OPENFGA_LOG_LEVEL: debug
steps:
- uses: actions/checkout@v4
- name: Install OpenFGA server v1.5.3
uses: jaxxstorm/[email protected]
with:
repo: openfga/openfga
tag: v1.5.3
cache: enable
- name: Migrate OpenFGA database
shell: bash
run: openfga migrate
- name: Start OpenFGA server in background
shell: bash
run: openfga run &
- name: Install OpenFGA cli
uses: jaxxstorm/[email protected]
with:
repo: openfga/cli
cache: enable
- name: Install jq
uses: dcarbone/install-jq-action@v2
- name: Create store with model
id: 'store'
run: |
fga store create --model ./example/model_with_conditions.fga > store_response.json
cat store_response.json
store_id= $(jq -r '.store.id' store_response.json)
echo "store_id=${store_id}" >> $GITHUB_OUTPUT
- name: Run tests
uses: openfga/[email protected]
with:
fga_server_url: 'http://localhost:8080'
fga_server_store_id: ${{ steps.store.outputs.store_id }}