From c3f7777792363ae893128881052c6a5bb7609e5e Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Wed, 13 Sep 2023 07:50:08 -0400 Subject: [PATCH 1/2] Fixing mapping of multiple action secrets --- internal/cli/actions.go | 5 +++-- internal/cli/actions_test.go | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/internal/cli/actions.go b/internal/cli/actions.go index 96dc86fb5..f6ec6a8d7 100644 --- a/internal/cli/actions.go +++ b/internal/cli/actions.go @@ -5,6 +5,7 @@ import ( "fmt" "net/url" + "github.com/auth0/go-auth0" "github.com/auth0/go-auth0/management" "github.com/spf13/cobra" "golang.org/x/net/context" @@ -560,8 +561,8 @@ func inputSecretsToActionSecrets(secrets map[string]string) *[]management.Action for name, value := range secrets { actionSecrets = append(actionSecrets, management.ActionSecret{ - Name: &name, - Value: &value, + Name: auth0.String(name), + Value: auth0.String(value), }) } diff --git a/internal/cli/actions_test.go b/internal/cli/actions_test.go index 2f45226cf..9ba8dcf26 100644 --- a/internal/cli/actions_test.go +++ b/internal/cli/actions_test.go @@ -210,3 +210,37 @@ func TestActionsPickerOptions(t *testing.T) { }) } } +func TestActionsInputSecretsToActionSecrets(t *testing.T) { + t.Run("Should map input secrets to action payload", func(t *testing.T) { + input := map[string]string{ + "secret1": "value1", + "secret2": "value2", + "secret3": "value3", + } + res := inputSecretsToActionSecrets(input) + expected := []management.ActionSecret{ + { + Name: auth0.String("secret1"), + Value: auth0.String("value1"), + }, + { + Name: auth0.String("secret2"), + Value: auth0.String("value2"), + }, + { + Name: auth0.String("secret3"), + Value: auth0.String("value3"), + }, + } + assert.Len(t, *res, 3) + assert.Equal(t, res, &expected) + }) + + t.Run("Should handle empty input secrets", func(t *testing.T) { + emptyInput := map[string]string{} + res := inputSecretsToActionSecrets(emptyInput) + expected := []management.ActionSecret{} + assert.Len(t, *res, 0) + assert.Equal(t, res, &expected) + }) +} From b9018a549979b7f9cdc405f2f048151a03336afd Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Wed, 13 Sep 2023 08:00:02 -0400 Subject: [PATCH 2/2] Editorial test name --- internal/cli/actions_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/cli/actions_test.go b/internal/cli/actions_test.go index 9ba8dcf26..15e3882c9 100644 --- a/internal/cli/actions_test.go +++ b/internal/cli/actions_test.go @@ -211,7 +211,7 @@ func TestActionsPickerOptions(t *testing.T) { } } func TestActionsInputSecretsToActionSecrets(t *testing.T) { - t.Run("Should map input secrets to action payload", func(t *testing.T) { + t.Run("it should map input secrets to action payload", func(t *testing.T) { input := map[string]string{ "secret1": "value1", "secret2": "value2", @@ -236,7 +236,7 @@ func TestActionsInputSecretsToActionSecrets(t *testing.T) { assert.Equal(t, res, &expected) }) - t.Run("Should handle empty input secrets", func(t *testing.T) { + t.Run("it should handle empty input secrets", func(t *testing.T) { emptyInput := map[string]string{} res := inputSecretsToActionSecrets(emptyInput) expected := []management.ActionSecret{}