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..15e3882c9 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("it 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("it 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) + }) +}