@@ -77,11 +77,18 @@ func TestAddNetworkPolicy(t *testing.T) {
7777 Spec : networkingv1.NetworkPolicySpec {
7878 Ingress : []networkingv1.NetworkPolicyIngressRule {
7979 networkingv1.NetworkPolicyIngressRule {
80- From : []networkingv1.NetworkPolicyPeer {{
81- PodSelector : & metav1.LabelSelector {
82- MatchLabels : map [string ]string {"app" : "test" },
80+ From : []networkingv1.NetworkPolicyPeer {
81+ networkingv1.NetworkPolicyPeer {
82+ PodSelector : & metav1.LabelSelector {
83+ MatchLabels : map [string ]string {"app" : "test" },
84+ },
8385 },
84- }},
86+ networkingv1.NetworkPolicyPeer {
87+ IPBlock : & networkingv1.IPBlock {
88+ CIDR : "0.0.0.0/0" ,
89+ },
90+ },
91+ },
8592 Ports : []networkingv1.NetworkPolicyPort {{
8693 Protocol : & tcp ,
8794 Port : & port8000 ,
@@ -98,6 +105,17 @@ func TestAddNetworkPolicy(t *testing.T) {
98105 }
99106 npMgr .Unlock ()
100107
108+ ipsMgr = npMgr .nsMap [util .KubeAllNamespacesFlag ].ipsMgr
109+
110+ // Check whether 0.0.0.0/0 got translated to 1.0.0.0/1 and 128.0.0.0/1
111+ if ! ipsMgr .Exists ("allow-ingress-in-ns-test-nwpolicy-0in" , "1.0.0.0/1" , util .IpsetNetHashFlag ) {
112+ t .Errorf ("TestDeleteFromSet failed @ ipsMgr.AddToSet" )
113+ }
114+
115+ if ! ipsMgr .Exists ("allow-ingress-in-ns-test-nwpolicy-0in" , "128.0.0.0/1" , util .IpsetNetHashFlag ) {
116+ t .Errorf ("TestDeleteFromSet failed @ ipsMgr.AddToSet" )
117+ }
118+
101119 allowEgress := & networkingv1.NetworkPolicy {
102120 ObjectMeta : metav1.ObjectMeta {
103121 Name : "allow-egress" ,
0 commit comments