-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,8 @@ jobs: | |
with: | ||
test_path: ./example/model.fga.yaml | ||
|
||
test_conditions_against_openfga_version: | ||
name: Run test against given OpenFGA version | ||
test_conditions_support: | ||
name: Test conditions support | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
|
@@ -64,13 +64,28 @@ jobs: | |
- name: Start OpenFGA Server | ||
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 OpenFGA CLI Tests | ||
id: 'tests' | ||
uses: ./ | ||
continue-on-error: true | ||
with: | ||
test_path: ./example/model_with_conditions.fga.yaml | ||
fga_server_url: 'http://localhost:8080' | ||
fga_server_store_id: ${{ steps.store.outputs.store_id }} | ||
- name: Assert expected results | ||
run: | | ||
if [ "${{ matrix.test.conditions_supported }}" == "true" ] && [ "${{ steps.tests.outcome }}" == "failure" ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,13 @@ This action can be used to test your authorization model using store test files. | |
|
||
## Parameter | ||
|
||
| 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. | 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_ | | ||
| 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. | 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 | ||
|
@@ -107,10 +108,25 @@ jobs: | |
- 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 }} | ||
``` | ||
|
||
## License | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters