From 84c714a90cbef1cf67e3b22030f36c28ba8fa644 Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Thu, 30 Mar 2023 11:59:26 -0400 Subject: [PATCH 1/3] Seperating qs tests out, adding cleanup and download test --- internal/cli/quickstarts.go | 5 ----- test/integration/quickstarts-test-cases.yaml | 13 +++++++++++++ test/integration/scripts/test-cleanup.sh | 3 +++ test/integration/test-cases.yaml | 3 --- 4 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 test/integration/quickstarts-test-cases.yaml diff --git a/internal/cli/quickstarts.go b/internal/cli/quickstarts.go index c5794b6dc..8af4497c1 100644 --- a/internal/cli/quickstarts.go +++ b/internal/cli/quickstarts.go @@ -2,7 +2,6 @@ package cli import ( _ "embed" - "errors" "fmt" "os" "path" @@ -355,10 +354,6 @@ func defaultURL(url string, port int) string { } func (i *qsInputs) fromArgs(cmd *cobra.Command, args []string, cli *cli) error { - if !canPrompt(cmd) { - return errors.New("this command can only be run on interactive mode") - } - if len(args) == 0 { if err := qsClientID.Pick( cmd, diff --git a/test/integration/quickstarts-test-cases.yaml b/test/integration/quickstarts-test-cases.yaml new file mode 100644 index 000000000..c8feca866 --- /dev/null +++ b/test/integration/quickstarts-test-cases.yaml @@ -0,0 +1,13 @@ +config: + inherit-env: true +tests: + 001 - list quickstarts: + command: auth0 quickstarts list + exit-code: 0 + 002 - download quickstart: + command: auth0 qs download $(./test/integration/scripts/get-app-id.sh) --stack "React Native" --no-color --force + exit-code: 0 + stderr: + contains: + - "Quickstart sample successfully downloaded at " + - "Hint: Start with `cd integration-test-app-newapp/00-" diff --git a/test/integration/scripts/test-cleanup.sh b/test/integration/scripts/test-cleanup.sh index 694795225..07ecddf8b 100755 --- a/test/integration/scripts/test-cleanup.sh +++ b/test/integration/scripts/test-cleanup.sh @@ -127,4 +127,7 @@ auth0 domains delete $(./test/integration/scripts/get-custom-domain-id.sh) --no- # Reset universal login branding auth0 ul update --accent "#2A2E35" --background "#FF4F40" --logo "https://example.com/logo.png" --favicon "https://example.com/favicon.png" --font https://example.com/font.woff --no-input +# Removes quickstart directory +rm -rf integration-test-app-newapp + rm -rf test/integration/identifiers diff --git a/test/integration/test-cases.yaml b/test/integration/test-cases.yaml index 525a05d93..4f857f764 100644 --- a/test/integration/test-cases.yaml +++ b/test/integration/test-cases.yaml @@ -14,9 +14,6 @@ tests: auth0 rules list: exit-code: 0 - auth0 quickstarts list: - exit-code: 0 - auth0 completion bash: exit-code: 0 From e06e5b33258bbab7010f83fca7254499151ae40b Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Thu, 30 Mar 2023 12:34:23 -0400 Subject: [PATCH 2/3] Separating qs app script --- test/integration/quickstarts-test-cases.yaml | 4 ++-- test/integration/scripts/get-quickstart-app-id.sh | 13 +++++++++++++ test/integration/scripts/test-cleanup.sh | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100755 test/integration/scripts/get-quickstart-app-id.sh diff --git a/test/integration/quickstarts-test-cases.yaml b/test/integration/quickstarts-test-cases.yaml index c8feca866..3f7624470 100644 --- a/test/integration/quickstarts-test-cases.yaml +++ b/test/integration/quickstarts-test-cases.yaml @@ -5,9 +5,9 @@ tests: command: auth0 quickstarts list exit-code: 0 002 - download quickstart: - command: auth0 qs download $(./test/integration/scripts/get-app-id.sh) --stack "React Native" --no-color --force + command: auth0 qs download $(./test/integration/scripts/get-quickstart-app-id.sh) --stack "React Native" --no-color --force exit-code: 0 stderr: contains: - "Quickstart sample successfully downloaded at " - - "Hint: Start with `cd integration-test-app-newapp/00-" + - "Hint: Start with `cd integration-test-app-qs/00-" diff --git a/test/integration/scripts/get-quickstart-app-id.sh b/test/integration/scripts/get-quickstart-app-id.sh new file mode 100755 index 000000000..91505dd4e --- /dev/null +++ b/test/integration/scripts/get-quickstart-app-id.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +FILE=./test/integration/identifiers/qs-app-id +if [ -f "$FILE" ]; then + cat $FILE + exit 0 +fi + +app=$( auth0 apps create -n integration-test-app-qs -t native --description "Quickstart app" --json --no-input ) + +mkdir -p ./test/integration/identifiers +echo "$app" | jq -r '.["client_id"]' > $FILE +cat $FILE diff --git a/test/integration/scripts/test-cleanup.sh b/test/integration/scripts/test-cleanup.sh index 07ecddf8b..3f0c47f41 100755 --- a/test/integration/scripts/test-cleanup.sh +++ b/test/integration/scripts/test-cleanup.sh @@ -128,6 +128,6 @@ auth0 domains delete $(./test/integration/scripts/get-custom-domain-id.sh) --no- auth0 ul update --accent "#2A2E35" --background "#FF4F40" --logo "https://example.com/logo.png" --favicon "https://example.com/favicon.png" --font https://example.com/font.woff --no-input # Removes quickstart directory -rm -rf integration-test-app-newapp +rm -rf integration-test-app-qs rm -rf test/integration/identifiers From 1438aeab36375583e3b9207504caa5cad7bb38cf Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Thu, 30 Mar 2023 13:46:56 -0400 Subject: [PATCH 3/3] Adding quick unit test --- internal/cli/quickstarts_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 internal/cli/quickstarts_test.go diff --git a/internal/cli/quickstarts_test.go b/internal/cli/quickstarts_test.go new file mode 100644 index 000000000..4c6f94ca6 --- /dev/null +++ b/internal/cli/quickstarts_test.go @@ -0,0 +1,15 @@ +package cli + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestQuickstartsTypeFor(t *testing.T) { + assert.Equal(t, qsSpa, quickstartsTypeFor("spa")) + assert.Equal(t, qsWebApp, quickstartsTypeFor("regular_web")) + assert.Equal(t, qsWebApp, quickstartsTypeFor("regular_web")) + assert.Equal(t, qsBackend, quickstartsTypeFor("non_interactive")) + assert.Equal(t, "generic", quickstartsTypeFor("some-unknown-value")) +}