From 5fb779648a51e2ebde0363e359023f73b6dfbcb0 Mon Sep 17 00:00:00 2001 From: Sergiu Ghitea <28300158+sergiught@users.noreply.github.com> Date: Fri, 17 Mar 2023 11:44:45 +0100 Subject: [PATCH] Increase test coverage for actions (#679) --- docs/auth0_actions_update.md | 2 +- internal/auth0/action.go | 2 + internal/auth0/action_mock.go | 170 ++++++++++++++++++++++ internal/cli/actions.go | 53 +++---- internal/cli/actions_test.go | 130 +++++++++++++++++ test/integration/actions-test-cases.yaml | 106 ++++++++++++++ test/integration/scripts/create-action.sh | 6 + test/integration/scripts/test-cleanup.sh | 17 +++ test/integration/test-cases.yaml | 3 - 9 files changed, 450 insertions(+), 39 deletions(-) create mode 100644 internal/auth0/action_mock.go create mode 100644 internal/cli/actions_test.go create mode 100644 test/integration/actions-test-cases.yaml create mode 100755 test/integration/scripts/create-action.sh diff --git a/docs/auth0_actions_update.md b/docs/auth0_actions_update.md index b10418edb..51cacd15a 100644 --- a/docs/auth0_actions_update.md +++ b/docs/auth0_actions_update.md @@ -25,7 +25,7 @@ auth0 actions update [flags] auth0 actions update --name myaction --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" auth0 actions update --name myaction --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" --secret "SECRET=value" auth0 actions update --name myaction --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" --dependency "uuid=9.0.0" --secret "API_KEY=value" --secret "SECRET=value" - auth0 actions update -n myaction -t post-login -c "$(cat path/to/code.js)" -d "lodash=4.0.0" -d "uuid=9.0.0" -s "API_KEY=value" -s "SECRET=value" --json + auth0 actions update -n myaction -c "$(cat path/to/code.js)" -d "lodash=4.0.0" -d "uuid=9.0.0" -s "API_KEY=value" -s "SECRET=value" --json ``` diff --git a/internal/auth0/action.go b/internal/auth0/action.go index 6797bdf1e..2264f65c6 100644 --- a/internal/auth0/action.go +++ b/internal/auth0/action.go @@ -1,3 +1,5 @@ +//go:generate mockgen -source=action.go -destination=action_mock.go -package=auth0 + package auth0 import "github.com/auth0/go-auth0/management" diff --git a/internal/auth0/action_mock.go b/internal/auth0/action_mock.go new file mode 100644 index 000000000..52b9597d0 --- /dev/null +++ b/internal/auth0/action_mock.go @@ -0,0 +1,170 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: action.go + +// Package auth0 is a generated GoMock package. +package auth0 + +import ( + reflect "reflect" + + management "github.com/auth0/go-auth0/management" + gomock "github.com/golang/mock/gomock" +) + +// MockActionAPI is a mock of ActionAPI interface. +type MockActionAPI struct { + ctrl *gomock.Controller + recorder *MockActionAPIMockRecorder +} + +// MockActionAPIMockRecorder is the mock recorder for MockActionAPI. +type MockActionAPIMockRecorder struct { + mock *MockActionAPI +} + +// NewMockActionAPI creates a new mock instance. +func NewMockActionAPI(ctrl *gomock.Controller) *MockActionAPI { + mock := &MockActionAPI{ctrl: ctrl} + mock.recorder = &MockActionAPIMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockActionAPI) EXPECT() *MockActionAPIMockRecorder { + return m.recorder +} + +// Create mocks base method. +func (m *MockActionAPI) Create(a *management.Action, opts ...management.RequestOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{a} + for _, a_2 := range opts { + varargs = append(varargs, a_2) + } + ret := m.ctrl.Call(m, "Create", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// Create indicates an expected call of Create. +func (mr *MockActionAPIMockRecorder) Create(a interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{a}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockActionAPI)(nil).Create), varargs...) +} + +// Delete mocks base method. +func (m *MockActionAPI) Delete(id string, opts ...management.RequestOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Delete", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockActionAPIMockRecorder) Delete(id interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockActionAPI)(nil).Delete), varargs...) +} + +// Deploy mocks base method. +func (m *MockActionAPI) Deploy(id string, opts ...management.RequestOption) (*management.ActionVersion, error) { + m.ctrl.T.Helper() + varargs := []interface{}{id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Deploy", varargs...) + ret0, _ := ret[0].(*management.ActionVersion) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Deploy indicates an expected call of Deploy. +func (mr *MockActionAPIMockRecorder) Deploy(id interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Deploy", reflect.TypeOf((*MockActionAPI)(nil).Deploy), varargs...) +} + +// List mocks base method. +func (m *MockActionAPI) List(opts ...management.RequestOption) (*management.ActionList, error) { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "List", varargs...) + ret0, _ := ret[0].(*management.ActionList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// List indicates an expected call of List. +func (mr *MockActionAPIMockRecorder) List(opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockActionAPI)(nil).List), opts...) +} + +// Read mocks base method. +func (m *MockActionAPI) Read(id string, opts ...management.RequestOption) (*management.Action, error) { + m.ctrl.T.Helper() + varargs := []interface{}{id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Read", varargs...) + ret0, _ := ret[0].(*management.Action) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Read indicates an expected call of Read. +func (mr *MockActionAPIMockRecorder) Read(id interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockActionAPI)(nil).Read), varargs...) +} + +// Triggers mocks base method. +func (m *MockActionAPI) Triggers(opts ...management.RequestOption) (*management.ActionTriggerList, error) { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Triggers", varargs...) + ret0, _ := ret[0].(*management.ActionTriggerList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Triggers indicates an expected call of Triggers. +func (mr *MockActionAPIMockRecorder) Triggers(opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Triggers", reflect.TypeOf((*MockActionAPI)(nil).Triggers), opts...) +} + +// Update mocks base method. +func (m *MockActionAPI) Update(id string, a *management.Action, opts ...management.RequestOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{id, a} + for _, a_2 := range opts { + varargs = append(varargs, a_2) + } + ret := m.ctrl.Call(m, "Update", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// Update indicates an expected call of Update. +func (mr *MockActionAPIMockRecorder) Update(id, a interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{id, a}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockActionAPI)(nil).Update), varargs...) +} diff --git a/internal/cli/actions.go b/internal/cli/actions.go index db9158177..873612f86 100644 --- a/internal/cli/actions.go +++ b/internal/cli/actions.go @@ -100,12 +100,11 @@ func listActionsCmd(cli *cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { var list *management.ActionList - if err := ansi.Waiting(func() error { - var err error - list, err = cli.api.Action.List() + if err := ansi.Waiting(func() (err error) { + list, err = cli.api.Action.List(management.PerPage(100)) return err }); err != nil { - return fmt.Errorf("An unexpected error occurred: %w", err) + return fmt.Errorf("failed to retrieve actions: %w", err) } cli.renderer.ActionList(list.Actions) @@ -133,8 +132,7 @@ func showActionCmd(cli *cli) *cobra.Command { auth0 actions show --json`, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { - err := actionID.Pick(cmd, &inputs.ID, cli.actionPickerOptions) - if err != nil { + if err := actionID.Pick(cmd, &inputs.ID, cli.actionPickerOptions); err != nil { return err } } else { @@ -143,12 +141,11 @@ func showActionCmd(cli *cli) *cobra.Command { var action *management.Action - if err := ansi.Waiting(func() error { - var err error + if err := ansi.Waiting(func() (err error) { action, err = cli.api.Action.Read(inputs.ID) return err }); err != nil { - return fmt.Errorf("Unable to get an action with ID '%s': %w", inputs.ID, err) + return fmt.Errorf("failed to get action with ID %q: %w", inputs.ID, err) } cli.renderer.ActionShow(action) @@ -195,18 +192,15 @@ func createActionCmd(cli *cli) *cobra.Command { return err } - triggerIds := make([]string, 0) + triggerIDs := make([]string, 0) for _, t := range triggers { - triggerIds = append(triggerIds, t.GetID()) + triggerIDs = append(triggerIDs, t.GetID()) } - if err := actionTrigger.Select(cmd, &inputs.Trigger, triggerIds, nil); err != nil { + if err := actionTrigger.Select(cmd, &inputs.Trigger, triggerIDs, nil); err != nil { return err } - // TODO(cyx): we can re-think this once we have - // `--stdin` based commands. For now we don't have - // those yet, so keeping this simple. if err := actionCode.OpenEditor( cmd, &inputs.Code, @@ -241,7 +235,7 @@ func createActionCmd(cli *cli) *cobra.Command { if err := ansi.Waiting(func() error { return cli.api.Action.Create(action) }); err != nil { - return fmt.Errorf("An unexpected error occurred while attempting to create an action with name '%s': %w", inputs.Name, err) + return fmt.Errorf("failed to create action: %w", err) } cli.renderer.ActionCreate(action) @@ -282,7 +276,7 @@ func updateActionCmd(cli *cli) *cobra.Command { auth0 actions update --name myaction --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" auth0 actions update --name myaction --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" --secret "SECRET=value" auth0 actions update --name myaction --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" --dependency "uuid=9.0.0" --secret "API_KEY=value" --secret "SECRET=value" - auth0 actions update -n myaction -t post-login -c "$(cat path/to/code.js)" -d "lodash=4.0.0" -d "uuid=9.0.0" -s "API_KEY=value" -s "SECRET=value" --json`, + auth0 actions update -n myaction -c "$(cat path/to/code.js)" -d "lodash=4.0.0" -d "uuid=9.0.0" -s "API_KEY=value" -s "SECRET=value" --json`, RunE: func(cmd *cobra.Command, args []string) error { if len(args) > 0 { inputs.ID = args[0] @@ -343,11 +337,10 @@ func updateActionCmd(cli *cli) *cobra.Command { if err = ansi.Waiting(func() error { return cli.api.Action.Update(oldAction.GetID(), updatedAction) }); err != nil { - return fmt.Errorf("failed to update action with ID %s: %w", oldAction.GetID(), err) + return fmt.Errorf("failed to update action with ID %q: %w", oldAction.GetID(), err) } cli.renderer.ActionUpdate(updatedAction) - return nil }, } @@ -381,8 +374,7 @@ func deleteActionCmd(cli *cli) *cobra.Command { auth0 actions delete --force`, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { - err := actionID.Pick(cmd, &inputs.ID, cli.actionPickerOptions) - if err != nil { + if err := actionID.Pick(cmd, &inputs.ID, cli.actionPickerOptions); err != nil { return err } } else { @@ -396,11 +388,6 @@ func deleteActionCmd(cli *cli) *cobra.Command { } return ansi.Spinner("Deleting action", func() error { - _, err := cli.api.Action.Read(inputs.ID) - if err != nil { - return fmt.Errorf("Unable to delete action: %w", err) - } - return cli.api.Action.Delete(inputs.ID) }) }, @@ -430,8 +417,7 @@ func deployActionCmd(cli *cli) *cobra.Command { auth0 actions deploy --json`, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { - err := actionID.Pick(cmd, &inputs.ID, cli.actionPickerOptions) - if err != nil { + if err := actionID.Pick(cmd, &inputs.ID, cli.actionPickerOptions); err != nil { return err } } else { @@ -439,14 +425,12 @@ func deployActionCmd(cli *cli) *cobra.Command { } var action *management.Action - - if err := ansi.Waiting(func() error { - var err error + if err := ansi.Waiting(func() (err error) { if _, err = cli.api.Action.Deploy(inputs.ID); err != nil { - return fmt.Errorf("Unable to deploy an action with Id '%s': %w", inputs.ID, err) + return fmt.Errorf("failed to deploy action with ID %q: %w", inputs.ID, err) } if action, err = cli.api.Action.Read(inputs.ID); err != nil { - return fmt.Errorf("Unable to get deployed action with Id '%s': %w", inputs.ID, err) + return fmt.Errorf("failed to get deployed action with ID %q: %w", inputs.ID, err) } return nil }); err != nil { @@ -477,8 +461,7 @@ func openActionCmd(cli *cli) *cobra.Command { auth0 actions open `, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { - err := actionID.Pick(cmd, &inputs.ID, cli.actionPickerOptions) - if err != nil { + if err := actionID.Pick(cmd, &inputs.ID, cli.actionPickerOptions); err != nil { return err } } else { diff --git a/internal/cli/actions_test.go b/internal/cli/actions_test.go new file mode 100644 index 000000000..52fb623bb --- /dev/null +++ b/internal/cli/actions_test.go @@ -0,0 +1,130 @@ +package cli + +import ( + "bytes" + "fmt" + "io" + "testing" + + "github.com/auth0/go-auth0/management" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + + "github.com/auth0/auth0-cli/internal/auth0" + "github.com/auth0/auth0-cli/internal/display" +) + +func TestActionsDeployCmd(t *testing.T) { + t.Run("it successfully deploys an action", func(t *testing.T) { + actionID := "1221c74c-cfd6-40db-af13-7bc9bb1c38db" + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + actionAPI := auth0.NewMockActionAPI(ctrl) + actionAPI.EXPECT(). + Deploy(actionID). + Return(nil, nil) + + actionAPI.EXPECT(). + Read(actionID). + Return(&management.Action{ + ID: auth0.String(actionID), + Name: auth0.String("actions-deploy"), + SupportedTriggers: []management.ActionTrigger{ + { + ID: auth0.String("post-login"), + }, + }, + Code: auth0.String("function () {}"), + DeployedVersion: &management.ActionVersion{ + Deployed: true, + }, + Status: auth0.String("built"), + }, nil) + + stdout := &bytes.Buffer{} + cli := &cli{ + renderer: &display.Renderer{ + MessageWriter: io.Discard, + ResultWriter: stdout, + }, + api: &auth0.API{Action: actionAPI}, + } + + cmd := deployActionCmd(cli) + cmd.SetArgs([]string{actionID}) + err := cmd.Execute() + + assert.NoError(t, err) + expectTable(t, stdout.String(), + []string{}, + [][]string{ + {"ID 1221c74c-cfd6-40db-af13-7bc9bb1c38db"}, + {"NAME actions-deploy"}, + {"TYPE post-login"}, + {"STATUS built"}, + {"DEPLOYED ✓"}, + {"LAST DEPLOYED"}, + {"LAST UPDATED Jan 01 0001"}, + {"CREATED Jan 01 0001"}, + {"CODE function () {}"}, + }, + ) + }) + + t.Run("it returns an error if it fails to deploy the action", func(t *testing.T) { + actionID := "1221c74c-cfd6-40db-af13-7bc9bb1c38db" + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + actionAPI := auth0.NewMockActionAPI(ctrl) + actionAPI.EXPECT(). + Deploy(actionID). + Return(nil, fmt.Errorf("400 Bad Request")) + + stdout := &bytes.Buffer{} + cli := &cli{ + renderer: &display.Renderer{ + MessageWriter: io.Discard, + ResultWriter: stdout, + }, + api: &auth0.API{Action: actionAPI}, + } + + cmd := deployActionCmd(cli) + cmd.SetArgs([]string{actionID}) + err := cmd.Execute() + + assert.EqualError(t, err, `failed to deploy action with ID "1221c74c-cfd6-40db-af13-7bc9bb1c38db": 400 Bad Request`) + }) + + t.Run("it returns an error if it fails to read the action", func(t *testing.T) { + actionID := "1221c74c-cfd6-40db-af13-7bc9bb1c38db" + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + actionAPI := auth0.NewMockActionAPI(ctrl) + actionAPI.EXPECT(). + Deploy(actionID). + Return(nil, nil) + + actionAPI.EXPECT(). + Read(actionID). + Return(nil, fmt.Errorf("400 Bad Request")) + + stdout := &bytes.Buffer{} + cli := &cli{ + renderer: &display.Renderer{ + MessageWriter: io.Discard, + ResultWriter: stdout, + }, + api: &auth0.API{Action: actionAPI}, + } + + cmd := deployActionCmd(cli) + cmd.SetArgs([]string{actionID}) + err := cmd.Execute() + + assert.EqualError(t, err, `failed to get deployed action with ID "1221c74c-cfd6-40db-af13-7bc9bb1c38db": 400 Bad Request`) + }) +} diff --git a/test/integration/actions-test-cases.yaml b/test/integration/actions-test-cases.yaml new file mode 100644 index 000000000..5f4f0410c --- /dev/null +++ b/test/integration/actions-test-cases.yaml @@ -0,0 +1,106 @@ +config: + inherit-env: true + +tests: + 001 - it successfully lists all actions: + command: auth0 actions list + exit-code: 0 + + 002 - it successfully creates an action: + command: auth0 actions create -n "integration-test-action1" -t "post-login" -c "function() {}" -d "lodash=4.0.0" -s "SECRET=value" + exit-code: 0 + stdout: + contains: + - "NAME integration-test-action1" + - "TYPE post-login" + - "STATUS pending" + - "DEPLOYED ✗" + - "LAST DEPLOYED" + - "LAST UPDATED 0 seconds ago" + - "CREATED 0 seconds ago" + - "CODE function() {}" + + 003 - it successfully creates an action and outputs in json: + command: auth0 actions create -n "integration-test-action2" -t "post-login" -c "function() {}" -d "lodash=4.0.0" -s "SECRET=value" --json + exit-code: 0 + stdout: + json: + name: "integration-test-action2" + supported_triggers.0.id: "post-login" + supported_triggers.0.version: "v3" + code: "function() {}" + dependencies.0.name: "lodash" + dependencies.0.version: "4.0.0" + secrets.0.name: "SECRET" + secrets.0.value: "value" + status: "pending" + + 004 - given a test action: + command: ./test/integration/scripts/create-action.sh + exit-code: 0 + + 005 - given a test action, it successfully gets the action's details: + command: auth0 actions show $(cat ./test/integration/identifiers/action-id) + exit-code: 0 + stdout: + contains: + - "NAME integration-test-action" + - "TYPE post-login" + - "STATUS" + - "DEPLOYED ✗" + - "LAST DEPLOYED" + - "LAST UPDATED" + - "CREATED" + - "CODE function() {}" + + 006 - given a test action, it successfully gets the action's details and outputs in json: + command: auth0 actions show $(cat ./test/integration/identifiers/action-id) --json + exit-code: 0 + stdout: + json: + name: "integration-test-action" + supported_triggers.0.id: "post-login" + supported_triggers.0.version: "v3" + code: "function() {}" + dependencies.0.name: "lodash" + dependencies.0.version: "4.0.0" + secrets.0.name: "SECRET" + + 007 - given a test action, it successfully updates the action's details: + command: auth0 actions update $(cat ./test/integration/identifiers/action-id) -n "integration-test-action-updated" -c "function() {console.log()}" -d "uuid=9.0.0" -s "SECRET2=newValue" + exit-code: 0 + stdout: + contains: + - "NAME integration-test-action-updated" + - "TYPE post-login" + - "STATUS" + - "DEPLOYED ✗" + - "LAST DEPLOYED" + - "LAST UPDATED" + - "CREATED" + - "CODE function() {console.log()}" + + 008 - given a test action, it successfully updates the action's details and outputs in json: + command: auth0 actions update $(cat ./test/integration/identifiers/action-id) -n "integration-test-action-updated-again" -c "function() {console.log()}" -d "uuid=9.0.0" -s "SECRET3=newValue" --json + exit-code: 0 + stdout: + json: + name: "integration-test-action-updated-again" + supported_triggers.0.id: "post-login" + supported_triggers.0.version: "v3" + code: "function() {console.log()}" + dependencies.0.name: "uuid" + dependencies.0.version: "9.0.0" + secrets.0.name: "SECRET3" + secrets.0.value: "newValue" + + 011 - given a test action, it successfully opens the settings page: + command: auth0 actions open $(cat ./test/integration/identifiers/action-id) --no-input + exit-code: 0 + stderr: + contains: + - "Open the following URL in a browser" + + 012 - given a test action, it successfully deletes the action: + command: auth0 actions delete $(cat ./test/integration/identifiers/action-id) --force + exit-code: 0 diff --git a/test/integration/scripts/create-action.sh b/test/integration/scripts/create-action.sh new file mode 100755 index 000000000..a5776459f --- /dev/null +++ b/test/integration/scripts/create-action.sh @@ -0,0 +1,6 @@ +#! /bin/bash + +action=$( auth0 actions create -n "integration-test-action" -t "post-login" -c "function() {}" -d "lodash=4.0.0" -s "SECRET=value" --json ) + +mkdir -p ./test/integration/identifiers +echo "$action" | jq -r '.["id"]' > ./test/integration/identifiers/action-id diff --git a/test/integration/scripts/test-cleanup.sh b/test/integration/scripts/test-cleanup.sh index a8da99c0f..954d6dc1d 100755 --- a/test/integration/scripts/test-cleanup.sh +++ b/test/integration/scripts/test-cleanup.sh @@ -104,3 +104,20 @@ for org in $( echo "${orgs}" | jq -r '.[] | @base64' ); do $( auth0 orgs delete "$id") fi done + +actions=$( auth0 actions list --json --no-input ) + +for action in $( echo "${actions}" | jq -r '.[] | @base64' ); do + _jq() { + echo "${action}" | base64 --decode | jq -r "${1}" + } + + id=$(_jq '.id') + name=$(_jq '.name') + + if [[ $name = integration-test-* ]] + then + echo deleting "$name" + $( auth0 actions delete "$id") + fi +done diff --git a/test/integration/test-cases.yaml b/test/integration/test-cases.yaml index b27bf27b0..0b1a6e058 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 actions list: - exit-code: 0 - auth0 orgs list: exit-code: 0