Skip to content
Snippets Groups Projects
Commit 6bf07d4e authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-6105 add netpol required values unittests' (#687) from OZG-6105 into master

parents 978b9fd3 10b90e12
No related branches found
No related tags found
No related merge requests found
...@@ -28,20 +28,26 @@ release: ...@@ -28,20 +28,26 @@ release:
namespace: by-helm-test namespace: by-helm-test
templates: templates:
- templates/network_policy.yaml - templates/network_policy.yaml
tests:
- it: should match apiVersion
set: set:
networkPolicy: networkPolicy:
dnsServerNamespace: kube-system dnsServerNamespace: kube-system
ssoPublicIp: 1.1.1.1/32
tests:
- it: should match apiVersion
asserts: asserts:
- isAPIVersion: - isAPIVersion:
of: networking.k8s.io/v1 of: networking.k8s.io/v1
- it: should match kind - it: should match kind
set:
networkPolicy:
dnsServerNamespace: kube-system
asserts: asserts:
- isKind: - isKind:
of: NetworkPolicy of: NetworkPolicy
- it: validate metadata - it: validate metadata
set:
networkPolicy:
dnsServerNamespace: kube-system
asserts: asserts:
- equal: - equal:
path: metadata path: metadata
...@@ -50,6 +56,9 @@ tests: ...@@ -50,6 +56,9 @@ tests:
namespace: by-helm-test namespace: by-helm-test
- it: should add egress rule to administration service - it: should add egress rule to administration service
set:
networkPolicy:
dnsServerNamespace: kube-system
asserts: asserts:
- contains: - contains:
path: spec.egress path: spec.egress
...@@ -84,7 +93,6 @@ tests: ...@@ -84,7 +93,6 @@ tests:
- it: should add additionalIngressConfig local - it: should add additionalIngressConfig local
set: set:
networkPolicy: networkPolicy:
ssoPublicIp: 51.89.117.53/32
dnsServerNamespace: test-namespace-dns dnsServerNamespace: test-namespace-dns
additionalIngressConfigLocal: additionalIngressConfigLocal:
- from: - from:
...@@ -102,7 +110,6 @@ tests: ...@@ -102,7 +110,6 @@ tests:
- it: should add additionalIngressConfig global - it: should add additionalIngressConfig global
set: set:
networkPolicy: networkPolicy:
ssoPublicIp: 51.89.117.53/32
dnsServerNamespace: test-namespace-dns dnsServerNamespace: test-namespace-dns
additionalIngressConfigGlobal: additionalIngressConfigGlobal:
- from: - from:
...@@ -121,7 +128,6 @@ tests: ...@@ -121,7 +128,6 @@ tests:
- it: should add additionalEgressConfig local - it: should add additionalEgressConfig local
set: set:
networkPolicy: networkPolicy:
ssoPublicIp: 51.89.117.53/32
dnsServerNamespace: test-dns-namespace dnsServerNamespace: test-dns-namespace
additionalEgressConfigLocal: additionalEgressConfigLocal:
- to: - to:
...@@ -138,7 +144,6 @@ tests: ...@@ -138,7 +144,6 @@ tests:
- it: should add additionalEgressConfig global - it: should add additionalEgressConfig global
set: set:
networkPolicy: networkPolicy:
ssoPublicIp: 51.89.117.53/32
dnsServerNamespace: test-dns-namespace dnsServerNamespace: test-dns-namespace
additionalEgressConfigGlobal: additionalEgressConfigGlobal:
- to: - to:
...@@ -164,9 +169,23 @@ tests: ...@@ -164,9 +169,23 @@ tests:
- it: test network policy unset should be disabled - it: test network policy unset should be disabled
set: set:
networkPolicy: networkPolicy:
ssoPublicIp: 1.1.1.1
disabled: false disabled: false
dnsServerNamespace: test-dns-server-namespace dnsServerNamespace: test-dns-server-namespace
asserts: asserts:
- hasDocuments: - hasDocuments:
count: 1 count: 1
- it: test network policy dnsServerNamespace must be set message
set:
networkPolicy:
disabled: false
asserts:
- failedTemplate:
errorMessage: networkPolicy.dnsServerNamespace must be set
- it: test network policy should be enabled by default
set:
networkPolicy:
dnsServerNamespace: test-dns-server-namespace
asserts:
- hasDocuments:
count: 1
\ No newline at end of file
...@@ -28,20 +28,26 @@ release: ...@@ -28,20 +28,26 @@ release:
namespace: by-helm-test namespace: by-helm-test
templates: templates:
- templates/network_policy.yaml - templates/network_policy.yaml
tests:
- it: should match apiVersion
set: set:
networkPolicy: networkPolicy:
dnsServerNamespace: kube-system dnsServerNamespace: kube-system
ssoPublicIp: 1.1.1.1/32
tests:
- it: should match apiVersion
asserts: asserts:
- isAPIVersion: - isAPIVersion:
of: networking.k8s.io/v1 of: networking.k8s.io/v1
- it: should match kind - it: should match kind
set:
networkPolicy:
dnsServerNamespace: kube-system
asserts: asserts:
- isKind: - isKind:
of: NetworkPolicy of: NetworkPolicy
- it: validate metadata - it: validate metadata
set:
networkPolicy:
dnsServerNamespace: kube-system
asserts: asserts:
- equal: - equal:
path: metadata path: metadata
...@@ -75,7 +81,6 @@ tests: ...@@ -75,7 +81,6 @@ tests:
- it: should add additionalIngressConfig local - it: should add additionalIngressConfig local
set: set:
networkPolicy: networkPolicy:
ssoPublicIp: 51.89.117.53/32
dnsServerNamespace: test-namespace-dns dnsServerNamespace: test-namespace-dns
additionalIngressConfigLocal: additionalIngressConfigLocal:
- from: - from:
...@@ -93,7 +98,6 @@ tests: ...@@ -93,7 +98,6 @@ tests:
- it: should add additionalIngressConfig global - it: should add additionalIngressConfig global
set: set:
networkPolicy: networkPolicy:
ssoPublicIp: 51.89.117.53/32
dnsServerNamespace: test-namespace-dns dnsServerNamespace: test-namespace-dns
additionalIngressConfigGlobal: additionalIngressConfigGlobal:
- from: - from:
...@@ -112,7 +116,6 @@ tests: ...@@ -112,7 +116,6 @@ tests:
- it: should add additionalEgressConfig local - it: should add additionalEgressConfig local
set: set:
networkPolicy: networkPolicy:
ssoPublicIp: 51.89.117.53/32
dnsServerNamespace: test-dns-namespace dnsServerNamespace: test-dns-namespace
additionalEgressConfigLocal: additionalEgressConfigLocal:
- to: - to:
...@@ -129,7 +132,6 @@ tests: ...@@ -129,7 +132,6 @@ tests:
- it: should add additionalEgressConfig global - it: should add additionalEgressConfig global
set: set:
networkPolicy: networkPolicy:
ssoPublicIp: 51.89.117.53/32
dnsServerNamespace: test-dns-namespace dnsServerNamespace: test-dns-namespace
additionalEgressConfigGlobal: additionalEgressConfigGlobal:
- to: - to:
...@@ -155,9 +157,23 @@ tests: ...@@ -155,9 +157,23 @@ tests:
- it: test network policy unset should be disabled - it: test network policy unset should be disabled
set: set:
networkPolicy: networkPolicy:
ssoPublicIp: 1.1.1.1
disabled: false disabled: false
dnsServerNamespace: test-dns-server-namespace dnsServerNamespace: test-dns-server-namespace
asserts: asserts:
- hasDocuments: - hasDocuments:
count: 1 count: 1
- it: test network policy dnsServerNamespace must be set message
set:
networkPolicy:
disabled: false
asserts:
- failedTemplate:
errorMessage: networkPolicy.dnsServerNamespace must be set
- it: test network policy should be enabled by default
set:
networkPolicy:
dnsServerNamespace: test-dns-server-namespace
asserts:
- hasDocuments:
count: 1
\ No newline at end of file
...@@ -28,21 +28,30 @@ release: ...@@ -28,21 +28,30 @@ release:
namespace: by-helm-test namespace: by-helm-test
templates: templates:
- templates/network_policy.yaml - templates/network_policy.yaml
tests:
- it: should match apiVersion
set: set:
networkPolicy: networkPolicy:
dnsServerNamespace: kube-system dnsServerNamespace: kube-system
ssoPublicIp: 1.1.1.1/32 ssoPublicIp: 1.1.1.1/32
tests:
- it: should match apiVersion
asserts: asserts:
- isAPIVersion: - isAPIVersion:
of: networking.k8s.io/v1 of: networking.k8s.io/v1
- it: should match kind - it: should match kind
set:
networkPolicy:
dnsServerNamespace: kube-system
ssoPublicIp: 1.1.1.1/32
asserts: asserts:
- isKind: - isKind:
of: NetworkPolicy of: NetworkPolicy
- it: validate metadata - it: validate metadata
set:
networkPolicy:
dnsServerNamespace: kube-system
ssoPublicIp: 1.1.1.1/32
asserts: asserts:
- equal: - equal:
path: metadata path: metadata
...@@ -187,3 +196,31 @@ tests: ...@@ -187,3 +196,31 @@ tests:
asserts: asserts:
- hasDocuments: - hasDocuments:
count: 1 count: 1
- it: test network policy dnsServerNamespace must be set message
set:
networkPolicy:
disabled: false
ssoPublicIp: 1.1.1.1/32
asserts:
- failedTemplate:
errorMessage: networkPolicy.dnsServerNamespace must be set
- it: test network policy ssoPublicIp must be set message
set:
networkPolicy:
disabled: false
dnsServerNamespace: test-dns-server-namespace
asserts:
- failedTemplate:
errorMessage: networkPolicy.ssoPublicIp must be set
- it: test network policy should be enabled by default
set:
networkPolicy:
ssoPublicIp: 1.1.1.1
dnsServerNamespace: test-dns-server-namespace
asserts:
- hasDocuments:
count: 1
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment