integration: fix tag tests for tagged nodes with nil user_id

Tagged nodes no longer have user_id set, so ListNodes(user) cannot
find them. Update integration tests to use ListNodes() (all nodes)
when looking up tagged nodes.

Add a findNode helper to locate nodes by predicate from an
unfiltered list, used in ACL tests that have multiple nodes per
scenario.

Updates #3077
This commit is contained in:
Kristoffer Dalby
2026-02-20 13:02:51 +00:00
parent 1e4fc3f179
commit be4fd9ff2d
3 changed files with 93 additions and 89 deletions

View File

@@ -1004,6 +1004,18 @@ func GetUserByName(headscale ControlServer, username string) (*v1.User, error) {
return nil, fmt.Errorf("user %s not found", username) //nolint:err113
}
// findNode returns the first node in nodes for which match returns true,
// or nil if no node matches.
func findNode(nodes []*v1.Node, match func(*v1.Node) bool) *v1.Node {
for _, n := range nodes {
if match(n) {
return n
}
}
return nil
}
// FindNewClient finds a client that is in the new list but not in the original list.
// This is useful when dynamically adding nodes during tests and needing to identify
// which client was just added.