You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{- fail "rbac.clusterScoped has been removed. Leave rbac.namespaces empty for cluster-scoped RBAC, or set rbac.namespaces=[<ns>, ...] for namespaced RBAC." -}}
Copy file name to clipboardExpand all lines: helm/kmcp/tests/rbac_test.yaml
+69-8Lines changed: 69 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -144,11 +144,12 @@ tests:
144
144
count: 1
145
145
- matchSnapshot: {}
146
146
147
-
- it: should create Role when clusterScoped is false
147
+
- it: should create Role when rbac.namespaces is set
148
148
template: rbac/clusterrole.yaml
149
149
set:
150
150
rbac.create: true
151
-
rbac.clusterScoped: false
151
+
rbac.namespaces:
152
+
- NAMESPACE
152
153
asserts:
153
154
- hasDocuments:
154
155
count: 1
@@ -157,11 +158,12 @@ tests:
157
158
apiVersion: rbac.authorization.k8s.io/v1
158
159
- matchSnapshot: {}
159
160
160
-
- it: should create RoleBinding when clusterScoped is false
161
+
- it: should create RoleBinding when rbac.namespaces is set
161
162
template: rbac/clusterrolebinding.yaml
162
163
set:
163
164
rbac.create: true
164
-
rbac.clusterScoped: false
165
+
rbac.namespaces:
166
+
- NAMESPACE
165
167
asserts:
166
168
- hasDocuments:
167
169
count: 1
@@ -170,20 +172,40 @@ tests:
170
172
apiVersion: rbac.authorization.k8s.io/v1
171
173
- matchSnapshot: {}
172
174
175
+
- it: should render a single role/binding in the listed namespace only (no release-ns fallback)
176
+
set:
177
+
rbac.create: true
178
+
rbac.namespaces:
179
+
- NAMESPACE
180
+
asserts:
181
+
- hasDocuments:
182
+
count: 1
183
+
template: rbac/clusterrole.yaml
184
+
- equal:
185
+
path: metadata.namespace
186
+
value: NAMESPACE
187
+
template: rbac/clusterrole.yaml
188
+
- hasDocuments:
189
+
count: 1
190
+
template: rbac/clusterrolebinding.yaml
191
+
- equal:
192
+
path: metadata.namespace
193
+
value: NAMESPACE
194
+
template: rbac/clusterrolebinding.yaml
195
+
173
196
- it: should create multiple Roles when multiple namespaces are provided
174
197
template: rbac/clusterrole.yaml
175
198
set:
176
199
rbac.create: true
177
-
rbac.clusterScoped: false
178
200
rbac.namespaces:
179
-
- ns1
201
+
- NAMESPACE
180
202
- ns2
181
203
asserts:
182
204
- hasDocuments:
183
205
count: 2
184
206
- equal:
185
207
path: metadata.namespace
186
-
value: ns1
208
+
value: NAMESPACE
187
209
documentIndex: 0
188
210
- equal:
189
211
path: metadata.namespace
@@ -195,4 +217,43 @@ tests:
195
217
- isKind:
196
218
of: Role
197
219
documentIndex: 1
198
-
- matchSnapshot: {}
220
+
- matchSnapshot: {}
221
+
222
+
- it: should fail rendering if the removed rbac.clusterScoped field is set
223
+
set:
224
+
rbac.create: true
225
+
rbac.clusterScoped: false
226
+
template: rbac/clusterrolebinding.yaml
227
+
asserts:
228
+
- failedTemplate:
229
+
errorMessage: "rbac.clusterScoped has been removed. Leave rbac.namespaces empty for cluster-scoped RBAC, or set rbac.namespaces=[<ns>, ...] for namespaced RBAC."
230
+
231
+
- it: should fail rendering if rbac.namespaces is set but does not include the install namespace
232
+
set:
233
+
rbac.create: true
234
+
rbac.namespaces:
235
+
- some-other-ns
236
+
template: rbac/clusterrolebinding.yaml
237
+
asserts:
238
+
- failedTemplate:
239
+
errorMessage: "rbac.namespaces is set but does not include the install namespace \"NAMESPACE\""
240
+
241
+
- it: should accept a custom install namespace when listed in rbac.namespaces
0 commit comments