@@ -1165,7 +1165,45 @@ var _ = Describe("Multi Homing", func() {
11651165 metav1.LabelSelector {
11661166 MatchLabels : map [string ]string {"role" : "trusted" },
11671167 },
1168- port ,
1168+ multiNetPolicyPort (port ),
1169+ ),
1170+ ),
1171+ ginkgo .Entry (
1172+ "using pod selectors and port range for a pure L2 overlay" ,
1173+ networkAttachmentConfigParams {
1174+ name : secondaryNetworkName ,
1175+ topology : "layer2" ,
1176+ cidr : secondaryFlatL2NetworkCIDR ,
1177+ },
1178+ podConfiguration {
1179+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
1180+ name : allowedClient (clientPodName ),
1181+ labels : map [string ]string {
1182+ "app" : "client" ,
1183+ "role" : "trusted" ,
1184+ },
1185+ },
1186+ podConfiguration {
1187+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
1188+ name : blockedClient (clientPodName ),
1189+ labels : map [string ]string {"app" : "client" },
1190+ },
1191+ podConfiguration {
1192+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
1193+ name : podName ,
1194+ containerCmd : httpServerContainerCmd (port ),
1195+ labels : map [string ]string {"app" : "stuff-doer" },
1196+ },
1197+ multiNetIngressLimitingPolicy (
1198+ secondaryNetworkName ,
1199+ metav1.LabelSelector {
1200+ MatchLabels : map [string ]string {"app" : "stuff-doer" },
1201+ },
1202+ metav1.LabelSelector {
1203+ MatchLabels : map [string ]string {"role" : "trusted" },
1204+ },
1205+ // build a random range around the port we are actually trying to allow without explicitly setting it
1206+ multiNetPolicyPortRange (port - 3 , port + 5 ),
11691207 ),
11701208 ),
11711209 ginkgo .Entry (
@@ -1202,7 +1240,7 @@ var _ = Describe("Multi Homing", func() {
12021240 metav1.LabelSelector {
12031241 MatchLabels : map [string ]string {"role" : "trusted" },
12041242 },
1205- port ,
1243+ multiNetPolicyPort ( port ) ,
12061244 ),
12071245 ),
12081246 ginkgo .Entry (
@@ -1239,7 +1277,7 @@ var _ = Describe("Multi Homing", func() {
12391277 metav1.LabelSelector {
12401278 MatchLabels : map [string ]string {"role" : "trusted" },
12411279 },
1242- port ,
1280+ multiNetPolicyPort ( port ) ,
12431281 ),
12441282 ),
12451283 ginkgo .Entry (
@@ -1608,7 +1646,7 @@ var _ = Describe("Multi Homing", func() {
16081646 )
16091647
16101648 ginkgo .DescribeTable (
1611- "deny all " ,
1649+ "deny traffic " ,
16121650 func (netConfigParams networkAttachmentConfigParams , clientPodConfig podConfiguration , serverPodConfig podConfiguration , policy * mnpapi.MultiNetworkPolicy ) {
16131651 netConfig := newNetworkAttachmentConfig (netConfigParams )
16141652
@@ -1670,6 +1708,39 @@ var _ = Describe("Multi Homing", func() {
16701708 nil ,
16711709 ),
16721710 ),
1711+ ginkgo .Entry (
1712+ "using pod selectors and wrong port range for a localnet topology" ,
1713+ networkAttachmentConfigParams {
1714+ name : secondaryNetworkName ,
1715+ topology : "localnet" ,
1716+ cidr : secondaryLocalnetNetworkCIDR ,
1717+ },
1718+ podConfiguration {
1719+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
1720+ name : allowedClient (clientPodName ),
1721+ labels : map [string ]string {
1722+ "app" : "client" ,
1723+ "role" : "trusted" ,
1724+ },
1725+ },
1726+ podConfiguration {
1727+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
1728+ name : podName ,
1729+ containerCmd : httpServerContainerCmd (port ),
1730+ labels : map [string ]string {"app" : "stuff-doer" },
1731+ },
1732+ multiNetIngressLimitingPolicy (
1733+ secondaryNetworkName ,
1734+ metav1.LabelSelector {
1735+ MatchLabels : map [string ]string {"app" : "stuff-doer" },
1736+ },
1737+ metav1.LabelSelector {
1738+ MatchLabels : map [string ]string {"role" : "trusted" },
1739+ },
1740+ // build a port range that doesn't include server port
1741+ multiNetPolicyPortRange (port - 10 , port - 1 ),
1742+ ),
1743+ ),
16731744 )
16741745 })
16751746 })
0 commit comments