Skip to content

Commit

Permalink
Fix potential flakey tests and update ux to remove 'completely' + typ…
Browse files Browse the repository at this point in the history
…o fixes
  • Loading branch information
roncodingenthusiast committed Mar 1, 2023
1 parent e7c0a45 commit 5a37d37
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .changelog/16288.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
```
2 changes: 1 addition & 1 deletion command/acl/token/update/token_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 "+
Expand Down
11 changes: 9 additions & 2 deletions command/acl/token/update/token_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
})
}

Expand Down
4 changes: 2 additions & 2 deletions website/content/commands/acl/token/update.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ instead.

- `-policy-name=<value>` - 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=<value>` - ID of policy to be added for this token. The token retains existing policies. May be specified multiple times.

Expand All @@ -69,7 +69,7 @@ instead.

- `-role-name=<value>` - 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=<value>` - ID of a role to add to this token. The token retains existing roles. May be specified multiple times.

Expand Down

0 comments on commit 5a37d37

Please sign in to comment.