diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fb1f8261d..b41cf4a88 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -82,10 +82,9 @@ jobs: shell: bash run: make test-integration env: - AUTH0_CLI_CLIENT_NAME: ${{ secrets.AUTH0_CLI_CLIENT_NAME }} - AUTH0_CLI_CLIENT_DOMAIN: ${{ secrets.AUTH0_CLI_CLIENT_DOMAIN }} - AUTH0_CLI_CLIENT_ID: ${{ secrets.AUTH0_CLI_CLIENT_ID }} - AUTH0_CLI_CLIENT_SECRET: ${{ secrets.AUTH0_CLI_CLIENT_SECRET }} + AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} + AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }} + AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }} - name: Download unit test coverage uses: actions/download-artifact@v3 diff --git a/.gitignore b/.gitignore index a9fc0216b..a1560ab06 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ tags .vscode .DS_Store .idea +.env # Vendor vendor diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f65d435fc..cd8339db4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,6 +4,24 @@ 2. Clone this repo: `git clone git@github.com:auth0/auth0-cli` 3. `make test` - ensure everything works correctly. Should see things pass. +### Adjusting your Development Environment (Optional) + +To pass the integration tests, you must have the `AUTH0_DOMAIN`, `AUTH0_CLIENT_ID` and `AUTH0_CLIENT_SECRET` environment variable set. To get these values, you can: + +1. Install [jq](https://jqlang.github.io/jq/) +2. [Setup a Machine-to-Machine application](https://auth0.com/docs/get-started/auth0-overview/create-applications/machine-to-machine-apps) +3. Use the resulting **Client Secret** values + +#### Setting up your Environment Variables + +You can set these variables in a `.env` file at the root of the project (replace the values with your own): + +```shell +export AUTH0_DOMAIN="travel0.us.auth0.com" +export AUTH0_CLIENT_ID="tUIvPH7g2ykVm4lGriYEQ6BKV3je24Ka" +export AUTH0_CLIENT_SECRET="XXXXXXXXXXXXXXXXXXXXXXXXXXXX" +``` + ## Build and run on native platform From the top-level directory: diff --git a/Makefile b/Makefile index 469d52bc5..007a73b6e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ #----------------------------------------------------------------------------------------------------------------------- # Variables (https://www.gnu.org/software/make/manual/html_node/Using-Variables.html#Using-Variables) #----------------------------------------------------------------------------------------------------------------------- +-include .env + .DEFAULT_GOAL := help NAME := auth0-cli @@ -164,10 +166,11 @@ test-unit: ## Run unit tests ${call print, "Running unit tests"} @go test -v -race ${GO_PACKAGES} -coverprofile="coverage-unit-tests.out" -test-integration: install-with-cover $(GO_BIN)/commander ## Run integration tests. To run a specific test pass the FILTER var. Usage: `make test-integration FILTER="attack protection"` +test-integration: install-with-cover $(GO_BIN)/auth0 $(GO_BIN)/commander ## Run integration tests. To run a specific test pass the FILTER var. Usage: `make test-integration FILTER="attack protection"` ${call print, "Running integration tests"} @mkdir -p "coverage" - @GOCOVERDIR=coverage bash ./test/integration/scripts/run-test-suites.sh + @PATH=$(GO_BIN):$$PATH \ + GOCOVERDIR=coverage bash ./test/integration/scripts/run-test-suites.sh @go tool covdata textfmt -i "coverage" -o "coverage-integration-tests.out" test-mocks: $(GO_BIN)/mockgen ## Generate testing mocks using mockgen diff --git a/test/integration/scripts/run-test-suites.sh b/test/integration/scripts/run-test-suites.sh index b92f7eb94..960f46cac 100644 --- a/test/integration/scripts/run-test-suites.sh +++ b/test/integration/scripts/run-test-suites.sh @@ -2,15 +2,15 @@ set -e -if [[ -z "${AUTH0_CLI_CLIENT_DOMAIN}" || -z "${AUTH0_CLI_CLIENT_ID}" || -z "${AUTH0_CLI_CLIENT_SECRET}" ]]; then - echo "Error: AUTH0_CLI_CLIENT_DOMAIN, AUTH0_CLI_CLIENT_ID and AUTH0_CLI_CLIENT_SECRET environment variables need to be set" +if [[ -z "${AUTH0_DOMAIN}" || -z "${AUTH0_CLIENT_ID}" || -z "${AUTH0_CLIENT_SECRET}" ]]; then + echo "Error: AUTH0_DOMAIN, AUTH0_CLIENT_ID and AUTH0_CLIENT_SECRET environment variables need to be set" exit 1 fi auth0 login \ - --domain "${AUTH0_CLI_CLIENT_DOMAIN}" \ - --client-id "${AUTH0_CLI_CLIENT_ID}" \ - --client-secret "${AUTH0_CLI_CLIENT_SECRET}" + --domain "${AUTH0_DOMAIN}" \ + --client-id "${AUTH0_CLIENT_ID}" \ + --client-secret "${AUTH0_CLIENT_SECRET}" set +e @@ -20,6 +20,6 @@ exit_code=$? bash ./test/integration/scripts/test-cleanup.sh -auth0 logout "$AUTH0_CLI_CLIENT_DOMAIN" +auth0 logout "$AUTH0_DOMAIN" exit $exit_code diff --git a/test/integration/terraform-test-cases.yaml b/test/integration/terraform-test-cases.yaml index e2dff653d..132929a0b 100644 --- a/test/integration/terraform-test-cases.yaml +++ b/test/integration/terraform-test-cases.yaml @@ -2,9 +2,9 @@ config: inherit-env: true retries: 1 env: - AUTH0_DOMAIN: $AUTH0_CLI_CLIENT_DOMAIN - AUTH0_CLIENT_ID: $AUTH0_CLI_CLIENT_ID - AUTH0_CLIENT_SECRET: $AUTH0_CLI_CLIENT_SECRET + AUTH0_DOMAIN: $AUTH0_DOMAIN + AUTH0_CLIENT_ID: $AUTH0_CLIENT_ID + AUTH0_CLIENT_SECRET: $AUTH0_CLIENT_SECRET tests: 001.0 - setup: command: rm -rdf tmp-tf-gen diff --git a/test/integration/test-cases.yaml b/test/integration/test-cases.yaml index f266a8e29..d3076199c 100644 --- a/test/integration/test-cases.yaml +++ b/test/integration/test-cases.yaml @@ -101,14 +101,14 @@ tests: exit-code: 0 tenants use: - command: auth0 tenants use $AUTH0_CLI_CLIENT_DOMAIN + command: auth0 tenants use $AUTH0_DOMAIN exit-code: 0 stderr: contains: - "Default tenant switched to:" tenants open: - command: auth0 tenants open $AUTH0_CLI_CLIENT_DOMAIN --no-input + command: auth0 tenants open $AUTH0_DOMAIN --no-input exit-code: 0 stderr: contains: