integration: port the new CLI command tests to the HTTP client

#3326 added per-resource CLI coverage decoding into the proto types; convert
the transport to the apiv1/ogen types, keeping every command and assertion.
Drop the now-duplicate health and node-routes tests #3326 covers more fully.
This commit is contained in:
Kristoffer Dalby
2026-06-18 13:45:46 +00:00
parent 2a1ae1a2fc
commit add794d190
7 changed files with 217 additions and 332 deletions
+94 -94
View File
@@ -7,7 +7,7 @@ import (
"testing"
"time"
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
apiv1 "github.com/juanfont/headscale/gen/api/v1"
policyv2 "github.com/juanfont/headscale/hscontrol/policy/v2"
"github.com/juanfont/headscale/hscontrol/types"
"github.com/juanfont/headscale/integration/hsic"
@@ -43,7 +43,7 @@ func TestNodeCommand(t *testing.T) {
types.MustAuthID().String(),
types.MustAuthID().String(),
}
nodes := make([]*v1.Node, len(regIDs))
nodes := make([]*apiv1.Node, len(regIDs))
require.NoError(t, err)
@@ -65,7 +65,7 @@ func TestNodeCommand(t *testing.T) {
)
require.NoError(t, err)
var node v1.Node
var node apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -94,7 +94,7 @@ func TestNodeCommand(t *testing.T) {
}, integrationutil.ScaledTimeout(15*time.Second), 1*time.Second)
// Test list all nodes after added seconds
var listAll []v1.Node
var listAll []apiv1.Node
assert.EventuallyWithT(t, func(ct *assert.CollectT) {
err := executeAndUnmarshal(
@@ -112,23 +112,23 @@ func TestNodeCommand(t *testing.T) {
assert.Len(ct, listAll, len(regIDs), "Should list all nodes after CLI operations")
}, integrationutil.ScaledTimeout(20*time.Second), 1*time.Second)
assert.Equal(t, uint64(1), listAll[0].GetId())
assert.Equal(t, uint64(2), listAll[1].GetId())
assert.Equal(t, uint64(3), listAll[2].GetId())
assert.Equal(t, uint64(4), listAll[3].GetId())
assert.Equal(t, uint64(5), listAll[4].GetId())
assert.Equal(t, uint64(1), listAll[0].GetID().Or(0))
assert.Equal(t, uint64(2), listAll[1].GetID().Or(0))
assert.Equal(t, uint64(3), listAll[2].GetID().Or(0))
assert.Equal(t, uint64(4), listAll[3].GetID().Or(0))
assert.Equal(t, uint64(5), listAll[4].GetID().Or(0))
assert.Equal(t, "node-1", listAll[0].GetName())
assert.Equal(t, "node-2", listAll[1].GetName())
assert.Equal(t, "node-3", listAll[2].GetName())
assert.Equal(t, "node-4", listAll[3].GetName())
assert.Equal(t, "node-5", listAll[4].GetName())
assert.Equal(t, "node-1", listAll[0].GetName().Or(""))
assert.Equal(t, "node-2", listAll[1].GetName().Or(""))
assert.Equal(t, "node-3", listAll[2].GetName().Or(""))
assert.Equal(t, "node-4", listAll[3].GetName().Or(""))
assert.Equal(t, "node-5", listAll[4].GetName().Or(""))
otherUserRegIDs := []string{
types.MustAuthID().String(),
types.MustAuthID().String(),
}
otherUserMachines := make([]*v1.Node, len(otherUserRegIDs))
otherUserMachines := make([]*apiv1.Node, len(otherUserRegIDs))
require.NoError(t, err)
@@ -150,7 +150,7 @@ func TestNodeCommand(t *testing.T) {
)
require.NoError(t, err)
var node v1.Node
var node apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -179,7 +179,7 @@ func TestNodeCommand(t *testing.T) {
}, integrationutil.ScaledTimeout(15*time.Second), 1*time.Second)
// Test list all nodes after added otherUser
var listAllWithotherUser []v1.Node
var listAllWithotherUser []apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -199,14 +199,14 @@ func TestNodeCommand(t *testing.T) {
// All nodes, nodes + otherUser
assert.Len(t, listAllWithotherUser, 7)
assert.Equal(t, uint64(6), listAllWithotherUser[5].GetId())
assert.Equal(t, uint64(7), listAllWithotherUser[6].GetId())
assert.Equal(t, uint64(6), listAllWithotherUser[5].GetID().Or(0))
assert.Equal(t, uint64(7), listAllWithotherUser[6].GetID().Or(0))
assert.Equal(t, "otheruser-node-1", listAllWithotherUser[5].GetName())
assert.Equal(t, "otheruser-node-2", listAllWithotherUser[6].GetName())
assert.Equal(t, "otheruser-node-1", listAllWithotherUser[5].GetName().Or(""))
assert.Equal(t, "otheruser-node-2", listAllWithotherUser[6].GetName().Or(""))
// Test list all nodes after added otherUser
var listOnlyotherUserMachineUser []v1.Node
var listOnlyotherUserMachineUser []apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -227,18 +227,18 @@ func TestNodeCommand(t *testing.T) {
assert.Len(t, listOnlyotherUserMachineUser, 2)
assert.Equal(t, uint64(6), listOnlyotherUserMachineUser[0].GetId())
assert.Equal(t, uint64(7), listOnlyotherUserMachineUser[1].GetId())
assert.Equal(t, uint64(6), listOnlyotherUserMachineUser[0].GetID().Or(0))
assert.Equal(t, uint64(7), listOnlyotherUserMachineUser[1].GetID().Or(0))
assert.Equal(
t,
"otheruser-node-1",
listOnlyotherUserMachineUser[0].GetName(),
listOnlyotherUserMachineUser[0].GetName().Or(""),
)
assert.Equal(
t,
"otheruser-node-2",
listOnlyotherUserMachineUser[1].GetName(),
listOnlyotherUserMachineUser[1].GetName().Or(""),
)
// Delete a nodes
@@ -258,7 +258,7 @@ func TestNodeCommand(t *testing.T) {
require.NoError(t, err)
// Test: list main user after node is deleted
var listOnlyMachineUserAfterDelete []v1.Node
var listOnlyMachineUserAfterDelete []apiv1.Node
assert.EventuallyWithT(t, func(ct *assert.CollectT) {
err := executeAndUnmarshal(
@@ -304,7 +304,7 @@ func TestNodeExpireCommand(t *testing.T) {
types.MustAuthID().String(),
types.MustAuthID().String(),
}
nodes := make([]*v1.Node, len(regIDs))
nodes := make([]*apiv1.Node, len(regIDs))
for index, regID := range regIDs {
_, err := headscale.Execute(
@@ -324,7 +324,7 @@ func TestNodeExpireCommand(t *testing.T) {
)
require.NoError(t, err)
var node v1.Node
var node apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -350,7 +350,7 @@ func TestNodeExpireCommand(t *testing.T) {
assert.Len(t, nodes, len(regIDs))
var listAll []v1.Node
var listAll []apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -372,7 +372,7 @@ func TestNodeExpireCommand(t *testing.T) {
// With node.expiry defaulting to 0, non-tagged nodes have zero expiry
// (never expire unless explicitly expired).
for i := range 5 {
assert.True(t, listAll[i].GetExpiry().AsTime().IsZero(),
assert.True(t, listAll[i].GetExpiry().Or(time.Time{}).IsZero(),
"node %d should have zero expiry (no default node.expiry)", i)
}
@@ -383,13 +383,13 @@ func TestNodeExpireCommand(t *testing.T) {
"nodes",
"expire",
"--identifier",
strconv.FormatUint(listAll[idx].GetId(), 10),
strconv.FormatUint(listAll[idx].GetID().Or(0), 10),
},
)
require.NoError(t, err)
}
var listAllAfterExpiry []v1.Node
var listAllAfterExpiry []apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -408,11 +408,11 @@ func TestNodeExpireCommand(t *testing.T) {
assert.Len(t, listAllAfterExpiry, 5)
assert.True(t, listAllAfterExpiry[0].GetExpiry().AsTime().Before(time.Now()))
assert.True(t, listAllAfterExpiry[1].GetExpiry().AsTime().Before(time.Now()))
assert.True(t, listAllAfterExpiry[2].GetExpiry().AsTime().Before(time.Now()))
assert.True(t, listAllAfterExpiry[3].GetExpiry().AsTime().IsZero())
assert.True(t, listAllAfterExpiry[4].GetExpiry().AsTime().IsZero())
assert.True(t, listAllAfterExpiry[0].GetExpiry().Or(time.Time{}).Before(time.Now()))
assert.True(t, listAllAfterExpiry[1].GetExpiry().Or(time.Time{}).Before(time.Now()))
assert.True(t, listAllAfterExpiry[2].GetExpiry().Or(time.Time{}).Before(time.Now()))
assert.True(t, listAllAfterExpiry[3].GetExpiry().Or(time.Time{}).IsZero())
assert.True(t, listAllAfterExpiry[4].GetExpiry().Or(time.Time{}).IsZero())
}
func TestNodeRenameCommand(t *testing.T) {
@@ -440,7 +440,7 @@ func TestNodeRenameCommand(t *testing.T) {
types.MustAuthID().String(),
types.MustAuthID().String(),
}
nodes := make([]*v1.Node, len(regIDs))
nodes := make([]*apiv1.Node, len(regIDs))
require.NoError(t, err)
@@ -462,7 +462,7 @@ func TestNodeRenameCommand(t *testing.T) {
)
require.NoError(t, err)
var node v1.Node
var node apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -488,7 +488,7 @@ func TestNodeRenameCommand(t *testing.T) {
assert.Len(t, nodes, len(regIDs))
var listAll []v1.Node
var listAll []apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -507,11 +507,11 @@ func TestNodeRenameCommand(t *testing.T) {
assert.Len(t, listAll, 5)
assert.Contains(t, listAll[0].GetGivenName(), "node-1")
assert.Contains(t, listAll[1].GetGivenName(), "node-2")
assert.Contains(t, listAll[2].GetGivenName(), "node-3")
assert.Contains(t, listAll[3].GetGivenName(), "node-4")
assert.Contains(t, listAll[4].GetGivenName(), "node-5")
assert.Contains(t, listAll[0].GetGivenName().Or(""), "node-1")
assert.Contains(t, listAll[1].GetGivenName().Or(""), "node-2")
assert.Contains(t, listAll[2].GetGivenName().Or(""), "node-3")
assert.Contains(t, listAll[3].GetGivenName().Or(""), "node-4")
assert.Contains(t, listAll[4].GetGivenName().Or(""), "node-5")
for idx := range 3 {
res, err := headscale.Execute(
@@ -520,7 +520,7 @@ func TestNodeRenameCommand(t *testing.T) {
"nodes",
"rename",
"--identifier",
strconv.FormatUint(listAll[idx].GetId(), 10),
strconv.FormatUint(listAll[idx].GetID().Or(0), 10),
fmt.Sprintf("newnode-%d", idx+1),
},
)
@@ -529,7 +529,7 @@ func TestNodeRenameCommand(t *testing.T) {
assert.Contains(t, res, "Node renamed")
}
var listAllAfterRename []v1.Node
var listAllAfterRename []apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -548,11 +548,11 @@ func TestNodeRenameCommand(t *testing.T) {
assert.Len(t, listAllAfterRename, 5)
assert.Equal(t, "newnode-1", listAllAfterRename[0].GetGivenName())
assert.Equal(t, "newnode-2", listAllAfterRename[1].GetGivenName())
assert.Equal(t, "newnode-3", listAllAfterRename[2].GetGivenName())
assert.Contains(t, listAllAfterRename[3].GetGivenName(), "node-4")
assert.Contains(t, listAllAfterRename[4].GetGivenName(), "node-5")
assert.Equal(t, "newnode-1", listAllAfterRename[0].GetGivenName().Or(""))
assert.Equal(t, "newnode-2", listAllAfterRename[1].GetGivenName().Or(""))
assert.Equal(t, "newnode-3", listAllAfterRename[2].GetGivenName().Or(""))
assert.Contains(t, listAllAfterRename[3].GetGivenName().Or(""), "node-4")
assert.Contains(t, listAllAfterRename[4].GetGivenName().Or(""), "node-5")
// Test failure for too long names
_, err = headscale.Execute(
@@ -561,13 +561,13 @@ func TestNodeRenameCommand(t *testing.T) {
"nodes",
"rename",
"--identifier",
strconv.FormatUint(listAll[4].GetId(), 10),
strconv.FormatUint(listAll[4].GetID().Or(0), 10),
strings.Repeat("t", 64),
},
)
require.ErrorContains(t, err, "is too long, max length is 63 bytes")
var listAllAfterRenameAttempt []v1.Node
var listAllAfterRenameAttempt []apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -586,11 +586,11 @@ func TestNodeRenameCommand(t *testing.T) {
assert.Len(t, listAllAfterRenameAttempt, 5)
assert.Equal(t, "newnode-1", listAllAfterRenameAttempt[0].GetGivenName())
assert.Equal(t, "newnode-2", listAllAfterRenameAttempt[1].GetGivenName())
assert.Equal(t, "newnode-3", listAllAfterRenameAttempt[2].GetGivenName())
assert.Contains(t, listAllAfterRenameAttempt[3].GetGivenName(), "node-4")
assert.Contains(t, listAllAfterRenameAttempt[4].GetGivenName(), "node-5")
assert.Equal(t, "newnode-1", listAllAfterRenameAttempt[0].GetGivenName().Or(""))
assert.Equal(t, "newnode-2", listAllAfterRenameAttempt[1].GetGivenName().Or(""))
assert.Equal(t, "newnode-3", listAllAfterRenameAttempt[2].GetGivenName().Or(""))
assert.Contains(t, listAllAfterRenameAttempt[3].GetGivenName().Or(""), "node-4")
assert.Contains(t, listAllAfterRenameAttempt[4].GetGivenName().Or(""), "node-5")
}
func TestPreAuthKeyCorrectUserLoggedInCommand(t *testing.T) {
@@ -623,7 +623,7 @@ func TestPreAuthKeyCorrectUserLoggedInCommand(t *testing.T) {
u2, err := headscale.CreateUser(user2)
require.NoError(t, err)
var user2Key v1.PreAuthKey
var user2Key apiv1.PreAuthKey
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err = executeAndUnmarshal(
@@ -632,7 +632,7 @@ func TestPreAuthKeyCorrectUserLoggedInCommand(t *testing.T) {
"headscale",
"preauthkeys",
"--user",
strconv.FormatUint(u2.GetId(), 10),
strconv.FormatUint(u2.GetID().Or(0), 10),
"create",
"--reusable",
"--expiration",
@@ -647,7 +647,7 @@ func TestPreAuthKeyCorrectUserLoggedInCommand(t *testing.T) {
assert.NoError(c, err)
}, integrationutil.ScaledTimeout(10*time.Second), integrationutil.FastPoll, "Waiting for user2 preauth key creation")
var listNodes []*v1.Node
var listNodes []*apiv1.Node
assert.EventuallyWithT(t, func(ct *assert.CollectT) {
var err error
@@ -655,7 +655,7 @@ func TestPreAuthKeyCorrectUserLoggedInCommand(t *testing.T) {
listNodes, err = headscale.ListNodes()
assert.NoError(ct, err)
assert.Len(ct, listNodes, 1, "Should have exactly 1 node for user1")
assert.Equal(ct, user1, listNodes[0].GetUser().GetName(), "Node should belong to user1")
assert.Equal(ct, user1, listNodes[0].GetUser().Value.Name.Or(""), "Node should belong to user1")
}, integrationutil.ScaledTimeout(15*time.Second), 1*time.Second)
allClients, err := scenario.ListTailscaleClients()
@@ -679,7 +679,7 @@ func TestPreAuthKeyCorrectUserLoggedInCommand(t *testing.T) {
"Expected node to be logged out, backend state: %s", status.BackendState)
}, integrationutil.StatusReadyTimeout, 2*time.Second)
err = client.Login(headscale.GetEndpoint(), user2Key.GetKey())
err = client.Login(headscale.GetEndpoint(), user2Key.GetKey().Or(""))
require.NoError(t, err)
assert.EventuallyWithT(t, func(ct *assert.CollectT) {
@@ -697,9 +697,9 @@ func TestPreAuthKeyCorrectUserLoggedInCommand(t *testing.T) {
listNodes, err = headscale.ListNodes()
assert.NoError(ct, err)
assert.Len(ct, listNodes, 2, "Should have 2 nodes after re-login")
assert.Equal(ct, user1, listNodes[0].GetUser().GetName(), "First node should belong to user1")
assert.Equal(ct, user1, listNodes[0].GetUser().Value.Name.Or(""), "First node should belong to user1")
// Second node is tagged (created with tagged PreAuthKey), so it shows as "tagged-devices"
assert.Equal(ct, "tagged-devices", listNodes[1].GetUser().GetName(), "Second node should be tagged-devices")
assert.Equal(ct, "tagged-devices", listNodes[1].GetUser().Value.Name.Or(""), "Second node should be tagged-devices")
}, integrationutil.ScaledTimeout(20*time.Second), 1*time.Second)
}
@@ -731,7 +731,7 @@ func TestTaggedNodesCLIOutput(t *testing.T) {
u2, err := headscale.CreateUser(user2)
require.NoError(t, err)
var user2Key v1.PreAuthKey
var user2Key apiv1.PreAuthKey
// Create a tagged PreAuthKey for user2
assert.EventuallyWithT(t, func(c *assert.CollectT) {
@@ -741,7 +741,7 @@ func TestTaggedNodesCLIOutput(t *testing.T) {
"headscale",
"preauthkeys",
"--user",
strconv.FormatUint(u2.GetId(), 10),
strconv.FormatUint(u2.GetID().Or(0), 10),
"create",
"--reusable",
"--expiration",
@@ -778,7 +778,7 @@ func TestTaggedNodesCLIOutput(t *testing.T) {
}, integrationutil.StatusReadyTimeout, 2*time.Second)
// Log in with the tagged PreAuthKey (from user2, with tags)
err = client.Login(headscale.GetEndpoint(), user2Key.GetKey())
err = client.Login(headscale.GetEndpoint(), user2Key.GetKey().Or(""))
require.NoError(t, err)
assert.EventuallyWithT(t, func(ct *assert.CollectT) {
@@ -790,7 +790,7 @@ func TestTaggedNodesCLIOutput(t *testing.T) {
}, integrationutil.StatusReadyTimeout, 2*time.Second)
// Wait for the second node to appear
var listNodes []*v1.Node
var listNodes []*apiv1.Node
assert.EventuallyWithT(t, func(ct *assert.CollectT) {
var err error
@@ -798,8 +798,8 @@ func TestTaggedNodesCLIOutput(t *testing.T) {
listNodes, err = headscale.ListNodes()
assert.NoError(ct, err)
assert.Len(ct, listNodes, 2, "Should have 2 nodes after re-login with tagged key")
assert.Equal(ct, user1, listNodes[0].GetUser().GetName(), "First node should belong to user1")
assert.Equal(ct, "tagged-devices", listNodes[1].GetUser().GetName(), "Second node should be tagged-devices")
assert.Equal(ct, user1, listNodes[0].GetUser().Value.Name.Or(""), "First node should belong to user1")
assert.Equal(ct, "tagged-devices", listNodes[1].GetUser().Value.Name.Or(""), "Second node should be tagged-devices")
}, integrationutil.ScaledTimeout(20*time.Second), 1*time.Second)
// Test: tailscale status output should show "tagged-devices" not "userid:2147455555"
@@ -838,7 +838,7 @@ func TestNodeExpireFlagsCommand(t *testing.T) {
})
require.NoError(t, err)
var node v1.Node
var node apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err := executeAndUnmarshal(headscale,
@@ -853,14 +853,14 @@ func TestNodeExpireFlagsCommand(t *testing.T) {
assert.NoError(c, err)
}, integrationutil.ScaledTimeout(10*time.Second), integrationutil.FastPoll, "Waiting for node registration")
nodeID := strconv.FormatUint(node.GetId(), 10)
nodeID := strconv.FormatUint(node.GetID().Or(0), 10)
// listNodeByID returns the node with the given id from `nodes list`. The
// expire mutations are verified by reading the node back (authoritative,
// eventually-consistent) rather than trusting the mutation's immediate
// response.
listNodeByID := func(ct *assert.CollectT) *v1.Node {
var nodes []v1.Node
listNodeByID := func(ct *assert.CollectT) *apiv1.Node {
var nodes []apiv1.Node
err := executeAndUnmarshal(headscale,
[]string{"headscale", "nodes", "list", "--output", "json"},
@@ -869,7 +869,7 @@ func TestNodeExpireFlagsCommand(t *testing.T) {
require.NoError(ct, err)
for i := range nodes {
if nodes[i].GetId() == node.GetId() {
if nodes[i].GetID().Or(0) == node.GetID().Or(0) {
return &nodes[i]
}
}
@@ -896,8 +896,8 @@ func TestNodeExpireFlagsCommand(t *testing.T) {
return
}
assert.False(ct, n.GetExpiry().AsTime().IsZero(), "expiry should be set")
assert.True(ct, n.GetExpiry().AsTime().After(time.Now()), "expiry should be in the future")
assert.False(ct, n.GetExpiry().Or(time.Time{}).IsZero(), "expiry should be set")
assert.True(ct, n.GetExpiry().Or(time.Time{}).After(time.Now()), "expiry should be in the future")
}, integrationutil.ScaledTimeout(15*time.Second), 1*time.Second, "Waiting for future expiry to apply")
// Disable expiry entirely; the node should then report no expiry.
@@ -919,7 +919,7 @@ func TestNodeExpireFlagsCommand(t *testing.T) {
// future — it never expires. A nil expiry deserialises to the Unix
// epoch rather than the zero time, so assert "not in the future"
// rather than IsZero.
assert.False(ct, n.GetExpiry().AsTime().After(time.Now()),
assert.False(ct, n.GetExpiry().Or(time.Time{}).After(time.Now()),
"disabled node should not have a future expiry")
}, integrationutil.ScaledTimeout(15*time.Second), 1*time.Second, "Waiting for --disable to clear expiry")
}
@@ -943,7 +943,7 @@ func TestNodeCommandValidation(t *testing.T) {
})
require.NoError(t, err)
var node v1.Node
var node apiv1.Node
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err := executeAndUnmarshal(headscale,
@@ -953,7 +953,7 @@ func TestNodeCommandValidation(t *testing.T) {
assert.NoError(c, err)
}, integrationutil.ScaledTimeout(10*time.Second), integrationutil.FastPoll, "Waiting for node registration")
id := strconv.FormatUint(node.GetId(), 10)
id := strconv.FormatUint(node.GetID().Or(0), 10)
// wantErr is matched with ErrorContains; an empty wantErr only requires
// that the command fails (used where the exact message is not load-bearing).
@@ -1049,8 +1049,8 @@ func TestNodeTagCommand(t *testing.T) {
assert.Len(ct, nodes, 1)
if len(nodes) == 1 {
nodeID = nodes[0].GetId()
assert.Equal(ct, "user1", nodes[0].GetUser().GetName(), "node should start user-owned")
nodeID = nodes[0].GetID().Or(0)
assert.Equal(ct, "user1", nodes[0].GetUser().Value.Name.Or(""), "node should start user-owned")
}
}, integrationutil.ScaledTimeout(20*time.Second), 1*time.Second)
@@ -1059,13 +1059,13 @@ func TestNodeTagCommand(t *testing.T) {
// Set two tags. The command response is round-tripped (transport check);
// the resulting tag state is asserted via the authoritative list read-back
// below rather than the immediate mutation response.
tagged := assertJSONRoundtrip[*v1.Node](t, headscale, []string{
tagged := assertJSONRoundtrip[*apiv1.Node](t, headscale, []string{
"headscale", "nodes", "tag",
"--identifier", idStr,
"--tags", "tag:test1,tag:test2",
"--output", "json",
})
assert.Equal(t, nodeID, tagged.GetId(), "tag response should be for the same node")
assert.Equal(t, nodeID, tagged.GetID().Or(0), "tag response should be for the same node")
// The node is now a tagged node, presented as the tagged-devices user.
assert.EventuallyWithT(t, func(ct *assert.CollectT) {
@@ -1074,7 +1074,7 @@ func TestNodeTagCommand(t *testing.T) {
assert.Len(ct, nodes, 1)
if len(nodes) == 1 {
assert.Equal(ct, "tagged-devices", nodes[0].GetUser().GetName(), "tagged node shows as tagged-devices")
assert.Equal(ct, "tagged-devices", nodes[0].GetUser().Value.Name.Or(""), "tagged node shows as tagged-devices")
assert.ElementsMatch(ct, []string{"tag:test1", "tag:test2"}, nodes[0].GetTags())
}
}, integrationutil.ScaledTimeout(20*time.Second), 1*time.Second)
@@ -1138,7 +1138,7 @@ func TestNodeRouteCommands(t *testing.T) {
var nodeID uint64
assert.EventuallyWithT(t, func(ct *assert.CollectT) {
var nodes []v1.Node
var nodes []apiv1.Node
err := executeAndUnmarshal(headscale,
[]string{"headscale", "nodes", "list-routes", "--output", "json"},
@@ -1148,7 +1148,7 @@ func TestNodeRouteCommands(t *testing.T) {
assert.Len(ct, nodes, 1, "list-routes should show the route-advertising node")
if len(nodes) == 1 {
nodeID = nodes[0].GetId()
nodeID = nodes[0].GetID().Or(0)
assert.Contains(ct, nodes[0].GetAvailableRoutes(), route)
assert.Empty(ct, nodes[0].GetApprovedRoutes())
}
@@ -1157,7 +1157,7 @@ func TestNodeRouteCommands(t *testing.T) {
idStr := strconv.FormatUint(nodeID, 10)
// Approve the route via the CLI.
approved := assertJSONRoundtrip[*v1.Node](t, headscale, []string{
approved := assertJSONRoundtrip[*apiv1.Node](t, headscale, []string{
"headscale", "nodes", "approve-routes",
"--identifier", idStr,
"--routes=" + route,
@@ -1168,7 +1168,7 @@ func TestNodeRouteCommands(t *testing.T) {
// list-routes filtered by the identifier should report the approved route
// as a primary subnet route.
assert.EventuallyWithT(t, func(ct *assert.CollectT) {
var nodes []v1.Node
var nodes []apiv1.Node
err := executeAndUnmarshal(headscale,
[]string{"headscale", "nodes", "list-routes", "--identifier", idStr, "--output", "json"},
@@ -1184,7 +1184,7 @@ func TestNodeRouteCommands(t *testing.T) {
}, integrationutil.ScaledTimeout(20*time.Second), 1*time.Second)
// Remove all approved routes by passing an empty --routes value.
cleared := assertJSONRoundtrip[*v1.Node](t, headscale, []string{
cleared := assertJSONRoundtrip[*apiv1.Node](t, headscale, []string{
"headscale", "nodes", "approve-routes",
"--identifier", idStr,
"--routes=",
@@ -1205,7 +1205,7 @@ func TestNodeBackfillIPsCommand(t *testing.T) {
require.NoError(t, scenario.WaitForTailscaleSync())
var before []*v1.Node
var before []*apiv1.Node
assert.EventuallyWithT(t, func(ct *assert.CollectT) {
var err error