From f4048866f1137dbfd6b3dea0d93bedcbadc07fb0 Mon Sep 17 00:00:00 2001 From: Ronald Ekambi Date: Tue, 21 Feb 2023 12:11:06 -0500 Subject: [PATCH] add some basic tests --- command/acl/token/update/token_update.go | 2 -- command/acl/token/update/token_update_test.go | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/command/acl/token/update/token_update.go b/command/acl/token/update/token_update.go index 03029de631..8df986faa3 100644 --- a/command/acl/token/update/token_update.go +++ b/command/acl/token/update/token_update.go @@ -215,7 +215,6 @@ func (c *cmd) Run(args []string) int { policyIDs = c.policyIDs policyNames = c.policyNames t.Policies = nil - // c.UI.Warn("Overwriting policies with new specified policies") } for _, policyName := range policyNames { @@ -288,7 +287,6 @@ func (c *cmd) Run(args []string) int { if hasRoleFields { roleNames = c.roleNames roleIDs = c.roleIDs - // c.UI.Warn("Overwriting policies with new specified policies") t.Roles = nil } diff --git a/command/acl/token/update/token_update_test.go b/command/acl/token/update/token_update_test.go index 541d1e2253..65eb0496ec 100644 --- a/command/acl/token/update/token_update_test.go +++ b/command/acl/token/update/token_update_test.go @@ -122,6 +122,19 @@ func TestTokenUpdateCommand(t *testing.T) { require.Len(t, token.Policies, 1) }) + // update with add-policy-name + t.Run("add-policy-name", func(t *testing.T) { + token := run(t, []string{ + "-http-addr=" + a.HTTPAddr(), + "-accessor-id=" + token.AccessorID, + "-token=root", + "-add-policy-name=" + policy.Name, + "-description=test token", + }) + + require.Len(t, token.Policies, 1) + }) + // update with policy by id t.Run("policy-id", func(t *testing.T) { token := run(t, []string{ @@ -135,6 +148,19 @@ func TestTokenUpdateCommand(t *testing.T) { require.Len(t, token.Policies, 1) }) + // update with add-policy-id + t.Run("add-policy-id", func(t *testing.T) { + token := run(t, []string{ + "-http-addr=" + a.HTTPAddr(), + "-accessor-id=" + token.AccessorID, + "-token=root", + "-add-policy-id=" + policy.ID, + "-description=test token", + }) + + require.Len(t, token.Policies, 1) + }) + // update with no description shouldn't delete the current description t.Run("merge-description", func(t *testing.T) { token := run(t, []string{