mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 19:28:16 +00:00
Validate Except of IPBlock for NetworkPolicy spec
This patch enhances the validation of Except field that the values will be rejected if they are not strictly within the CIDR range.
This commit is contained in:
@@ -715,6 +715,26 @@ func TestValidateNetworkPolicy(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
"except IP is not strictly within CIDR range": {
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"},
|
||||
Spec: networking.NetworkPolicySpec{
|
||||
PodSelector: metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{"a": "b"},
|
||||
},
|
||||
Ingress: []networking.NetworkPolicyIngressRule{
|
||||
{
|
||||
From: []networking.NetworkPolicyPeer{
|
||||
{
|
||||
IPBlock: &networking.IPBlock{
|
||||
CIDR: "192.168.0.0/24",
|
||||
Except: []string{"192.168.0.0/24"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"except IPv6 is outside of CIDR range": {
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"},
|
||||
Spec: networking.NetworkPolicySpec{
|
||||
|
||||
Reference in New Issue
Block a user