Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DXCDT-415: Quickstarts integration tests #693

Merged
merged 4 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions internal/cli/quickstarts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cli

import (
_ "embed"
"errors"
"fmt"
"os"
"path"
Expand Down Expand Up @@ -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")
}

Comment on lines -358 to -361
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conditional was originally added in #119 . It notes:

Returned an error when running in non-interactive mode

  • The use case for this command only makes sense when run by a human being
  • This can be changed later if other use cases pop up

I consider the removal of this check appropriate to enable testing IMO.

if len(args) == 0 {
if err := qsClientID.Pick(
cmd,
Expand Down
15 changes: 15 additions & 0 deletions internal/cli/quickstarts_test.go
Original file line number Diff line number Diff line change
@@ -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"))
}
13 changes: 13 additions & 0 deletions test/integration/quickstarts-test-cases.yaml
Original file line number Diff line number Diff line change
@@ -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-"
13 changes: 13 additions & 0 deletions test/integration/scripts/get-quickstart-app-id.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions test/integration/scripts/test-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions test/integration/test-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ tests:
auth0 rules list:
exit-code: 0

auth0 quickstarts list:
exit-code: 0

auth0 completion bash:
exit-code: 0

Expand Down