-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DXCDT-417: Tests for
test
commands (#694)
* Adding tests for test commands * Removing commented-out code * Adding hashbang * Adding required flag, contrib note * Slightly stronger assertion --------- Co-authored-by: Will Vedder <[email protected]> Co-authored-by: Ewan Harris <[email protected]>
- Loading branch information
1 parent
e320094
commit bdc68bc
Showing
6 changed files
with
103 additions
and
2 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
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#! /bin/bash | ||
|
||
management_api_audience=$(./test/integration/scripts/get-manage-api-audience.sh) | ||
m2m_client_id=$(./test/integration/scripts/get-m2m-app-id.sh) | ||
|
||
auth0 api POST "client-grants" --data "{\"client_id\":\"$m2m_client_id\",\"audience\": \"$management_api_audience\",\"scope\": []}" |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#! /bin/bash | ||
|
||
apps=$( auth0 apps list --json --no-input ) | ||
for app in $( printf "%s" "$apps" | jq -r '.[] | @base64' ); do | ||
_jq() { | ||
echo "${app}" | base64 --decode | jq -r "${1}" | ||
} | ||
|
||
id=$(_jq '.client_id') | ||
name=$(_jq '.name') | ||
|
||
if [[ $name = "Default App" ]] | ||
then | ||
echo $id | ||
exit 0 | ||
fi | ||
exit 1 | ||
done |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#! /bin/bash | ||
|
||
FILE=./test/integration/identifiers/m2m-app-id | ||
if [ -f "$FILE" ]; then | ||
cat $FILE | ||
exit 0 | ||
fi | ||
|
||
m2m_app=$( auth0 apps create -n integration-test-app-m2m -t m2m --description "M2M test app" --json --no-input ) | ||
|
||
mkdir -p ./test/integration/identifiers | ||
echo "$m2m_app" | jq -r '.["client_id"]' > $FILE | ||
cat $FILE |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#! /bin/bash | ||
|
||
apis=$( auth0 apis list --json --no-input ) | ||
for api in $( printf "%s" "$apis" | jq -r '.[] | @base64' ); do | ||
_jq() { | ||
echo "${api}" | base64 --decode | jq -r "${1}" | ||
} | ||
|
||
audience=$(_jq '.identifier') | ||
name=$(_jq '.name') | ||
|
||
if [[ $name = "Auth0 Management API" ]] | ||
then | ||
echo $audience | ||
exit 0 | ||
fi | ||
exit 1 | ||
done |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
config: | ||
inherit-env: true | ||
|
||
tests: | ||
001 - test login of default app (partially successful): | ||
#Terminate early because command will otherwise wait for in-browser authorization stage | ||
# `timeout` command provided by GNU coreutils | ||
command: timeout 2s auth0 test login $(./test/integration/scripts/get-default-app-id.sh) --no-input 2>&1 | ||
exit-code: 124 #Timeout exit code | ||
stdout: | ||
contains: | ||
- "Open the following URL in a browser: https://" | ||
- ".auth0.com/authorize?client_id=" | ||
- "&response_type=code&scope=openid+profile&state=" | ||
|
||
002 - unsuccessful test login of machine-to-machine app: | ||
command: auth0 test login $(./test/integration/scripts/get-m2m-app-id.sh) --no-input | ||
exit-code: 1 | ||
stderr: | ||
contains: | ||
- "cannot test the Universal Login with a Machine to Machine application." | ||
|
||
003 - test token without client grant: | ||
command: auth0 test token $(./test/integration/scripts/get-m2m-app-id.sh) --audience "$(./test/integration/scripts/get-manage-api-audience.sh)" --no-input | ||
exit-code: 1 | ||
stderr: | ||
contains: | ||
- "failed to log in with client credentials for client with ID " | ||
- "the integration-test-app-m2m application is not authorized to request access tokens for this API " | ||
- ".auth0.com/api/v2/." | ||
|
||
004 - test token after creating client grant: | ||
command: ./test/integration/scripts/create-client-grant.sh; auth0 test token $(./test/integration/scripts/get-m2m-app-id.sh) --audience "$(./test/integration/scripts/get-manage-api-audience.sh)" --no-input | ||
exit-code: 0 | ||
stdout: | ||
contains: | ||
- "TOKEN TYPE Bearer" | ||
- "EXPIRES IN 1440 minute(s)" | ||
- "ACCESS TOKEN eyJhbGci" |