-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecfd100
commit eab19b5
Showing
6 changed files
with
140 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: pol4 | ||
namespace: ns-y | ||
spec: | ||
egress: | ||
- {} | ||
ingress: | ||
- from: | ||
- podSelector: {} | ||
podSelector: {} | ||
policyTypes: | ||
- Ingress | ||
- Egress | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: pol5 | ||
namespace: ns-y | ||
spec: | ||
ingress: | ||
- from: | ||
- namespaceSelector: {} | ||
ports: | ||
- port: 8080 | ||
protocol: TCP | ||
podSelector: {} | ||
policyTypes: | ||
- Ingress | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: pol6 | ||
namespace: ns-y | ||
spec: | ||
ingress: | ||
- from: | ||
- namespaceSelector: {} | ||
podSelector: | ||
matchLabels: | ||
app: qrs | ||
policyTypes: | ||
- Ingress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
apiVersion: v1 | ||
items: | ||
- apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: pol1 | ||
namespace: ns-y | ||
spec: | ||
egress: | ||
- {} | ||
ingress: | ||
- from: | ||
- podSelector: {} | ||
podSelector: {} | ||
policyTypes: | ||
- Ingress | ||
- Egress | ||
- apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: pol2 | ||
namespace: ns-y | ||
spec: | ||
ingress: | ||
- from: | ||
- namespaceSelector: {} | ||
ports: | ||
- port: 8080 | ||
protocol: TCP | ||
podSelector: {} | ||
policyTypes: | ||
- Ingress | ||
- apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: pol3 | ||
namespace: ns-y | ||
spec: | ||
ingress: | ||
- from: | ||
- namespaceSelector: {} | ||
podSelector: | ||
matchLabels: | ||
app: qrs | ||
policyTypes: | ||
- Ingress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package kube | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func RunReadNetworkPolicyTests() { | ||
Describe("ReadNetworkPolicies", func() { | ||
It("Should read a single policy from a single file", func() { | ||
policies, err := ReadNetworkPoliciesFromPath("../../networkpolicies/features/portrange1.yaml") | ||
Expect(err).To(BeNil()) | ||
Expect(len(policies)).To(Equal(1)) | ||
}) | ||
It("Should read a list of policies from a single file", func() { | ||
policies, err := ReadNetworkPoliciesFromPath("../../networkpolicies/yaml-syntax/yaml-list.yaml") | ||
Expect(err).To(BeNil()) | ||
Expect(len(policies)).To(Equal(3)) | ||
}) | ||
It("Should read multiple policies separated by '---' lines from a single file", func() { | ||
policies, err := ReadNetworkPoliciesFromPath("../../networkpolicies/yaml-syntax/triple-dash-separated.yaml") | ||
Expect(err).To(BeNil()) | ||
Expect(len(policies)).To(Equal(3)) | ||
}) | ||
It("Should read multiple policies from all files in a directory", func() { | ||
policies, err := ReadNetworkPoliciesFromPath("../../networkpolicies/yaml-syntax") | ||
Expect(err).To(BeNil()) | ||
Expect(len(policies)).To(Equal(6)) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters