Skip to content

Commit

Permalink
test : netpol with empty port range
Browse files Browse the repository at this point in the history
  • Loading branch information
shireenf-ibm committed Dec 2, 2024
1 parent 606c64f commit a86298f
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/netpol/connlist/connlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,10 @@ var goodPathTests = []struct {
testDirName: "anp_test_with_empty_port_range",
outputFormats: []string{output.DefaultFormat},
},
{
testDirName: "np_test_with_empty_port_range",
outputFormats: []string{output.DefaultFormat},
},
}

func runParsedResourcesConnlistTests(t *testing.T, testList []examples.ParsedResourcesTest) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
0.0.0.0-255.255.255.255 => ns1/pod1[Deployment] : All Connections
0.0.0.0-255.255.255.255 => ns2/pod1[Deployment] : All Connections
ns1/pod1[Deployment] => 0.0.0.0-255.255.255.255 : UDP 3535
ns1/pod1[Deployment] => ns2/pod1[Deployment] : UDP 3535
ns2/pod1[Deployment] => 0.0.0.0-255.255.255.255 : All Connections
ns2/pod1[Deployment] => ns1/pod1[Deployment] : All Connections
16 changes: 16 additions & 0 deletions tests/np_test_with_empty_port_range/netpol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: egress-empty-port-range
namespace: ns1
spec:
podSelector: {}
policyTypes:
- Egress
egress:
- ports:
- port: 3535
protocol: UDP
- port: 10
endPort: 1
protocol: TCP
67 changes: 67 additions & 0 deletions tests/np_test_with_empty_port_range/pods.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: ns1
spec: {}
---
apiVersion: v1
kind: Namespace
metadata:
name: ns2
spec: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: pod1
namespace: ns1
labels:
app: a-app
spec:
selector:
matchLabels:
app: a-app
template:
metadata:
labels:
app: a-app
spec:
containers:
- name: ns1
image: quay.io/shfa/ns1:latest
ports:
- containerPort: 80
- containerPort: 81
- containerPort: 80
protocol: UDP
- containerPort: 81
protocol: UDP
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: pod1
namespace: ns2
labels:
app: a-app
spec:
selector:
matchLabels:
app: a-app
template:
metadata:
labels:
app: a-app
spec:
containers:
- name: ns2
image: quay.io/shfa/ns2:latest
ports:
- containerPort: 80
- containerPort: 81
- containerPort: 80
protocol: UDP
- containerPort: 81
protocol: UDP
---

0 comments on commit a86298f

Please sign in to comment.