validation_test.yaml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 resourceNames 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. resourceNames:
  160. - ""
  161. verbs:
  162. - get
  163. asserts:
  164. - failedTemplate:
  165. errorMessage: RBAC - Expected non-empty entry in <rbac.rules.resourceNames>
  166. - it: should fail with empty entry in verbs in rules in rbac
  167. set:
  168. rbac:
  169. my-rbac:
  170. enabled: true
  171. primary: true
  172. rules:
  173. - apiGroups:
  174. - ""
  175. resources:
  176. - pods
  177. verbs:
  178. - get
  179. - ""
  180. asserts:
  181. - failedTemplate:
  182. errorMessage: RBAC - Expected non-empty entry in <rbac.rules.verbs>
  183. - it: should fail with empty kind in subjects in rbac
  184. set:
  185. serviceAccount:
  186. my-service-account:
  187. enabled: true
  188. primary: true
  189. rbac:
  190. my-rbac:
  191. enabled: true
  192. primary: true
  193. rules:
  194. - apiGroups:
  195. - ""
  196. resources:
  197. - pods
  198. verbs:
  199. - get
  200. subjects:
  201. - kind: ""
  202. name: my-name
  203. apiGroup: my-apiGroup
  204. asserts:
  205. - failedTemplate:
  206. errorMessage: RBAC - Expected non-empty <rbac.subjects.kind>
  207. - it: should fail with empty name in subjects in rbac
  208. set:
  209. serviceAccount:
  210. my-service-account:
  211. enabled: true
  212. primary: true
  213. rbac:
  214. my-rbac:
  215. enabled: true
  216. primary: true
  217. rules:
  218. - apiGroups:
  219. - ""
  220. resources:
  221. - pods
  222. verbs:
  223. - get
  224. subjects:
  225. - kind: my-kind
  226. name: ""
  227. apiGroup: my-apiGroup
  228. asserts:
  229. - failedTemplate:
  230. errorMessage: RBAC - Expected non-empty <rbac.subjects.name>
  231. - it: should fail with empty apiGroup in subjects in rbac
  232. set:
  233. serviceAccount:
  234. my-service-account:
  235. enabled: true
  236. primary: true
  237. rbac:
  238. my-rbac:
  239. enabled: true
  240. primary: true
  241. rules:
  242. - apiGroups:
  243. - ""
  244. resources:
  245. - pods
  246. verbs:
  247. - get
  248. subjects:
  249. - kind: my-kind
  250. name: my-name
  251. apiGroup: ""
  252. asserts:
  253. - failedTemplate:
  254. errorMessage: RBAC - Expected non-empty <rbac.subjects.apiGroup>