webhook_test.yaml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. suite: test webhook deployment
  2. templates:
  3. - webhook-deployment.yaml
  4. - webhook-secret.yaml
  5. - webhook-certificate.yaml
  6. - validatingwebhook.yaml
  7. - crds/externalsecret.yaml
  8. tests:
  9. - it: should match snapshot of default values
  10. asserts:
  11. - matchSnapshot: {}
  12. templates:
  13. - webhook-deployment.yaml
  14. - webhook-secret.yaml
  15. # webhook-certificate.yaml is not rendered by default
  16. - it: should set imagePullPolicy to Always
  17. set:
  18. webhook.image.pullPolicy: Always
  19. asserts:
  20. - equal:
  21. path: spec.template.spec.containers[0].imagePullPolicy
  22. value: Always
  23. template: webhook-deployment.yaml
  24. - it: should imagePullPolicy to be default value IfNotPresent
  25. asserts:
  26. - equal:
  27. path: spec.template.spec.containers[0].imagePullPolicy
  28. value: IfNotPresent
  29. template: webhook-deployment.yaml
  30. - it: should override securityContext
  31. set:
  32. webhook.podSecurityContext:
  33. runAsUser: 2000
  34. webhook.securityContext:
  35. runAsUser: 3000
  36. asserts:
  37. - equal:
  38. path: spec.template.spec.securityContext
  39. value:
  40. runAsUser: 2000
  41. - equal:
  42. path: spec.template.spec.containers[0].securityContext
  43. value:
  44. allowPrivilegeEscalation: false
  45. capabilities:
  46. drop:
  47. - ALL
  48. readOnlyRootFilesystem: true
  49. runAsNonRoot: true
  50. runAsUser: 3000
  51. seccompProfile:
  52. type: RuntimeDefault
  53. template: webhook-deployment.yaml
  54. - it: should override hostNetwork
  55. set:
  56. webhook.hostNetwork: true
  57. asserts:
  58. - equal:
  59. path: spec.template.spec.hostNetwork
  60. value: true
  61. template: webhook-deployment.yaml
  62. - it: should create a certificate CRD
  63. set:
  64. webhook.certManager.enabled: true
  65. webhook.certManager.cert.duration: "10d"
  66. webhook.certManager.cert.renewBefore: "5d"
  67. asserts:
  68. - equal:
  69. path: metadata.name
  70. value: "RELEASE-NAME-external-secrets-webhook"
  71. - equal:
  72. path: spec.secretName
  73. value: "RELEASE-NAME-external-secrets-webhook"
  74. - equal:
  75. path: spec.commonName
  76. value: "RELEASE-NAME-external-secrets-webhook"
  77. - equal:
  78. path: spec.dnsNames[0]
  79. value: "RELEASE-NAME-external-secrets-webhook"
  80. - equal:
  81. path: spec.issuerRef.group
  82. value: "cert-manager.io"
  83. - equal:
  84. path: spec.issuerRef.kind
  85. value: "Issuer"
  86. - equal:
  87. path: spec.issuerRef.name
  88. value: "my-issuer"
  89. - equal:
  90. path: spec.duration
  91. value: "10d"
  92. - equal:
  93. path: spec.renewBefore
  94. value: "5d"
  95. - hasDocuments:
  96. count: 1
  97. templates:
  98. - webhook-certificate.yaml
  99. - it: should not create the webhook secret
  100. set:
  101. webhook.certManager.enabled: true
  102. asserts:
  103. - hasDocuments:
  104. count: 0
  105. template: webhook-secret.yaml
  106. - it: should not create the secret nor the certificate
  107. set:
  108. webhook.certManager.enabled: true
  109. webhook.certManager.cert.create: false
  110. asserts:
  111. - hasDocuments:
  112. count: 0
  113. templates:
  114. - webhook-secret.yaml
  115. - webhook-certificate.yaml
  116. - it: also should not create the secret nor the certificate
  117. set:
  118. webhook.certManager.enabled: false
  119. webhook.createWebhookSecret: false
  120. asserts:
  121. - hasDocuments:
  122. count: 0
  123. templates:
  124. - webhook-secret.yaml
  125. - webhook-certificate.yaml
  126. - it: should
  127. set:
  128. webhook.certManager.enabled: true
  129. asserts:
  130. - equal:
  131. path: metadata.name
  132. value: "RELEASE-NAME-external-secrets-webhook"
  133. - hasDocuments:
  134. count: 1
  135. template: webhook-certificate.yaml
  136. - it: should allow using a cluster issuer
  137. set:
  138. webhook.certManager.enabled: true
  139. webhook.certManager.cert.issuerRef.kind: ClusterIssuer
  140. webhook.certManager.cert.issuerRef.name: my-other-issuer
  141. asserts:
  142. - equal:
  143. path: spec.issuerRef.kind
  144. value: "ClusterIssuer"
  145. - equal:
  146. path: spec.issuerRef.name
  147. value: "my-other-issuer"
  148. templates:
  149. - webhook-certificate.yaml
  150. - it: should add annotations to the webhook
  151. set:
  152. webhook.create: true
  153. webhook.certManager.enabled: true
  154. webhook.certManager.addInjectorAnnotations: true
  155. asserts:
  156. - equal:
  157. path: metadata.annotations["cert-manager.io/inject-ca-from"]
  158. value: "NAMESPACE/RELEASE-NAME-external-secrets-webhook"
  159. templates:
  160. - validatingwebhook.yaml
  161. - crds/externalsecret.yaml
  162. - it: should not add annotations to the webhook
  163. set:
  164. webhook.create: true
  165. webhook.certManager.enabled: true
  166. webhook.certManager.addInjectorAnnotations: false
  167. asserts:
  168. - isNull:
  169. path: metadata.annotations["cert-manager.io/inject-ca-from"]
  170. # value: "NAMESPACE/RELEASE-NAME-external-secrets-webhook"
  171. templates:
  172. - validatingwebhook.yaml
  173. - crds/externalsecret.yaml
  174. - it: should add annotations, necessary when using a custom secret, to the webhook
  175. set:
  176. certController.create: false
  177. webhook.create: true
  178. webhook.certManager.enabled: true
  179. webhook.certManager.cert.create: false
  180. webhook.certManager.addInjectorAnnotationsFromSecret: true
  181. webhook.certManager.addInjectorAnnotations: false
  182. asserts:
  183. - equal:
  184. path: metadata.annotations["cert-manager.io/inject-ca-from-secret"]
  185. value: "NAMESPACE/RELEASE-NAME-external-secrets-webhook"
  186. templates:
  187. - validatingwebhook.yaml
  188. - crds/externalsecret.yaml
  189. - it: should not add injector annotations for the *custom secret*
  190. set:
  191. webhook.certManager.addInjectorAnnotationsFromSecret: false
  192. webhook.certManager.addInjectorAnnotations: false
  193. asserts:
  194. - isNull:
  195. path: metadata.annotations["cert-manager.io/inject-ca-from-secret"]
  196. templates:
  197. - validatingwebhook.yaml
  198. - crds/externalsecret.yaml
  199. - it: should override the name of the certificates Secret
  200. set:
  201. webhook.certSecretNameOverride: custom-secret-name
  202. asserts:
  203. - equal:
  204. path: metadata.name
  205. value: custom-secret-name
  206. template: webhook-secret.yaml
  207. - it: should override the name of the certificates Secret created by cert-manager
  208. set:
  209. webhook.certManager.enabled: true
  210. webhook.certSecretNameOverride: custom-secret-name
  211. asserts:
  212. - equal:
  213. path: spec.secretName
  214. value: custom-secret-name
  215. template: webhook-certificate.yaml