From e32009403f70c024eaf8ccbcb1e0a1efc75bf988 Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Fri, 31 Mar 2023 05:44:59 -0400 Subject: [PATCH] DXCDT-415: Quickstarts integration tests (#693) * Seperating qs tests out, adding cleanup and download test * Separating qs app script * Adding quick unit test --------- Co-authored-by: Will Vedder --- internal/cli/quickstarts.go | 5 ----- internal/cli/quickstarts_test.go | 15 +++++++++++++++ test/integration/quickstarts-test-cases.yaml | 13 +++++++++++++ test/integration/scripts/get-quickstart-app-id.sh | 13 +++++++++++++ test/integration/scripts/test-cleanup.sh | 3 +++ test/integration/test-cases.yaml | 3 --- 6 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 internal/cli/quickstarts_test.go create mode 100644 test/integration/quickstarts-test-cases.yaml create mode 100755 test/integration/scripts/get-quickstart-app-id.sh 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/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")) +} diff --git a/test/integration/quickstarts-test-cases.yaml b/test/integration/quickstarts-test-cases.yaml new file mode 100644 index 000000000..3f7624470 --- /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-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-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 694795225..3f0c47f41 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-qs + 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