add some basic tests

pull/16288/head
Ronald Ekambi 2023-02-21 12:11:06 -05:00
parent 63d2fb4d91
commit f4048866f1
2 changed files with 26 additions and 2 deletions

View File

@ -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
}

View File

@ -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{