[management] Fix policy tests (#3135)

- Add firewall rule isEqual method
- Fix tests
This commit is contained in:
Maycon Santos
2024-12-31 18:45:40 +01:00
committed by GitHub
parent 18b049cd24
commit 03fd656344
2 changed files with 20 additions and 5 deletions

View File

@@ -35,6 +35,15 @@ type FirewallRule struct {
Port string
}
// IsEqual checks if two firewall rules are equal.
func (r *FirewallRule) IsEqual(other *FirewallRule) bool {
return r.PeerIP == other.PeerIP &&
r.Direction == other.Direction &&
r.Action == other.Action &&
r.Protocol == other.Protocol &&
r.Port == other.Port
}
// generateRouteFirewallRules generates a list of firewall rules for a given route.
func generateRouteFirewallRules(ctx context.Context, route *nbroute.Route, rule *PolicyRule, groupPeers []*nbpeer.Peer, direction int) []*RouteFirewallRule {
rulesExists := make(map[string]struct{})