mirror of
https://github.com/juanfont/headscale.git
synced 2026-03-21 08:59:19 +01:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user