From 5a37d37179b104e9e60b11474261b86c900a0406 Mon Sep 17 00:00:00 2001 From: Ronald Ekambi Date: Wed, 1 Mar 2023 09:35:07 -0500 Subject: [PATCH] Fix potential flakey tests and update ux to remove 'completely' + typo fixes --- .changelog/16288.txt | 2 +- command/acl/token/update/token_update.go | 2 +- command/acl/token/update/token_update_test.go | 11 +++++++++-- website/content/commands/acl/token/update.mdx | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.changelog/16288.txt b/.changelog/16288.txt index 3df376b97132..5e2820ec27d5 100644 --- a/.changelog/16288.txt +++ b/.changelog/16288.txt @@ -4,5 +4,5 @@ cli: Deprecate the `-merge-policies` and `-merge-roles` flags from the `consul t ```release-note:improvement cli: added `-append-policy-id`, `-append-policy-name`, `-append-role-name`, and `-append-role-id` flags to the `consul token update` command. -These flags will allow updates to token's policies/roles without having to override them completely. +These flags allow updates to a token's policies/roles without having to override them completely. ``` \ No newline at end of file diff --git a/command/acl/token/update/token_update.go b/command/acl/token/update/token_update.go index 870473905771..6cb529edd45f 100644 --- a/command/acl/token/update/token_update.go +++ b/command/acl/token/update/token_update.go @@ -71,7 +71,7 @@ func (c *cmd) init() { c.flags.Var((*flags.AppendSliceValue)(&c.roleIDs), "role-id", "ID of a "+ "role to use for this token. Overwrites existing roles. May be specified multiple times") c.flags.Var((*flags.AppendSliceValue)(&c.roleNames), "role-name", "Name of a "+ - "role to use for this token. Overwrites existing rolees. May be specified multiple times") + "role to use for this token. Overwrites existing roles. May be specified multiple times") c.flags.Var((*flags.AppendSliceValue)(&c.appendRoleIDs), "append-role-id", "ID of a "+ "role to add to this token. The token retains existing roles. May be specified multiple times") c.flags.Var((*flags.AppendSliceValue)(&c.appendRoleNames), "append-role-name", "Name of a "+ diff --git a/command/acl/token/update/token_update_test.go b/command/acl/token/update/token_update_test.go index a410b61a8dc0..bd11d1d8e3f6 100644 --- a/command/acl/token/update/token_update_test.go +++ b/command/acl/token/update/token_update_test.go @@ -190,6 +190,13 @@ func TestTokenUpdateCommandWithAppend(t *testing.T) { ) require.NoError(t, policyErr) + //third policy + thirdPolicy, _, policyErr := client.ACL().PolicyCreate( + &api.ACLPolicy{Name: "third-policy"}, + &api.WriteOptions{Token: "root"}, + ) + require.NoError(t, policyErr) + run := func(t *testing.T, args []string) *api.ACLToken { ui := cli.NewMockUi() cmd := New(ui) @@ -222,11 +229,11 @@ func TestTokenUpdateCommandWithAppend(t *testing.T) { "-http-addr=" + a.HTTPAddr(), "-accessor-id=" + token.AccessorID, "-token=root", - "-append-policy-id=" + secondPolicy.ID, + "-append-policy-id=" + thirdPolicy.ID, "-description=test token", }) - require.Len(t, token.Policies, 2) + require.Len(t, token.Policies, 3) }) } diff --git a/website/content/commands/acl/token/update.mdx b/website/content/commands/acl/token/update.mdx index 68e5ffe48a16..19441e1020b0 100644 --- a/website/content/commands/acl/token/update.mdx +++ b/website/content/commands/acl/token/update.mdx @@ -59,7 +59,7 @@ instead. - `-policy-name=` - Name of a policy to use for this token. Overwrites existing policies. May be specified multiple times. -~> `-policy-id` and `-policy-name` will completely overwrite existing token policies. Use `-append-policy-id` or `-append-policy-name` to retain existing policies. +~> `-policy-id` and `-policy-name` will overwrite existing token policies. Use `-append-policy-id` or `-append-policy-name` to retain existing policies. - `-append-policy-id=` - ID of policy to be added for this token. The token retains existing policies. May be specified multiple times. @@ -69,7 +69,7 @@ instead. - `-role-name=` - Name of a role to use for this token. Overwrites existing roles. May be specified multiple times. -~> `-role-id` and `-role-name` will completely overwrite existing roles. Use `-append-role-id` or `-append-role-name` to retain the existing roles. +~> `-role-id` and `-role-name` will overwrite existing roles. Use `-append-role-id` or `-append-role-name` to retain the existing roles. - `-append-role-id=` - ID of a role to add to this token. The token retains existing roles. May be specified multiple times.