Giter Club home page Giter Club logo

action-openfga-test's Introduction

OpenFGA Github Action - Test

FOSSA Status

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. 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

Examples

Running tests of *.fga.yaml files present in the repository

name: Test Action

on:
  workflow_dispatch:

jobs:
  test:
    name: Run test
    runs-on: ubuntu-latest
    steps:
      - uses: openfga/[email protected]

Running tests of *.fga.yaml files present in a given folder

name: Test Action

on:
  workflow_dispatch:

jobs:
  test:
    name: Run test
    runs-on: ubuntu-latest
    steps:
      - uses: openfga/[email protected]
        with:
          test_path: example

Running tests of a single file

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

Running tests against a given version of OpenFGA

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:
      - 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 }}

License

FOSSA Status

action-openfga-test's People

Contributors

poovamraj avatar le-yams avatar rhamzeh avatar aaguiarz avatar big-kahuna-burger avatar josxha avatar dependabot[bot] avatar fossabot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.