Skip to content

Commit

Permalink
Reorganize integration test files into test folder (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught authored Nov 21, 2022
1 parent df69c1b commit 4f36c89
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project artifacts
/auth0
/integration/identifiers
/test/integration/identifiers

# Swap
[._]*.s[a-v][a-z]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions test/integration/fixtures/update-rule.json
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

user=$( auth0 users create -n integration-test-user-better -c Username-Password-Authentication -e [email protected] -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
File renamed without changes.
80 changes: 40 additions & 40 deletions commander.yaml → test/integration/test-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -416,19 +416,19 @@ 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: "[email protected]"
connection: "Username-Password-Authentication"
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 [email protected]
Expand All @@ -437,14 +437,14 @@ tests:

# Test 'users update'
users update email:
command: auth0 users update $(cat ./integration/identifiers/user-id) --email [email protected] --format json --no-input
command: auth0 users update $(cat ./test/integration/identifiers/user-id) --email [email protected] --format json --no-input
stdout:
json:
email: [email protected]
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: [email protected] # Name is not being displayed, hence using email
Expand All @@ -469,19 +469,19 @@ 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
description: integration-test-role
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
Expand All @@ -490,22 +490,22 @@ 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
exit-code: 0

# 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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -558,15 +558,15 @@ 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"
exit-code: 0

# 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"
Expand Down

0 comments on commit 4f36c89

Please sign in to comment.