validation_test.yaml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. suite: rbac validation test
  2. templates:
  3. - common.yaml
  4. tests:
  5. - it: should fail with name longer than 63 characters
  6. set:
  7. rbac:
  8. zmy-rbac:
  9. enabled: true
  10. primary: true
  11. my-rbac-has-super-long-name-that-is-longer-than-63-characters-too-bad:
  12. enabled: true
  13. primary: false
  14. asserts:
  15. - failedTemplate:
  16. errorMessage: Name [release-name-common-test-my-rbac-has-super-long-name-that-is-longer-than-63-characters-too-bad] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters.
  17. - it: should fail with name starting with underscore
  18. set:
  19. rbac:
  20. my-rbac:
  21. enabled: true
  22. primary: true
  23. rules:
  24. - apiGroups:
  25. - ""
  26. resources:
  27. - pods
  28. verbs:
  29. - get
  30. _my-rbac2:
  31. enabled: true
  32. primary: false
  33. asserts:
  34. - failedTemplate:
  35. errorMessage: Name [release-name-common-test-_my-rbac2] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters.
  36. - it: should fail with labels not a dict
  37. set:
  38. rbac:
  39. my-rbac:
  40. enabled: true
  41. primary: true
  42. labels: "not a dict"
  43. asserts:
  44. - failedTemplate:
  45. errorMessage: RBAC - Expected <labels> to be a dictionary, but got [string]
  46. - it: should fail with annotations not a dict
  47. set:
  48. rbac:
  49. my-rbac:
  50. enabled: true
  51. primary: true
  52. annotations: "not a dict"
  53. asserts:
  54. - failedTemplate:
  55. errorMessage: RBAC - Expected <annotations> to be a dictionary, but got [string]
  56. - it: should fail with more than 1 primary rbac
  57. set:
  58. rbac:
  59. my-rbac:
  60. enabled: true
  61. primary: true
  62. my-rbac2:
  63. enabled: true
  64. primary: true
  65. asserts:
  66. - failedTemplate:
  67. errorMessage: RBAC - Only one rbac can be primary
  68. - it: should fail without any primary on enabled rbac
  69. set:
  70. rbac:
  71. my-rbac:
  72. enabled: true
  73. primary: false
  74. my-rbac2:
  75. enabled: true
  76. primary: false
  77. asserts:
  78. - failedTemplate:
  79. errorMessage: RBAC - At least one enabled rbac must be primary
  80. - it: should fail without rules in rbac
  81. set:
  82. rbac:
  83. my-rbac:
  84. enabled: true
  85. primary: true
  86. asserts:
  87. - failedTemplate:
  88. errorMessage: RBAC - Expected non-empty <rbac.rules>
  89. - it: should fail without apiGroups in rules in rbac
  90. set:
  91. rbac:
  92. my-rbac:
  93. enabled: true
  94. primary: true
  95. rules:
  96. - resources:
  97. - pods
  98. verbs:
  99. - get
  100. asserts:
  101. - failedTemplate:
  102. errorMessage: RBAC - Expected non-empty <rbac.rules.apiGroups>
  103. - it: should fail without resources in rules in rbac
  104. set:
  105. rbac:
  106. my-rbac:
  107. enabled: true
  108. primary: true
  109. rules:
  110. - apiGroups:
  111. - ""
  112. verbs:
  113. - get
  114. asserts:
  115. - failedTemplate:
  116. errorMessage: RBAC - Expected non-empty <rbac.rules.resources>
  117. - it: should fail without verbs in rules in rbac
  118. set:
  119. rbac:
  120. my-rbac:
  121. enabled: true
  122. primary: true
  123. rules:
  124. - apiGroups:
  125. - ""
  126. resources:
  127. - pods
  128. asserts:
  129. - failedTemplate:
  130. errorMessage: RBAC - Expected non-empty <rbac.rules.verbs>
  131. - it: should fail with empty entry in resources in rules in rbac
  132. set:
  133. rbac:
  134. my-rbac:
  135. enabled: true
  136. primary: true
  137. rules:
  138. - apiGroups:
  139. - ""
  140. resources:
  141. - pods
  142. - ""
  143. verbs:
  144. - get
  145. asserts:
  146. - failedTemplate:
  147. errorMessage: RBAC - Expected non-empty entry in <rbac.rules.resources>
  148. - it: should fail with empty entry in verbs in rules in rbac
  149. set:
  150. rbac:
  151. my-rbac:
  152. enabled: true
  153. primary: true
  154. rules:
  155. - apiGroups:
  156. - ""
  157. resources:
  158. - pods
  159. verbs:
  160. - get
  161. - ""
  162. asserts:
  163. - failedTemplate:
  164. errorMessage: RBAC - Expected non-empty entry in <rbac.rules.verbs>
  165. - it: should fail with empty kind in subjects in rbac
  166. set:
  167. serviceAccount:
  168. my-service-account:
  169. enabled: true
  170. primary: true
  171. rbac:
  172. my-rbac:
  173. enabled: true
  174. primary: true
  175. rules:
  176. - apiGroups:
  177. - ""
  178. resources:
  179. - pods
  180. verbs:
  181. - get
  182. subjects:
  183. - kind: ""
  184. name: my-name
  185. apiGroup: my-apiGroup
  186. asserts:
  187. - failedTemplate:
  188. errorMessage: RBAC - Expected non-empty <rbac.subjects.kind>
  189. - it: should fail with empty name in subjects in rbac
  190. set:
  191. serviceAccount:
  192. my-service-account:
  193. enabled: true
  194. primary: true
  195. rbac:
  196. my-rbac:
  197. enabled: true
  198. primary: true
  199. rules:
  200. - apiGroups:
  201. - ""
  202. resources:
  203. - pods
  204. verbs:
  205. - get
  206. subjects:
  207. - kind: my-kind
  208. name: ""
  209. apiGroup: my-apiGroup
  210. asserts:
  211. - failedTemplate:
  212. errorMessage: RBAC - Expected non-empty <rbac.subjects.name>
  213. - it: should fail with empty apiGroup in subjects in rbac
  214. set:
  215. serviceAccount:
  216. my-service-account:
  217. enabled: true
  218. primary: true
  219. rbac:
  220. my-rbac:
  221. enabled: true
  222. primary: true
  223. rules:
  224. - apiGroups:
  225. - ""
  226. resources:
  227. - pods
  228. verbs:
  229. - get
  230. subjects:
  231. - kind: my-kind
  232. name: my-name
  233. apiGroup: ""
  234. asserts:
  235. - failedTemplate:
  236. errorMessage: RBAC - Expected non-empty <rbac.subjects.apiGroup>