Skip to content

Commit

Permalink
added tests for node identities changes
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodingenthusiast committed Mar 6, 2023
1 parent 04a7185 commit f47fbf7
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion command/acl/token/update/token_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,15 @@ func TestTokenUpdateCommandWithAppend(t *testing.T) {

// create a token
token, _, err := client.ACL().TokenCreate(
&api.ACLToken{Description: "test", Policies: []*api.ACLTokenPolicyLink{{Name: policy.Name}}},
&api.ACLToken{Description: "test",
Policies: []*api.ACLTokenPolicyLink{{Name: policy.Name}},
NodeIdentities: []*api.ACLNodeIdentity{
{
NodeName: "first-node",
Datacenter: "middleearth-southwest",
},
},
},
&api.WriteOptions{Token: "root"},
)
require.NoError(t, err)
Expand Down Expand Up @@ -235,6 +243,23 @@ func TestTokenUpdateCommandWithAppend(t *testing.T) {

require.Len(t, token.Policies, 3)
})

// update with append-node-identity
t.Run("append-node-identity", func(t *testing.T) {
require.Len(t, token.NodeIdentities, 1)

token := run(t, []string{
"-http-addr=" + a.HTTPAddr(),
"-accessor-id=" + token.AccessorID,
"-token=root",
"-append-node-identity=foo:bar",
"-description=test token",
})

require.Len(t, token.NodeIdentities, 2)
require.Equal(t, "foo", token.NodeIdentities[1].NodeName)
require.Equal(t, "bar", token.NodeIdentities[1].Datacenter)
})
}

func TestTokenUpdateCommand_JSON(t *testing.T) {
Expand Down

0 comments on commit f47fbf7

Please sign in to comment.