Skip to content

Commit

Permalink
Add helm chart tests for admission-webhooks (#11375)
Browse files Browse the repository at this point in the history
Signed-off-by: Reddysekhar Gaduputi <[email protected]>
  • Loading branch information
rgaduput committed May 29, 2024
1 parent 3ba71ec commit 4a74fee
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
suite: AdmissionWebhooks > RBAC > ClusterRole
templates:
- admission-webhooks/job-patch/clusterrole.yaml

tests:
- it: should not create ClusterRole if `controller.admissionWebhooks.rbac.create` is false
set:
controller.admissionWebhooks.rbac.create: false
asserts:
- hasDocuments:
count: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
suite: AdmissionWebhooks > RBAC > ClusterRoleBinding
templates:
- admission-webhooks/job-patch/clusterrolebinding.yaml

tests:
- it: should not create ClusterRoleBinding if `controller.admissionWebhooks.rbac.create` is false
set:
controller.admissionWebhooks.rbac.create: false
asserts:
- hasDocuments:
count: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
suite: AdmissionWebhooks > RBAC > Role
templates:
- admission-webhooks/job-patch/role.yaml

tests:
- it: should not create Role if `controller.admissionWebhooks.rbac.create` is false
set:
controller.admissionWebhooks.rbac.create: false
asserts:
- hasDocuments:
count: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
suite: AdmissionWebhooks > RBAC > RoleBinding
templates:
- admission-webhooks/job-patch/rolebinding.yaml

tests:
- it: should not create RoleBinding if `controller.admissionWebhooks.rbac.create` is false
set:
controller.admissionWebhooks.rbac.create: false
asserts:
- hasDocuments:
count: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
suite: AdmissionWebhooks > ServiceAccount
templates:
- admission-webhooks/serviceaccount.yaml

tests:
- it: should not create a ServiceAccount if `controller.admissionWebhooks.serviceAccount.create` is false
set:
controller.admissionWebhooks.serviceAccount.create: false
asserts:
- hasDocuments:
count: 0

- it: should create a ServiceAccount if `controller.admissionWebhooks.serviceAccount.create` is true
set:
controller.admissionWebhooks.serviceAccount.create: true
asserts:
- hasDocuments:
count: 1
- isKind:
of: ServiceAccount
- equal:
path: metadata.name
value: ingress-nginx-admission

- it: should create a ServiceAccount with specified name if `controller.admissionWebhooks.serviceAccount.name` is set to non-empty value
set:
controller.admissionWebhooks.serviceAccount.name: ingress-nginx-admission-test-sa
asserts:
- hasDocuments:
count: 1
- isKind:
of: ServiceAccount
- equal:
path: metadata.name
value: ingress-nginx-admission-test-sa

- it: automountServiceAccountToken in ServiceAccount should be false if `controller.admissionWebhooks.serviceAccount.automountServiceAccountToken` is false
set:
controller.admissionWebhooks.serviceAccount.automountServiceAccountToken: false
asserts:
- hasDocuments:
count: 1
- isKind:
of: ServiceAccount
- equal:
path: automountServiceAccountToken
value: false

0 comments on commit 4a74fee

Please sign in to comment.