Skip to content

Commit

Permalink
tests: fix konnect integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Nov 9, 2023
1 parent 77682ca commit 681e00c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/integration-konnect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
DECK_KONNECT_EMAIL : ${{ secrets.DECK_KONNECT_EMAIL }}
DECK_KONNECT_PASSWORD : ${{ secrets.DECK_KONNECT_PASSWORD }}
DECK_KONNECT_ADDR : ${{ secrets.DECK_KONNECT_ADDR }}
DECK_KONNECT_TOKEN : ${{ secrets.DECK_KONNECT_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Setup go
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ import (

func Test_KonnectPing(t *testing.T) {
t.Run("konnect ping - email/password", func(t *testing.T) {
// TODO: https://github.com/Kong/deck/issues/1100
// Remove the test altogether or fix the basic auth support.
t.Skip("https://github.com/Kong/deck/issues/1100")

runWhen(t, "konnect", "")
require.NoError(t, ping(
"--konnect-email", os.Getenv("DECK_KONNECT_EMAIL"),
"--konnect-password", os.Getenv("DECK_KONNECT_PASSWORD"),
))
})

t.Run("konnect ping - token", func(t *testing.T) {
runWhen(t, "konnect", "")
require.NoError(t, ping(
Expand Down
24 changes: 17 additions & 7 deletions tests/integration/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,39 @@ func getTestClient() (*kong.Client, error) {
}

func runWhenKonnect(t *testing.T) {
t.Helper()

if os.Getenv("DECK_KONNECT_EMAIL") == "" &&
os.Getenv("DECK_KONNECT_PASSWORD") == "" &&
os.Getenv("DECK_KONNECT_TOKEN") == "" {
t.Log("non-Konnect test instance, skipping")
t.Skip()
t.Skip("non-Konnect test instance, skipping")
}
}

func skipWhenKonnect(t *testing.T) {
if os.Getenv("DECK_KONNECT_EMAIL") != "" || os.Getenv("DECK_KONNECT_PASSWORD") != "" {
t.Log("non-Kong test instance, skipping")
t.Skip()
t.Helper()

if os.Getenv("DECK_KONNECT_EMAIL") != "" ||
os.Getenv("DECK_KONNECT_PASSWORD") != "" ||
os.Getenv("DECK_KONNECT_TOKEN") != "" {
t.Skip("non-Kong test instance, skipping")
}
}

func runWhenKongOrKonnect(t *testing.T, kongSemverRange string) {
if os.Getenv("DECK_KONNECT_EMAIL") != "" && os.Getenv("DECK_KONNECT_PASSWORD") != "" {
t.Helper()

if os.Getenv("DECK_KONNECT_EMAIL") != "" &&
os.Getenv("DECK_KONNECT_PASSWORD") != "" &&
os.Getenv("DECK_KONNECT_TOKEN") != "" {
return
}
kong.RunWhenKong(t, kongSemverRange)
}

func runWhen(t *testing.T, mode string, semverRange string) {
t.Helper()

switch mode {
case "kong":
skipWhenKonnect(t)
Expand Down Expand Up @@ -324,7 +334,7 @@ func lint(opts ...string) (string, error) {

func ping(opts ...string) error {
deckCmd := cmd.NewRootCmd()
args := []string{"ping"}
args := []string{"gateway", "ping"}
if len(opts) > 0 {
args = append(args, opts...)
}
Expand Down

0 comments on commit 681e00c

Please sign in to comment.