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." -}}
94
+
{{- end -}}
95
+
{{- ifand.Values.rbac.Values.rbac.namespaces -}}
96
+
{{- $installNs:= include "kagent-tools.namespace". -}}
Copy file name to clipboardExpand all lines: helm/kagent-tools/tests/rbac_test.yaml
+76-9Lines changed: 76 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,10 @@ tests:
12
12
of: ClusterRoleBinding
13
13
template: clusterrolebinding.yaml
14
14
15
-
- it: should render Roles when clusterScoped is false
15
+
- it: should render Roles when rbac.namespaces is set
16
16
set:
17
-
rbac.clusterScoped: false
17
+
rbac.namespaces:
18
+
- NAMESPACE
18
19
asserts:
19
20
- isKind:
20
21
of: Role
@@ -31,36 +32,102 @@ tests:
31
32
value: NAMESPACE
32
33
template: clusterrolebinding.yaml
33
34
34
-
- it: should render multiple roles and bindings when namespaces are specified and clusterScoped is false
35
+
- it: should render a single role/binding in the listed namespace only (no release-ns fallback)
36
+
set:
37
+
rbac.namespaces:
38
+
- NAMESPACE
39
+
asserts:
40
+
- hasDocuments:
41
+
count: 1
42
+
template: clusterrole.yaml
43
+
- equal:
44
+
path: metadata.namespace
45
+
value: NAMESPACE
46
+
template: clusterrole.yaml
47
+
- hasDocuments:
48
+
count: 1
49
+
template: clusterrolebinding.yaml
50
+
- equal:
51
+
path: metadata.namespace
52
+
value: NAMESPACE
53
+
template: clusterrolebinding.yaml
54
+
55
+
- it: should render multiple roles and bindings when namespaces are specified
35
56
set:
36
-
rbac.clusterScoped: false
37
57
rbac.namespaces:
38
58
- ns1
59
+
- NAMESPACE
39
60
- ns2
40
61
asserts:
41
62
- hasDocuments:
42
-
count: 2
63
+
count: 3
43
64
template: clusterrole.yaml
44
65
- equal:
45
66
path: metadata.namespace
46
-
value: ns1
67
+
value: NAMESPACE
47
68
template: clusterrole.yaml
48
69
documentIndex: 0
49
70
- equal:
50
71
path: metadata.namespace
51
-
value: ns2
72
+
value: ns1
52
73
template: clusterrole.yaml
53
74
documentIndex: 1
75
+
- equal:
76
+
path: metadata.namespace
77
+
value: ns2
78
+
template: clusterrole.yaml
79
+
documentIndex: 2
54
80
- hasDocuments:
55
-
count: 2
81
+
count: 3
56
82
template: clusterrolebinding.yaml
57
83
- equal:
58
84
path: metadata.namespace
59
-
value: ns1
85
+
value: NAMESPACE
60
86
template: clusterrolebinding.yaml
61
87
documentIndex: 0
88
+
- equal:
89
+
path: metadata.namespace
90
+
value: ns1
91
+
template: clusterrolebinding.yaml
92
+
documentIndex: 1
62
93
- equal:
63
94
path: metadata.namespace
64
95
value: ns2
65
96
template: clusterrolebinding.yaml
97
+
documentIndex: 2
98
+
99
+
- it: should fail rendering if the removed rbac.clusterScoped field is set
100
+
set:
101
+
rbac.clusterScoped: false
102
+
template: clusterrolebinding.yaml
103
+
asserts:
104
+
- failedTemplate:
105
+
errorMessage: "rbac.clusterScoped has been removed. Leave rbac.namespaces empty for cluster-scoped RBAC, or set rbac.namespaces=[<ns>, ...] for namespaced RBAC."
106
+
107
+
- it: should fail rendering if rbac.namespaces is set but does not include the install namespace
108
+
set:
109
+
rbac.namespaces:
110
+
- some-other-ns
111
+
template: clusterrolebinding.yaml
112
+
asserts:
113
+
- failedTemplate:
114
+
errorMessage: 'rbac.namespaces is set but does not include the install namespace "NAMESPACE"'
115
+
116
+
- it: should accept a custom install namespace when listed in rbac.namespaces
0 commit comments