From 80ced390cdab070ee44300e25ccb990f90f7b7c1 Mon Sep 17 00:00:00 2001 From: Sergiu Ghitea Date: Fri, 18 Nov 2022 21:16:18 +0100 Subject: [PATCH] Reorganize integration test files into test folder --- .gitignore | 2 +- Makefile | 4 +- .../integration}/fixtures/create-rule.json | 0 test/integration/fixtures/update-rule.json | 7 ++ .../integration/scripts}/get-api-id.sh | 4 +- .../integration/scripts}/get-app-id.sh | 4 +- .../integration/scripts}/get-role-id.sh | 4 +- .../integration/scripts}/get-rule-id.sh | 6 +- .../integration/scripts}/get-user-id.sh | 4 +- .../integration/scripts}/test-cleanup.sh | 0 .../integration/test-cases.yaml | 80 +++++++++---------- 11 files changed, 61 insertions(+), 54 deletions(-) rename {integration => test/integration}/fixtures/create-rule.json (100%) create mode 100644 test/integration/fixtures/update-rule.json rename {integration => test/integration/scripts}/get-api-id.sh (60%) rename {integration => test/integration/scripts}/get-app-id.sh (52%) rename {integration => test/integration/scripts}/get-role-id.sh (53%) rename {integration => test/integration/scripts}/get-rule-id.sh (60%) rename {integration => test/integration/scripts}/get-user-id.sh (59%) rename {integration => test/integration/scripts}/test-cleanup.sh (100%) rename commander.yaml => test/integration/test-cases.yaml (80%) diff --git a/.gitignore b/.gitignore index 611ab1045..6d8cf0ccc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Project artifacts /auth0 -/integration/identifiers +/test/integration/identifiers # Swap [._]*.s[a-v][a-z] diff --git a/Makefile b/Makefile index 0bdb8b14b..28896ad07 100644 --- a/Makefile +++ b/Makefile @@ -129,9 +129,9 @@ test-unit: ## Run unit tests test-integration: $(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"} @$(MAKE) install # ensure fresh install prior to running test - auth0 config init && commander test commander.yaml --filter "$(FILTER)"; \ + auth0 config init && commander test ./test/integration/test-cases.yaml --filter "$(FILTER)"; \ exit_code=$$?; \ - bash ./integration/test-cleanup.sh; \ + bash ./test/integration/scripts/test-cleanup.sh; \ exit $$exit_code test-mocks: $(GO_BIN)/mockgen ## Generate testing mocks using mockgen diff --git a/integration/fixtures/create-rule.json b/test/integration/fixtures/create-rule.json similarity index 100% rename from integration/fixtures/create-rule.json rename to test/integration/fixtures/create-rule.json diff --git a/test/integration/fixtures/update-rule.json b/test/integration/fixtures/update-rule.json new file mode 100644 index 000000000..c36ac2218 --- /dev/null +++ b/test/integration/fixtures/update-rule.json @@ -0,0 +1,7 @@ +{ + "id": "rul_ftj6AEesNkFz5ZVQ", + "name": "integration-test-rule-betterName", + "script": "function(user, context, cb) {\n cb(null, user, context);\n}\n", + "order": 3, + "enabled": false +} diff --git a/integration/get-api-id.sh b/test/integration/scripts/get-api-id.sh similarity index 60% rename from integration/get-api-id.sh rename to test/integration/scripts/get-api-id.sh index 8a60dce47..04237f079 100755 --- a/integration/get-api-id.sh +++ b/test/integration/scripts/get-api-id.sh @@ -2,5 +2,5 @@ api=$( auth0 apis create --name integration-test-api-newapi --identifier http://integration-test-api-newapi --scopes read:todos --format json --no-input ) -mkdir -p ./integration/identifiers -echo "$api" | jq -r '.["id"]' > ./integration/identifiers/api-id +mkdir -p ./test/integration/identifiers +echo "$api" | jq -r '.["id"]' > ./test/integration/identifiers/api-id diff --git a/integration/get-app-id.sh b/test/integration/scripts/get-app-id.sh similarity index 52% rename from integration/get-app-id.sh rename to test/integration/scripts/get-app-id.sh index d348c6485..8d02eb6b9 100755 --- a/integration/get-app-id.sh +++ b/test/integration/scripts/get-app-id.sh @@ -2,5 +2,5 @@ app=$( auth0 apps create -n integration-test-app-newapp -t native --description NewApp --format json --no-input ) -mkdir -p ./integration/identifiers -echo "$app" | jq -r '.["client_id"]' > ./integration/identifiers/app-id +mkdir -p ./test/integration/identifiers +echo "$app" | jq -r '.["client_id"]' > ./test/integration/identifiers/app-id diff --git a/integration/get-role-id.sh b/test/integration/scripts/get-role-id.sh similarity index 53% rename from integration/get-role-id.sh rename to test/integration/scripts/get-role-id.sh index 952b2e9c3..42bf53c99 100755 --- a/integration/get-role-id.sh +++ b/test/integration/scripts/get-role-id.sh @@ -2,5 +2,5 @@ role=$( auth0 roles create -n integration-test-role-newRole -d integration-test-role --format json --no-input ) -mkdir -p ./integration/identifiers -echo "$role" | jq -r '.["id"]' > ./integration/identifiers/role-id +mkdir -p ./test/integration/identifiers +echo "$role" | jq -r '.["id"]' > ./test/integration/identifiers/role-id diff --git a/integration/get-rule-id.sh b/test/integration/scripts/get-rule-id.sh similarity index 60% rename from integration/get-rule-id.sh rename to test/integration/scripts/get-rule-id.sh index 9738699d4..997ffeea0 100755 --- a/integration/get-rule-id.sh +++ b/test/integration/scripts/get-rule-id.sh @@ -3,6 +3,6 @@ json='{"name":"integration-test-rule-newRule","script":"function(user, context, cb) {\n cb(null, user, context);\n}\n","enabled":false}' rule=$( echo "$json" | auth0 rules create --format json ) -mkdir -p ./integration/identifiers -echo "$rule" | jq -r '.["id"]' > ./integration/identifiers/rule-id -echo "$rule" | jq '.name = "integration-test-rule-betterName"' | jq '.enabled = false' > ./integration/fixtures/update-rule.json +mkdir -p ./test/integration/identifiers +echo "$rule" | jq -r '.["id"]' > ./test/integration/identifiers/rule-id +echo "$rule" | jq '.name = "integration-test-rule-betterName"' | jq '.enabled = false' > ./test/integration/fixtures/update-rule.json diff --git a/integration/get-user-id.sh b/test/integration/scripts/get-user-id.sh similarity index 59% rename from integration/get-user-id.sh rename to test/integration/scripts/get-user-id.sh index 92cff8d97..71c1b289c 100755 --- a/integration/get-user-id.sh +++ b/test/integration/scripts/get-user-id.sh @@ -2,5 +2,5 @@ user=$( auth0 users create -n integration-test-user-better -c Username-Password-Authentication -e newuser@example.com -p testUser12 --format json --no-input ) -mkdir -p ./integration/identifiers -echo "$user" | jq -r '.["user_id"]' > ./integration/identifiers/user-id +mkdir -p ./test/integration/identifiers +echo "$user" | jq -r '.["user_id"]' > ./test/integration/identifiers/user-id diff --git a/integration/test-cleanup.sh b/test/integration/scripts/test-cleanup.sh similarity index 100% rename from integration/test-cleanup.sh rename to test/integration/scripts/test-cleanup.sh diff --git a/commander.yaml b/test/integration/test-cases.yaml similarity index 80% rename from commander.yaml rename to test/integration/test-cases.yaml index 9a45767f4..e61e61f56 100644 --- a/commander.yaml +++ b/test/integration/test-cases.yaml @@ -177,11 +177,11 @@ tests: # Test 'apps show' apps create test app: # create an app and capture its client id - command: ./integration/get-app-id.sh + command: ./test/integration/scripts/get-app-id.sh exit-code: 0 apps show json: - command: auth0 apps show $(cat ./integration/identifiers/app-id) --format json # depends on "apps create test app" test + command: auth0 apps show $(cat ./test/integration/identifiers/app-id) --format json # depends on "apps create test app" test stdout: json: name: integration-test-app-newapp @@ -190,7 +190,7 @@ tests: exit-code: 0 apps show: - command: auth0 apps show $(cat ./integration/identifiers/app-id) # depends on "apps create test app" test + command: auth0 apps show $(cat ./test/integration/identifiers/app-id) # depends on "apps create test app" test stdout: contains: - NAME integration-test-app-newapp @@ -200,70 +200,70 @@ tests: # Test 'apps update'; all tests depend on "apps create test app" test apps update auth method: - command: auth0 apps update $(cat ./integration/identifiers/app-id) --auth-method Basic --format json + command: auth0 apps update $(cat ./test/integration/identifiers/app-id) --auth-method Basic --format json stdout: json: token_endpoint_auth_method: client_secret_basic exit-code: 0 apps update callbacks: - command: auth0 apps update $(cat ./integration/identifiers/app-id) --callbacks https://example.com --format json + command: auth0 apps update $(cat ./test/integration/identifiers/app-id) --callbacks https://example.com --format json stdout: json: callbacks: "[https://example.com]" exit-code: 0 apps update description: - command: auth0 apps update $(cat ./integration/identifiers/app-id) --description "A better description" --format json + command: auth0 apps update $(cat ./test/integration/identifiers/app-id) --description "A better description" --format json stdout: json: description: A better description exit-code: 0 apps update grants: - command: auth0 apps update $(cat ./integration/identifiers/app-id) --grants code --format json + command: auth0 apps update $(cat ./test/integration/identifiers/app-id) --grants code --format json stdout: json: grant_types: "[authorization_code]" exit-code: 0 apps update logout urls: - command: auth0 apps update $(cat ./integration/identifiers/app-id) --logout-urls https://example.com --format json + command: auth0 apps update $(cat ./test/integration/identifiers/app-id) --logout-urls https://example.com --format json stdout: json: allowed_logout_urls: "[https://example.com]" exit-code: 0 apps update name: - command: auth0 apps update $(cat ./integration/identifiers/app-id) --name integration-test-app-betterAppName --format json + command: auth0 apps update $(cat ./test/integration/identifiers/app-id) --name integration-test-app-betterAppName --format json stdout: json: name: integration-test-app-betterAppName exit-code: 0 apps update origins: - command: auth0 apps update $(cat ./integration/identifiers/app-id) --origins https://example.com --format json + command: auth0 apps update $(cat ./test/integration/identifiers/app-id) --origins https://example.com --format json stdout: json: allowed_origins: "[https://example.com]" exit-code: 0 apps update type: - command: auth0 apps update $(cat ./integration/identifiers/app-id) --type spa --format json + command: auth0 apps update $(cat ./test/integration/identifiers/app-id) --type spa --format json stdout: json: app_type: spa exit-code: 0 apps update web origins: - command: auth0 apps update $(cat ./integration/identifiers/app-id) --web-origins https://example.com --format json + command: auth0 apps update $(cat ./test/integration/identifiers/app-id) --web-origins https://example.com --format json stdout: json: web_origins: "[https://example.com]" exit-code: 0 apps update multiple updates: - command: auth0 apps update $(cat ./integration/identifiers/app-id) --web-origins https://examples.com --type native --format json + command: auth0 apps update $(cat ./test/integration/identifiers/app-id) --web-origins https://examples.com --type native --format json stdout: json: app_type: native @@ -332,11 +332,11 @@ tests: # Test 'apps show' apis create test api: # create an api and capture its id - command: ./integration/get-api-id.sh + command: ./test/integration/scripts/get-api-id.sh exit-code: 0 apis show json: - command: auth0 apis show $(cat ./integration/identifiers/api-id) --format json # depends on "apis create test app" test + command: auth0 apis show $(cat ./test/integration/identifiers/api-id) --format json # depends on "apis create test app" test stdout: json: name: integration-test-api-newapi @@ -347,7 +347,7 @@ tests: exit-code: 0 apis show: - command: auth0 apis show $(cat ./integration/identifiers/api-id) # depends on "apis create test app" test + command: auth0 apis show $(cat ./test/integration/identifiers/api-id) # depends on "apis create test app" test stdout: contains: - NAME integration-test-api-newapi @@ -358,40 +358,40 @@ tests: exit-code: 0 apis scopes list: - command: auth0 apis scopes list $(cat ./integration/identifiers/api-id) # depends on "apis create test app" test + command: auth0 apis scopes list $(cat ./test/integration/identifiers/api-id) # depends on "apis create test app" test exit-code: 0 # Test 'apis update'; all tests depend on "apis create test api" test apis update name: - command: auth0 apis update $(cat ./integration/identifiers/api-id) --name integration-test-api-betterApiName --format json + command: auth0 apis update $(cat ./test/integration/identifiers/api-id) --name integration-test-api-betterApiName --format json stdout: json: name: integration-test-api-betterApiName exit-code: 0 apis update scopes: - command: auth0 apis update $(cat ./integration/identifiers/api-id) --scopes read:todos,write:todos --format json + command: auth0 apis update $(cat ./test/integration/identifiers/api-id) --scopes read:todos,write:todos --format json stdout: json: scopes: "[map[value:read:todos] map[value:write:todos]]" exit-code: 0 apis update token lifetime: - command: auth0 apis update $(cat ./integration/identifiers/api-id) --token-lifetime 1000 --format json + command: auth0 apis update $(cat ./test/integration/identifiers/api-id) --token-lifetime 1000 --format json stdout: json: token_lifetime: "1000" exit-code: 0 apis update offline access true: - command: auth0 apis update $(cat ./integration/identifiers/api-id) --offline-access --format json + command: auth0 apis update $(cat ./test/integration/identifiers/api-id) --offline-access --format json stdout: json: allow_offline_access: "true" exit-code: 0 apis update offline access false: - command: auth0 apis update $(cat ./integration/identifiers/api-id) --offline-access=false --format json + command: auth0 apis update $(cat ./test/integration/identifiers/api-id) --offline-access=false --format json stdout: json: allow_offline_access: "false" @@ -416,11 +416,11 @@ tests: # Test 'users show' users create test user: - command: ./integration/get-user-id.sh + command: ./test/integration/scripts/get-user-id.sh exit-code: 0 users show json: - command: auth0 users show $(cat ./integration/identifiers/user-id) --format json + command: auth0 users show $(cat ./test/integration/identifiers/user-id) --format json stdout: json: email: "newuser@example.com" @@ -428,7 +428,7 @@ tests: exit-code: 0 users show: - command: auth0 users show $(cat ./integration/identifiers/user-id) + command: auth0 users show $(cat ./test/integration/identifiers/user-id) stdout: contains: - EMAIL newuser@example.com @@ -437,14 +437,14 @@ tests: # Test 'users update' users update email: - command: auth0 users update $(cat ./integration/identifiers/user-id) --email betteruser@example.com --format json --no-input + command: auth0 users update $(cat ./test/integration/identifiers/user-id) --email betteruser@example.com --format json --no-input stdout: json: email: betteruser@example.com exit-code: 0 users update name: - command: auth0 users update $(cat ./integration/identifiers/user-id) --name integration-test-user-bettername --format json --no-input + command: auth0 users update $(cat ./test/integration/identifiers/user-id) --name integration-test-user-bettername --format json --no-input stdout: json: email: betteruser@example.com # Name is not being displayed, hence using email @@ -469,11 +469,11 @@ tests: # Test 'roles show' roles create test role: - command: ./integration/get-role-id.sh + command: ./test/integration/scripts/get-role-id.sh exit-code: 0 roles show json: - command: auth0 roles show $(cat ./integration/identifiers/role-id) --format json + command: auth0 roles show $(cat ./test/integration/identifiers/role-id) --format json stdout: json: name: integration-test-role-newRole @@ -481,7 +481,7 @@ tests: exit-code: 0 roles show: - command: auth0 roles show $(cat ./integration/identifiers/role-id) + command: auth0 roles show $(cat ./test/integration/identifiers/role-id) stdout: contains: - NAME integration-test-role-newRole @@ -490,14 +490,14 @@ tests: # Test 'roles update' roles update name: - command: auth0 roles update $(cat ./integration/identifiers/role-id) --name integration-test-role-betterName --format json + command: auth0 roles update $(cat ./test/integration/identifiers/role-id) --name integration-test-role-betterName --format json stdout: json: name: integration-test-role-betterName exit-code: 0 roles update description: - command: auth0 roles update $(cat ./integration/identifiers/role-id) --description betterDescription --format json + command: auth0 roles update $(cat ./test/integration/identifiers/role-id) --description betterDescription --format json stdout: json: description: betterDescription @@ -505,7 +505,7 @@ tests: # Test 'rules create' rules create and check data: - command: cat ./integration/fixtures/create-rule.json | jq '.[0]' | auth0 rules create --format json + command: cat ./test/integration/fixtures/create-rule.json | jq '.[0]' | auth0 rules create --format json stdout: json: name: integration-test-rule-new1 @@ -515,7 +515,7 @@ tests: exit-code: 0 rules create and check output: - command: cat ./integration/fixtures/create-rule.json | jq '.[1]' | auth0 rules create + command: cat ./test/integration/fixtures/create-rule.json | jq '.[1]' | auth0 rules create stdout: contains: - NAME integration-test-rule-new2 @@ -526,11 +526,11 @@ tests: # Test 'rules show' rules create test rule: - command: ./integration/get-rule-id.sh + command: ./test/integration/scripts/get-rule-id.sh exit-code: 0 rules show json: - command: auth0 rules show $(cat ./integration/identifiers/rule-id) --format json + command: auth0 rules show $(cat ./test/integration/identifiers/rule-id) --format json stdout: json: name: integration-test-rule-newRule @@ -539,7 +539,7 @@ tests: exit-code: 0 rules show: - command: auth0 rules show $(cat ./integration/identifiers/rule-id) + command: auth0 rules show $(cat ./test/integration/identifiers/rule-id) stdout: contains: - NAME integration-test-rule-newRule @@ -549,7 +549,7 @@ tests: # Test 'rules update' rules update: - command: cat ./integration/fixtures/update-rule.json | auth0 rules update --format json + command: cat ./test/integration/fixtures/update-rule.json | auth0 rules update --format json stdout: json: name: integration-test-rule-betterName @@ -558,7 +558,7 @@ tests: # Test 'rules enable' rules enable: - command: auth0 rules enable $(cat ./integration/identifiers/rule-id) --format json + command: auth0 rules enable $(cat ./test/integration/identifiers/rule-id) --format json stdout: json: enabled: "true" @@ -566,7 +566,7 @@ tests: # Test 'rules disable' rules disable: - command: auth0 rules disable $(cat ./integration/identifiers/rule-id) --format json + command: auth0 rules disable $(cat ./test/integration/identifiers/rule-id) --format json stdout: json: enabled: "false"