mirror of https://github.com/hashicorp/consul
add some basic tests
parent
63d2fb4d91
commit
f4048866f1
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue