diff --git a/internal/controller/api_to_config_test.go b/internal/controller/api_to_config_test.go index 26c31432..1db78de1 100644 --- a/internal/controller/api_to_config_test.go +++ b/internal/controller/api_to_config_test.go @@ -88,23 +88,11 @@ func TestConversion(t *testing.T) { ConnectTime: ptr.To(uint64(2)), DisableMP: true, GracefulRestart: true, - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, - VRF: "", IPV4Prefixes: []string{"192.0.2.0/24"}, - IPV6Prefixes: []string{}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -160,23 +148,11 @@ func TestConversion(t *testing.T) { HoldTime: ptr.To[uint64](40), ConnectTime: ptr.To(uint64(2)), DisableMP: true, - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, - VRF: "", IPV4Prefixes: []string{"192.0.2.0/24"}, - IPV6Prefixes: []string{}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -200,7 +176,6 @@ func TestConversion(t *testing.T) { Address: "192.0.2.7", }, }, - VRF: "", Prefixes: []string{"192.0.2.0/24"}, }, { @@ -232,35 +207,15 @@ func TestConversion(t *testing.T) { Name: "65011@192.0.2.6", ASN: 65011, Addr: "192.0.2.6", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, { IPFamily: ipfamily.IPv4, Name: "65012@192.0.2.7", ASN: 65012, Addr: "192.0.2.7", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, - VRF: "", IPV4Prefixes: []string{"192.0.2.0/24"}, - IPV6Prefixes: []string{}, }, { MyASN: 65013, @@ -272,23 +227,12 @@ func TestConversion(t *testing.T) { ASN: 65014, Addr: "2001:db8::4", VRFName: "vrf2", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, VRF: "vrf2", - IPV4Prefixes: []string{}, IPV6Prefixes: []string{"2001:db8::/64"}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -328,22 +272,12 @@ func TestConversion(t *testing.T) { Name: "65021@192.0.2.11", ASN: 65021, Addr: "192.0.2.11", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, IPV4Prefixes: []string{"192.0.2.0/24"}, IPV6Prefixes: []string{"2001:db8::/64"}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -352,12 +286,9 @@ func TestConversion(t *testing.T) { fromK8s: []v1beta1.FRRConfiguration{ {}, }, - secrets: map[string]v1.Secret{}, - expected: &frr.Config{ - Routers: []*frr.RouterConfig{}, - BFDProfiles: []frr.BFDProfile{}, - }, - err: nil, + secrets: map[string]v1.Secret{}, + expected: &frr.Config{}, + err: nil, }, { name: "Non default VRF", @@ -396,23 +327,12 @@ func TestConversion(t *testing.T) { ASN: 65031, Addr: "192.0.2.16", VRFName: "vrf1", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, VRF: "vrf1", IPV4Prefixes: []string{"192.0.2.0/24"}, - IPV6Prefixes: []string{}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -464,20 +384,12 @@ func TestConversion(t *testing.T) { Prefix: "192.0.2.0/24", }, }, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, IPV4Prefixes: []string{"192.0.2.0/24"}, - IPV6Prefixes: []string{}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -542,13 +454,7 @@ func TestConversion(t *testing.T) { Prefix: "192.0.4.0/24", }, }, - PrefixesV6: []frr.OutgoingFilter{}, }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, { IPFamily: ipfamily.IPv4, @@ -577,18 +483,12 @@ func TestConversion(t *testing.T) { }, }, }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, IPV4Prefixes: []string{"192.0.2.0/24", "192.0.3.0/24", "192.0.4.0/24"}, IPV6Prefixes: []string{"2001:db8::/64"}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -710,13 +610,7 @@ func TestConversion(t *testing.T) { LocalPref: 100, }, }, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, }, - AlwaysBlock: []frr.IncomingFilter{}, }, { IPFamily: ipfamily.IPv4, @@ -752,18 +646,12 @@ func TestConversion(t *testing.T) { }, }, }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, IPV4Prefixes: []string{"192.0.2.0/24", "192.0.3.0/24", "192.0.4.0/24", "192.0.6.0/24"}, IPV6Prefixes: []string{"2001:db8::/64"}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -986,31 +874,21 @@ func TestConversion(t *testing.T) { expected: &frr.Config{ Routers: []*frr.RouterConfig{ { - MyASN: 65040, - RouterID: "192.0.2.20", - IPV4Prefixes: []string{}, - IPV6Prefixes: []string{}, + MyASN: 65040, + RouterID: "192.0.2.20", Neighbors: []*frr.NeighborConfig{ { IPFamily: ipfamily.IPv4, Name: "65041@192.0.2.21", ASN: 65041, Addr: "192.0.2.21", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, Incoming: frr.AllowedIn{ - All: true, - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, + All: true, }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -1060,10 +938,6 @@ func TestConversion(t *testing.T) { Name: "65041@192.0.2.21", ASN: 65041, Addr: "192.0.2.21", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, Incoming: frr.AllowedIn{ All: false, PrefixesV4: []frr.IncomingFilter{ @@ -1075,12 +949,10 @@ func TestConversion(t *testing.T) { {IPFamily: "ipv6", Prefix: "2001:db8::/64"}, }, }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -1130,10 +1002,6 @@ func TestConversion(t *testing.T) { Name: "65041@192.0.2.21", ASN: 65041, Addr: "192.0.2.21", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, Incoming: frr.AllowedIn{ All: false, PrefixesV4: []frr.IncomingFilter{ @@ -1145,7 +1013,6 @@ func TestConversion(t *testing.T) { {IPFamily: "ipv6", Prefix: "2001:db8::/64"}, }, }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, }, @@ -1290,7 +1157,6 @@ func TestConversion(t *testing.T) { Communities: []string{"10:101"}, }, }, - PrefixesV6: []frr.OutgoingFilter{}, }, Incoming: frr.AllowedIn{ PrefixesV4: []frr.IncomingFilter{ @@ -1303,17 +1169,13 @@ func TestConversion(t *testing.T) { Prefix: "192.0.101.0/24", }, }, - PrefixesV6: []frr.IncomingFilter{}, }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, VRF: "", IPV4Prefixes: []string{"192.0.2.10/32", "192.0.2.11/32"}, - IPV6Prefixes: []string{}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -1392,10 +1254,6 @@ func TestConversion(t *testing.T) { Name: "65012@192.0.2.7", ASN: 65012, Addr: "192.0.2.7", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, Incoming: frr.AllowedIn{ PrefixesV4: []frr.IncomingFilter{ { @@ -1426,17 +1284,13 @@ func TestConversion(t *testing.T) { GE: 26, }, }, - PrefixesV6: []frr.IncomingFilter{}, }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, VRF: "", IPV4Prefixes: []string{"192.0.2.10/32", "192.0.2.11/32"}, - IPV6Prefixes: []string{}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -1605,13 +1459,7 @@ func TestConversion(t *testing.T) { Prefix: "192.0.3.2/32", }, }, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, }, - AlwaysBlock: []frr.IncomingFilter{}, }, { IPFamily: ipfamily.IPv4, @@ -1643,18 +1491,11 @@ func TestConversion(t *testing.T) { LocalPref: 200, }, }, - PrefixesV6: []frr.OutgoingFilter{}, }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, VRF: "", IPV4Prefixes: []string{"192.0.2.10/32", "192.0.2.11/32", "192.0.3.1/32", "192.0.3.2/32", "192.0.3.20/32", "192.0.3.21/32"}, - IPV6Prefixes: []string{}, }, { MyASN: 65013, @@ -1673,13 +1514,7 @@ func TestConversion(t *testing.T) { Prefix: "192.0.2.5/32", }, }, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, }, - AlwaysBlock: []frr.IncomingFilter{}, }, { IPFamily: ipfamily.IPv6, @@ -1705,11 +1540,6 @@ func TestConversion(t *testing.T) { }, }, }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, VRF: "vrf2", @@ -1717,7 +1547,6 @@ func TestConversion(t *testing.T) { IPV6Prefixes: []string{"2001:db8::/64", "2001:db9::/96"}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -1798,15 +1627,6 @@ func TestConversion(t *testing.T) { ASN: 65012, Addr: "192.0.2.7", Password: "password1", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, { IPFamily: ipfamily.IPv4, @@ -1814,20 +1634,9 @@ func TestConversion(t *testing.T) { ASN: 65012, Addr: "192.0.2.8", Password: "cleartext-password", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, - VRF: "", - IPV4Prefixes: []string{}, - IPV6Prefixes: []string{}, + VRF: "", }, { MyASN: 65013, @@ -1839,15 +1648,6 @@ func TestConversion(t *testing.T) { ASN: 65017, Addr: "192.0.2.7", VRFName: "vrf2", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, { IPFamily: ipfamily.IPv6, @@ -1856,23 +1656,11 @@ func TestConversion(t *testing.T) { Addr: "2001:db8::4", VRFName: "vrf2", Password: "password2", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, - VRF: "vrf2", - IPV4Prefixes: []string{}, - IPV6Prefixes: []string{}, + VRF: "vrf2", }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -1975,12 +1763,8 @@ func TestConversion(t *testing.T) { expected: &frr.Config{ Routers: []*frr.RouterConfig{ { - MyASN: 65001, - RouterID: "192.0.2.1", - Neighbors: []*frr.NeighborConfig{}, - VRF: "", - IPV4Prefixes: []string{}, - IPV6Prefixes: []string{}, + MyASN: 65001, + RouterID: "192.0.2.1", }, }, BFDProfiles: []frr.BFDProfile{}, @@ -2032,15 +1816,10 @@ func TestConversion(t *testing.T) { expected: &frr.Config{ Routers: []*frr.RouterConfig{ { - MyASN: 65001, - RouterID: "192.0.2.1", - Neighbors: []*frr.NeighborConfig{}, - VRF: "", - IPV4Prefixes: []string{}, - IPV6Prefixes: []string{}, + MyASN: 65001, + RouterID: "192.0.2.1", }, }, - BFDProfiles: []frr.BFDProfile{}, ExtraConfig: "bar\nfoo\nbar\nbaz\n", }, err: nil, @@ -2090,16 +1869,6 @@ func TestConversion(t *testing.T) { ASN: 65041, Addr: "192.0.2.21", BFDProfile: "bfd1", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - All: false, - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, - AlwaysBlock: []frr.IncomingFilter{}, }, }, }, @@ -2416,14 +2185,6 @@ func TestConversion(t *testing.T) { Name: "65011@192.0.2.6", ASN: 65011, Addr: "192.0.2.6", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, AlwaysBlock: []frr.IncomingFilter{ { IPFamily: ipfamily.IPv4, @@ -2437,9 +2198,6 @@ func TestConversion(t *testing.T) { }, }, }, - VRF: "", - IPV4Prefixes: []string{}, - IPV6Prefixes: []string{}, }, { MyASN: 65013, @@ -2451,14 +2209,6 @@ func TestConversion(t *testing.T) { ASN: 65014, Addr: "2001:db8::4", VRFName: "vrf2", - Outgoing: frr.AllowedOut{ - PrefixesV4: []frr.OutgoingFilter{}, - PrefixesV6: []frr.OutgoingFilter{}, - }, - Incoming: frr.AllowedIn{ - PrefixesV4: []frr.IncomingFilter{}, - PrefixesV6: []frr.IncomingFilter{}, - }, AlwaysBlock: []frr.IncomingFilter{ { IPFamily: ipfamily.IPv4, @@ -2472,12 +2222,9 @@ func TestConversion(t *testing.T) { }, }, }, - VRF: "vrf2", - IPV4Prefixes: []string{}, - IPV6Prefixes: []string{}, + VRF: "vrf2", }, }, - BFDProfiles: []frr.BFDProfile{}, }, err: nil, }, @@ -2636,9 +2383,7 @@ func TestConversion(t *testing.T) { IPV6Prefixes: []string{"2001:db9::/64"}, }, }, - BFDProfiles: []frr.BFDProfile{}, }, - secrets: map[string]v1.Secret{}, }, { name: "Multiple Routers import non existing VRFs",