Added helm unit tests for automountServiceAccountToken for all serviceAccounts/Workloads
Signed-off-by: Aran Shavit <Aranshavit@gmail.com>
This commit is contained in:
parent
a822382b95
commit
8216d88c7c
7 changed files with 148 additions and 0 deletions
|
@ -0,0 +1,12 @@
|
|||
suite: Admission Webhooks > Create Secret Job
|
||||
templates:
|
||||
- admission-webhooks/job-patch/job-createSecret.yaml
|
||||
|
||||
tests:
|
||||
- it: should create a Job with token auto-mounting disabled if `controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken` is false
|
||||
set:
|
||||
controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken: false
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.automountServiceAccountToken
|
||||
value: false
|
|
@ -0,0 +1,12 @@
|
|||
suite: Admission Webhooks > Patch Webhook Job
|
||||
templates:
|
||||
- admission-webhooks/job-patch/job-patchWebhook.yaml
|
||||
|
||||
tests:
|
||||
- it: should create a Job with token auto-mounting disabled if `controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken` is false
|
||||
set:
|
||||
controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken: false
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.automountServiceAccountToken
|
||||
value: false
|
|
@ -190,3 +190,12 @@ tests:
|
|||
- equal:
|
||||
path: spec.template.spec.containers[0].image
|
||||
value: registry.k8s.io/ingress-nginx/controller:custom-tag@sha256:faa2d18687f734994b6bd9e309e7a73852a81c30e1b8f63165fcd4f0a087e3cd
|
||||
|
||||
- it: should create a DaemonSet with token auto-mounting disabled if `serviceAccount.automountServiceAccountToken` is false
|
||||
set:
|
||||
controller.kind: DaemonSet
|
||||
serviceAccount.automountServiceAccountToken: false
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.automountServiceAccountToken
|
||||
value: false
|
||||
|
|
|
@ -215,3 +215,11 @@ tests:
|
|||
- equal:
|
||||
path: spec.progressDeadlineSeconds
|
||||
value: 111
|
||||
|
||||
- it: should create a Deployment with token auto-mounting disabled if `serviceAccount.automountServiceAccountToken` is false
|
||||
set:
|
||||
serviceAccount.automountServiceAccountToken: false
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.automountServiceAccountToken
|
||||
value: false
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
suite: Controller > ServiceAccount
|
||||
templates:
|
||||
- controller-serviceaccount.yaml
|
||||
|
||||
tests:
|
||||
- it: should not create a ServiceAccount if `serviceAccount.create` is false
|
||||
set:
|
||||
serviceAccount.create: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
- it: should create a ServiceAccount if `serviceAccount.create` is true
|
||||
set:
|
||||
serviceAccount.create: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- isKind:
|
||||
of: ServiceAccount
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-ingress-nginx
|
||||
|
||||
- it: should create a ServiceAccount with specified name if `serviceAccount.name` is set
|
||||
set:
|
||||
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: should create a ServiceAccount with token auto-mounting disabled if `serviceAccount.automountServiceAccountToken` is false
|
||||
set:
|
||||
serviceAccount.automountServiceAccountToken: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- isKind:
|
||||
of: ServiceAccount
|
||||
- equal:
|
||||
path: automountServiceAccountToken
|
||||
value: false
|
|
@ -187,3 +187,12 @@ tests:
|
|||
- equal:
|
||||
path: spec.template.spec.containers[0].image
|
||||
value: registry.k8s.io/defaultbackend-amd64:custom-tag@sha256:faa2d18687f734994b6bd9e309e7a73852a81c30e1b8f63165fcd4f0a087e3cd
|
||||
|
||||
- it: should create a Deployment with token auto-mounting disabled if `defaultBackend.serviceAccount.automountServiceAccountToken` is false
|
||||
set:
|
||||
defaultBackend.enabled: true
|
||||
defaultBackend.serviceAccount.automountServiceAccountToken: false
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.automountServiceAccountToken
|
||||
value: false
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
suite: Default Backend > ServiceAccount
|
||||
templates:
|
||||
- default-backend-serviceaccount.yaml
|
||||
|
||||
tests:
|
||||
- it: should not create a ServiceAccount if `defaultBackend.serviceAccount.create` is false
|
||||
set:
|
||||
defaultBackend.enabled: true
|
||||
defaultBackend.serviceAccount.create: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
- it: should create a ServiceAccount if `defaultBackend.serviceAccount.create` is true
|
||||
set:
|
||||
defaultBackend.enabled: true
|
||||
defaultBackend.serviceAccount.create: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- isKind:
|
||||
of: ServiceAccount
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-ingress-nginx-backend
|
||||
|
||||
- it: should create a ServiceAccount with specified name if `defaultBackend.serviceAccount.name` is set
|
||||
set:
|
||||
defaultBackend.enabled: true
|
||||
defaultBackend.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: should create a ServiceAccount with token auto-mounting disabled if `defaultBackend.serviceAccount.automountServiceAccountToken` is false
|
||||
set:
|
||||
defaultBackend.enabled: true
|
||||
defaultBackend.serviceAccount.automountServiceAccountToken: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- isKind:
|
||||
of: ServiceAccount
|
||||
- equal:
|
||||
path: automountServiceAccountToken
|
||||
value: false
|
Loading…
Reference in a new issue