@@ -72,6 +72,34 @@ var CNPBaselineTierEgressInlineCIDRPeers = suite.ConformanceTest{
7272 serverPod .Status .PodIP , int32 (53 ), s .TimeoutConfig , true )
7373 kubernetes .PokeServer (t , s .ClientSet , & s .KubeConfig , "network-policy-conformance-gryffindor" , "harry-potter-1" , "sctp" ,
7474 serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig , true )
75+
76+ // update namespace label for slytherin to "conformance-house": "denied-namespace-label" to no longer match ingressRule at index0
77+ namespace := kubernetes .GetNamespace (t , s .Client , "network-policy-conformance-slytherin" , s .TimeoutConfig .GetTimeout )
78+ mutateNamespace := namespace .DeepCopy ()
79+ mutateNamespace .SetLabels (map [string ]string {"conformance-house" : "denied-namespace-label" })
80+ kubernetes .PatchNamespace (t , s .Client , namespace , mutateNamespace , s .TimeoutConfig .GetTimeout )
81+
82+ // ensure traffic is no longer allowed to slytherin since the namespace label no longer matches
83+ kubernetes .PokeServer (t , s .ClientSet , & s .KubeConfig , "network-policy-conformance-gryffindor" , "harry-potter-1" , "tcp" ,
84+ serverPod .Status .PodIP , int32 (80 ), s .TimeoutConfig , false )
85+ kubernetes .PokeServer (t , s .ClientSet , & s .KubeConfig , "network-policy-conformance-gryffindor" , "harry-potter-1" , "udp" ,
86+ serverPod .Status .PodIP , int32 (53 ), s .TimeoutConfig , false )
87+ kubernetes .PokeServer (t , s .ClientSet , & s .KubeConfig , "network-policy-conformance-gryffindor" , "harry-potter-1" , "sctp" ,
88+ serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig , false )
89+
90+ // update namespace label for slytherin back to "conformance-house": "slytherin" to match ingressRule at index0 again
91+ namespace = kubernetes .GetNamespace (t , s .Client , "network-policy-conformance-slytherin" , s .TimeoutConfig .GetTimeout )
92+ mutateNamespace = namespace .DeepCopy ()
93+ mutateNamespace .SetLabels (map [string ]string {"conformance-house" : "slytherin" })
94+ kubernetes .PatchNamespace (t , s .Client , namespace , mutateNamespace , s .TimeoutConfig .GetTimeout )
95+
96+ // ensure traffic is allowed to slytherin again since the namespace label matches again
97+ kubernetes .PokeServer (t , s .ClientSet , & s .KubeConfig , "network-policy-conformance-gryffindor" , "harry-potter-1" , "tcp" ,
98+ serverPod .Status .PodIP , int32 (80 ), s .TimeoutConfig , true )
99+ kubernetes .PokeServer (t , s .ClientSet , & s .KubeConfig , "network-policy-conformance-gryffindor" , "harry-potter-1" , "udp" ,
100+ serverPod .Status .PodIP , int32 (53 ), s .TimeoutConfig , true )
101+ kubernetes .PokeServer (t , s .ClientSet , & s .KubeConfig , "network-policy-conformance-gryffindor" , "harry-potter-1" , "sctp" ,
102+ serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig , true )
75103 })
76104 // To test allow CIDR rule, insert the following rule at index0
77105 //- name: "allow-egress-to-specific-podIPs"
0 commit comments