@@ -52,17 +52,14 @@ var _ = g.Describe("Authorization [RBAC] [Zalando]", func() {
52
52
// will clear these values for other specs.
53
53
// https://onsi.github.io/ginkgo/#organizing-specs-with-container-nodes
54
54
tc .data .resources = []string {"users" , "groups" }
55
- tc .run (context .TODO (), cs )
56
- output := tc .output
57
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
58
-
55
+ tc .run (context .TODO (), cs , false )
56
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
59
57
})
60
58
g .It ("should deny access for service accounts" , func () {
61
59
tc .data .resources = []string {"serviceaccounts" }
62
60
tc .data .namespaces = []string {"" , "teapot" , "kube-system" }
63
- tc .run (context .TODO (), cs )
64
- output := tc .output
65
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
61
+ tc .run (context .TODO (), cs , false )
62
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
66
63
})
67
64
})
68
65
g .When ("the verb is escalate" , func () {
@@ -72,16 +69,14 @@ var _ = g.Describe("Authorization [RBAC] [Zalando]", func() {
72
69
73
70
g .It ("should deny access for cluster roles" , func () {
74
71
tc .data .resources = []string {"rbac.authorization.k8s.io/clusterrole" }
75
- tc .run (context .TODO (), cs )
76
- output := tc .output
77
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
72
+ tc .run (context .TODO (), cs , false )
73
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
78
74
})
79
75
g .It ("should deny access for roles in all namespaces" , func () {
80
76
tc .data .resources = []string {"rbac.authorization.k8s.io/role" }
81
77
tc .data .namespaces = []string {"" , "teapot" , "kube-system" }
82
- tc .run (context .TODO (), cs )
83
- output := tc .output
84
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
78
+ tc .run (context .TODO (), cs , false )
79
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
85
80
})
86
81
})
87
82
})
@@ -99,9 +94,8 @@ var _ = g.Describe("Authorization [RBAC] [Zalando]", func() {
99
94
g .It ("should deny access in all namespaces" , func () {
100
95
tc .data .verbs = []string {"get" , "list" , "watch" , "create" , "update" , "delete" , "patch" }
101
96
tc .data .namespaces = []string {"" , "teapot" , "kube-system" }
102
- tc .run (context .TODO (), cs )
103
- output := tc .output
104
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
97
+ tc .run (context .TODO (), cs , false )
98
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
105
99
})
106
100
})
107
101
g .When ("the resource is not a Secret resource" , func () {
@@ -122,16 +116,13 @@ var _ = g.Describe("Authorization [RBAC] [Zalando]", func() {
122
116
})
123
117
g .It ("should allow read access in all namespaces" , func () {
124
118
tc .data .verbs = []string {"get" , "list" , "watch" }
125
- tc .run (context .TODO (), cs )
126
- output := tc .output
127
- gomega .Expect (output .allowed ).To (gomega .BeTrue (),
128
- "Reason: %v" , output .reason )
119
+ tc .run (context .TODO (), cs , true )
120
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
129
121
})
130
122
g .It ("should deny write access in all namespaces" , func () {
131
123
tc .data .verbs = []string {"create" , "update" , "delete" , "patch" }
132
- tc .run (context .TODO (), cs )
133
- output := tc .output
134
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
124
+ tc .run (context .TODO (), cs , false )
125
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
135
126
})
136
127
})
137
128
g .When ("the resource is a global resource" , func () {
@@ -145,16 +136,13 @@ var _ = g.Describe("Authorization [RBAC] [Zalando]", func() {
145
136
}
146
137
g .It ("should allow read access" , func () {
147
138
tc .data .verbs = []string {"get" , "list" , "watch" }
148
- tc .run (context .TODO (), cs )
149
- output := tc .output
150
- gomega .Expect (output .allowed ).To (gomega .BeTrue (),
151
- "Reason: %v" , output .reason )
139
+ tc .run (context .TODO (), cs , true )
140
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
152
141
})
153
142
g .It ("should deny write access" , func () {
154
143
tc .data .verbs = []string {"create" , "update" , "delete" , "patch" }
155
- tc .run (context .TODO (), cs )
156
- output := tc .output
157
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
144
+ tc .run (context .TODO (), cs , false )
145
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
158
146
})
159
147
})
160
148
})
@@ -175,43 +163,37 @@ var _ = g.Describe("Authorization [RBAC] [Zalando]", func() {
175
163
tc .data .resources = []string {"secrets" }
176
164
tc .data .namespaces = []string {"kube-system" , "visibility" }
177
165
tc .data .verbs = []string {"get" , "list" , "watch" }
178
- tc .run (context .TODO (), cs )
179
- output := tc .output
180
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
166
+ tc .run (context .TODO (), cs , false )
167
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
181
168
})
182
169
183
170
g .It ("should deny write access to Nodes" , func () {
184
171
tc .data .resources = []string {"nodes" }
185
172
tc .data .verbs = []string {"create" , "update" , "delete" , "patch" }
186
- tc .run (context .TODO (), cs )
187
- output := tc .output
188
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
173
+ tc .run (context .TODO (), cs , false )
174
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
189
175
})
190
176
191
177
g .It ("should deny write access to DaemonSets" , func () {
192
178
tc .data .resources = []string {"apps/daemonsets" }
193
179
tc .data .verbs = []string {"create" , "update" , "delete" , "patch" }
194
- tc .run (context .TODO (), cs )
195
- output := tc .output
196
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
180
+ tc .run (context .TODO (), cs , false )
181
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
197
182
})
198
183
199
- // TODO: Double check if the original test case is correct
200
184
g .It ("should allow deleting CRDs" , func () {
201
185
tc .data .resources = []string {"apiextensions.k8s.io/customresourcedefinitions" }
202
186
tc .data .verbs = []string {"delete" }
203
- tc .run (context .TODO (), cs )
204
- output := tc .output
205
- gomega .Expect (output .allowed ).To (gomega .BeTrue ())
187
+ tc .run (context .TODO (), cs , true )
188
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
206
189
})
207
190
208
191
g .It ("should deny deleting kube-system or visibility namespaces" , func () {
209
192
tc .data .resources = []string {"namespaces" }
210
193
tc .data .namespaces = []string {"kube-system" , "visibility" }
211
194
tc .data .verbs = []string {"delete" }
212
- tc .run (context .TODO (), cs )
213
- output := tc .output
214
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
195
+ tc .run (context .TODO (), cs , false )
196
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
215
197
})
216
198
217
199
g .When ("the resource is a namespaced resource" , func () {
@@ -231,16 +213,13 @@ var _ = g.Describe("Authorization [RBAC] [Zalando]", func() {
231
213
})
232
214
g .It ("should deny write access in kube-system and visibility namespaces" , func () {
233
215
tc .data .namespaces = []string {"kube-system" , "visibility" }
234
- tc .run (context .TODO (), cs )
235
- output := tc .output
236
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
216
+ tc .run (context .TODO (), cs , false )
217
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
237
218
})
238
219
g .It ("should allow write access in namespaces other than kube-system and visibility" , func () {
239
220
tc .data .namespaces = []string {"" , "teapot" }
240
- tc .run (context .TODO (), cs )
241
- output := tc .output
242
- gomega .Expect (output .allowed ).To (gomega .BeTrue (),
243
- "Reason: %v" , output .reason )
221
+ tc .run (context .TODO (), cs , true )
222
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
244
223
})
245
224
})
246
225
g .When ("the resource is a global resource" , func () {
@@ -249,20 +228,17 @@ var _ = g.Describe("Authorization [RBAC] [Zalando]", func() {
249
228
})
250
229
g .It ("should deny write access to Nodes" , func () {
251
230
tc .data .resources = []string {"nodes" }
252
- tc .run (context .TODO (), cs )
253
- output := tc .output
254
- gomega .Expect (output .denied ).To (gomega .BeTrue ())
231
+ tc .run (context .TODO (), cs , false )
232
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
255
233
})
256
234
g .It ("should allow write access to resources other than Nodes" , func () {
257
235
tc .data .resources = []string {
258
236
"namespaces" ,
259
237
"storage.k8s.io/storageclasses" ,
260
238
"apiextensions.k8s.io/customresourcedefinitions" ,
261
239
}
262
- tc .run (context .TODO (), cs )
263
- output := tc .output
264
- gomega .Expect (output .allowed ).To (gomega .BeTrue (),
265
- "Reason: %v" , output .reason )
240
+ tc .run (context .TODO (), cs , true )
241
+ gomega .Expect (tc .output .passed ).To (gomega .BeTrue (), tc .output .String ())
266
242
})
267
243
})
268
244
})
0 commit comments