aboutsummaryrefslogtreecommitdiffstats
path: root/test/security/k8s/src/check/validators/master/api_test.go
blob: f9eb943b3e58d7e9223a337b40335d443595a9f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
package master_test

import (
	. "check/validators/master"

	. "github.com/onsi/ginkgo/extensions/table"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Api", func() {
	var (
		// kubeApiServerCISCompliant uses secure defaults or follows CIS guidelines explicitly.
		kubeApiServerCISCompliant = []string{
			"--anonymous-auth=false",
			"--insecure-port=0",
			"--profiling=false",
			"--repair-malformed-updates=false",
			"--service-account-lookup=true",
			"--enable-admission-plugins=NamespaceLifecycle,LimitRanger,ServiceAccount," +
				"TaintNodesByCondition,Priority,DefaultTolerationSeconds,DefaultStorageClass," +
				"PersistentVolumeClaimResize,MutatingAdmissionWebhook,ValidatingAdmissionWebhook," +
				"ResourceQuota,AlwaysPullImages,DenyEscalatingExec,SecurityContextDeny," +
				"PodSecurityPolicy,NodeRestriction,EventRateLimit",
			"--authorization-mode=RBAC",
			"--audit-log-path=/var/log/apiserver/audit.log",
			"--audit-log-maxage=30",
			"--audit-log-maxbackup=10",
			"--audit-log-maxsize=100",
			"--kubelet-certificate-authority=TrustedCA",
			"--client-ca-file=/etc/kubernetes/ssl/ca.pem",
			"--etcd-cafile=/etc/kubernetes/etcd/ca.pem",
			"--service-account-key-file=/etc/kubernetes/ssl/kube-service-account-token-key.pem",
			"--kubelet-client-certificate=/etc/kubernetes/ssl/cert.pem",
			"--kubelet-client-key=/etc/kubernetes/ssl/key.pem",
			"--etcd-certfile=/etc/kubernetes/etcd/cert.pem",
			"--etcd-keyfile=/etc/kubernetes/etcd/key.pem",
			"--tls-cert-file=/etc/kubernetes/ssl/cert.pem",
			"--tls-private-key-file=/etc/kubernetes/ssl/key.pem",
		}

		// kubeApiServerCasablanca was obtained from virtual environment for testing
		// (introduced in Change-Id: I57f9f3caac0e8b391e9ed480f6bebba98e006882).
		kubeApiServerCasablanca = []string{
			"--storage-backend=etcd2",
			"--storage-media-type=application/json",
			"--service-cluster-ip-range=10.43.0.0/16",
			"--etcd-servers=https://etcd.kubernetes.rancher.internal:2379",
			"--insecure-bind-address=0.0.0.0",
			"--insecure-port=0",
			"--cloud-provider=rancher",
			"--allow-privileged=true",
			"--admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount," +
				"PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,ResourceQuota",
			"--client-ca-file=/etc/kubernetes/ssl/ca.pem",
			"--tls-cert-file=/etc/kubernetes/ssl/cert.pem",
			"--tls-private-key-file=/etc/kubernetes/ssl/key.pem",
			"--kubelet-client-certificate=/etc/kubernetes/ssl/cert.pem",
			"--kubelet-client-key=/etc/kubernetes/ssl/key.pem",
			"--runtime-config=batch/v2alpha1",
			"--anonymous-auth=false",
			"--authentication-token-webhook-config-file=/etc/kubernetes/authconfig",
			"--runtime-config=authentication.k8s.io/v1beta1=true",
			"--external-hostname=kubernetes.kubernetes.rancher.internal",
			"--etcd-cafile=/etc/kubernetes/etcd/ca.pem",
			"--etcd-certfile=/etc/kubernetes/etcd/cert.pem",
			"--etcd-keyfile=/etc/kubernetes/etcd/key.pem",
			"--tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256," +
				"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305," +
				"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384," +
				"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
		}

		// kubeApiServerCasablanca was obtained from virtual environment for testing
		// (introduced in Change-Id: I54ada5fade3b984dedd1715f20579e3ce901faa3).
		kubeApiServerDublin = []string{
			"--requestheader-group-headers=X-Remote-Group",
			"--proxy-client-cert-file=/etc/kubernetes/ssl/kube-apiserver-proxy-client.pem",
			"--bind-address=0.0.0.0",
			"--tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256," +
				"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305," +
				"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384," +
				"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
			"--cloud-provider=",
			"--etcd-cafile=/etc/kubernetes/ssl/kube-ca.pem",
			"--etcd-servers=https://172.17.0.100:2379",
			"--tls-cert-file=/etc/kubernetes/ssl/kube-apiserver.pem",
			"--enable-admission-plugins=NamespaceLifecycle,LimitRanger,ServiceAccount," +
				"DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook," +
				"ValidatingAdmissionWebhook,ResourceQuota,NodeRestriction,PersistentVolumeLabel",
			"--insecure-port=0",
			"--secure-port=6443",
			"--storage-backend=etcd3",
			"--kubelet-client-key=/etc/kubernetes/ssl/kube-apiserver-key.pem",
			"--requestheader-client-ca-file=/etc/kubernetes/ssl/kube-apiserver-requestheader-ca.pem",
			"--service-account-key-file=/etc/kubernetes/ssl/kube-service-account-token-key.pem",
			"--service-node-port-range=30000-32767",
			"--tls-private-key-file=/etc/kubernetes/ssl/kube-apiserver-key.pem",
			"--requestheader-username-headers=X-Remote-User",
			"--repair-malformed-updates=false",
			"--kubelet-client-certificate=/etc/kubernetes/ssl/kube-apiserver.pem",
			"--service-cluster-ip-range=10.43.0.0/16",
			"--advertise-address=172.17.0.100",
			"--profiling=false",
			"--requestheader-extra-headers-prefix=X-Remote-Extra-",
			"--etcd-certfile=/etc/kubernetes/ssl/kube-node.pem",
			"--anonymous-auth=false",
			"--etcd-keyfile=/etc/kubernetes/ssl/kube-node-key.pem",
			"--etcd-prefix=/registry",
			"--client-ca-file=/etc/kubernetes/ssl/kube-ca.pem",
			"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname",
			"--requestheader-allowed-names=kube-apiserver-proxy-client",
			"--service-account-lookup=true",
			"--proxy-client-key-file=/etc/kubernetes/ssl/kube-apiserver-proxy-client-key.pem",
			"--authorization-mode=Node,RBAC",
			"--allow-privileged=true",
		}
	)

	Describe("Boolean flags", func() {
		DescribeTable("Accepting any token",
			func(params []string, expected bool) {
				Expect(IsInsecureAllowAnyTokenAbsent(params)).To(Equal(expected))
			},
			Entry("Is not absent on insecure cluster", []string{"--insecure-allow-any-token"}, false),
			Entry("Should be absent on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be absent on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be absent on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Anonymous requests",
			func(params []string, expected bool) {
				Expect(IsAnonymousAuthDisabled(params)).To(Equal(expected))
			},
			Entry("Is not set on insecure cluster", []string{}, false),
			Entry("Should be set to false on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be set to false on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be set to false on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Profiling",
			func(params []string, expected bool) {
				Expect(IsProfilingDisabled(params)).To(Equal(expected))
			},
			Entry("Is not set on insecure cluster", []string{}, false),
			Entry("Is explicitly enabled on insecure cluster", []string{"--profiling=true"}, false),
			Entry("Is not set on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Should be set to false on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be set to false on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("HTTPS for kubelet",
			func(params []string, expected bool) {
				Expect(IsKubeletHTTPSAbsentOrEnabled(params)).To(Equal(expected))
			},
			Entry("Is explicitly disabled on insecure cluster", []string{"--kubelet-https=false"}, false),
			Entry("Should be absent or set to true on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be absent or set to true on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be absent or set to true on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Repairing malformed updates",
			func(params []string, expected bool) {
				Expect(IsRepairMalformedUpdatesDisabled(params)).To(Equal(expected))
			},
			Entry("Is not set on insecure cluster", []string{}, false),
			Entry("Is explicitly enabled on insecure cluster", []string{"--repair-malformed-updates=true"}, false),
			Entry("Is not set on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Should be set to false on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be set to false on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Service account lookup",
			func(params []string, expected bool) {
				Expect(IsServiceAccountLookupEnabled(params)).To(Equal(expected))
			},
			Entry("Is not set on insecure cluster", []string{}, false),
			Entry("Is explicitly disabled on insecure cluster", []string{"--service-account-lookup=false"}, false),
			Entry("Is not set on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Should be set to true on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be set to true on Dublin cluster", kubeApiServerDublin, true),
		)
	})

	Describe("File path flags", func() {
		DescribeTable("Basic authentication file",
			func(params []string, expected bool) {
				Expect(IsBasicAuthFileAbsent(params)).To(Equal(expected))
			},
			Entry("Is not absent on insecure cluster", []string{"--basic-auth-file=/path/to/file"}, false),
			Entry("Should be absent on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be absent on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be absent on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Token authentication file",
			func(params []string, expected bool) {
				Expect(IsTokenAuthFileAbsent(params)).To(Equal(expected))
			},
			Entry("Is not absent on insecure cluster", []string{"--token-auth-file=/path/to/file"}, false),
			Entry("Should be absent on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be absent on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be absent on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Audit log path",
			func(params []string, expected bool) {
				Expect(IsAuditLogPathSet(params)).To(Equal(expected))
			},
			Entry("Is absent on insecure cluster", []string{}, false),
			Entry("Is empty on insecure cluster", []string{"--audit-log-path="}, false),
			Entry("Is absent on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Is absent on Dublin cluster", kubeApiServerDublin, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
		)

		DescribeTable("Kubelet certificate authority",
			func(params []string, expected bool) {
				Expect(IsKubeletCertificateAuthoritySet(params)).To(Equal(expected))
			},
			Entry("Is absent on insecure cluster", []string{}, false),
			Entry("Is empty on insecure cluster", []string{"--kubelet-certificate-authority="}, false),
			Entry("Is absent on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Is absent on Dublin cluster", kubeApiServerDublin, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
		)

		DescribeTable("Client certificate authority",
			func(params []string, expected bool) {
				Expect(IsClientCertificateAuthoritySet(params)).To(Equal(expected))
			},
			Entry("Is absent on insecure cluster", []string{}, false),
			Entry("Is empty on insecure cluster", []string{"--client-ca-file="}, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be present on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be present on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Etcd certificate authority",
			func(params []string, expected bool) {
				Expect(IsEtcdCertificateAuthoritySet(params)).To(Equal(expected))
			},
			Entry("Is absent on insecure cluster", []string{}, false),
			Entry("Is empty on insecure cluster", []string{"-etcd-cafile="}, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be present on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be present on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Service account key",
			func(params []string, expected bool) {
				Expect(IsServiceAccountKeySet(params)).To(Equal(expected))
			},
			Entry("Is absent on insecure cluster", []string{}, false),
			Entry("Is empty on insecure cluster", []string{"--service-account-key-file="}, false),
			Entry("Is absent on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be present on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Kubelet client certificate and key",
			func(params []string, expected bool) {
				Expect(IsKubeletClientCertificateAndKeySet(params)).To(Equal(expected))
			},
			Entry("Is absent on insecure cluster", []string{}, false),
			Entry("Is empty on insecure cluster", []string{"--kubelet-client-certificate= --kubelet-client-key="}, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be present on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be present on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Etcd certificate and key",
			func(params []string, expected bool) {
				Expect(IsEtcdCertificateAndKeySet(params)).To(Equal(expected))
			},
			Entry("Is absent on insecure cluster", []string{}, false),
			Entry("Is empty on insecure cluster", []string{"--etcd-certfile= --etcd-keyfile="}, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be present on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be present on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("TLS certificate and key",
			func(params []string, expected bool) {
				Expect(IsTLSCertificateAndKeySet(params)).To(Equal(expected))
			},
			Entry("Is absent on insecure cluster", []string{}, false),
			Entry("Is empty on insecure cluster", []string{"--tls-cert-file= --tls-private-key-file="}, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be present on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be present on Dublin cluster", kubeApiServerDublin, true),
		)
	})

	Describe("Address and port flags", func() {
		DescribeTable("Bind address",
			func(params []string, expected bool) {
				Expect(IsInsecureBindAddressAbsentOrLoopback(params)).To(Equal(expected))
			},
			Entry("Is not absent on insecure cluster", []string{"--insecure-bind-address=1.2.3.4"}, false),
			Entry("Is not absent nor set to loopback on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Should be absent or set to loopback on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be absent or set to loopback on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Bind port",
			func(params []string, expected bool) {
				Expect(IsInsecurePortUnbound(params)).To(Equal(expected))
			},
			Entry("Is not set on insecure cluster", []string{}, false),
			Entry("Is explicitly enabled on insecure cluster", []string{"--insecure-port=1234"}, false),
			Entry("Should be set to 0 on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be set to 0 on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be set to 0 on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("Secure bind port",
			func(params []string, expected bool) {
				Expect(IsSecurePortAbsentOrValid(params)).To(Equal(expected))
			},
			Entry("Is explicitly disabled on insecure cluster", []string{"--secure-port=0"}, false),
			Entry("Should be absent or set to valid port on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be absent or set to valid port on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be absent or set to valid port on Dublin cluster", kubeApiServerDublin, true),
		)
	})

	Describe("Numeric flags", func() {
		DescribeTable("Audit log age",
			func(params []string, expected bool) {
				Expect(IsAuditLogMaxAgeValid(params)).To(Equal(expected))
			},
			Entry("Is absent on insecure cluster", []string{}, false),
			Entry("Is empty on insecure cluster", []string{"--audit-log-maxage="}, false),
			Entry("Is insufficient on insecure cluster", []string{"--audit-log-maxage=5"}, false),
			Entry("Is absent on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Is absent on Dublin cluster", kubeApiServerDublin, false),
			Entry("Should be set appropriately on CIS-compliant cluster", kubeApiServerCISCompliant, true),
		)

		DescribeTable("Audit log backups",
			func(params []string, expected bool) {
				Expect(IsAuditLogMaxBackupValid(params)).To(Equal(expected))
			},
			Entry("Is absent on insecure cluster", []string{}, false),
			Entry("Is empty on insecure cluster", []string{"--audit-log-maxbackup="}, false),
			Entry("Is insufficient on insecure cluster", []string{"--audit-log-maxbackup=2"}, false),
			Entry("Is absent on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Is absent on Dublin cluster", kubeApiServerDublin, false),
			Entry("Should be set appropriately on CIS-compliant cluster", kubeApiServerCISCompliant, true),
		)

		DescribeTable("Audit log size",
			func(params []string, expected bool) {
				Expect(IsAuditLogMaxSizeValid(params)).To(Equal(expected))
			},
			Entry("Is absent on insecure cluster", []string{}, false),
			Entry("Is empty on insecure cluster", []string{"--audit-log-maxsize="}, false),
			Entry("Is insufficient on insecure cluster", []string{"--audit-log-maxsize=5"}, false),
			Entry("Is absent on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Is absent on Dublin cluster", kubeApiServerDublin, false),
			Entry("Should be set appropriately on CIS-compliant cluster", kubeApiServerCISCompliant, true),
		)
	})

	Describe("Argument list flags", func() {
		DescribeTable("AlwaysAdmit admission control plugin",
			func(params []string, expected bool) {
				Expect(IsAlwaysAdmitAdmissionControlPluginExcluded(params)).To(Equal(expected))
			},
			Entry("Is not absent on insecure cluster", []string{"--enable-admission-plugins=Foo,Bar,AlwaysAdmit,Baz,Quuz"}, false),
			Entry("Is not absent on insecure deprecated cluster", []string{"--admission-control=Foo,Bar,AlwaysAdmit,Baz,Quuz"}, false),
			Entry("Should be absent on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be absent on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be absent on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("AlwaysPullImages admission control plugin",
			func(params []string, expected bool) {
				Expect(IsAlwaysPullImagesAdmissionControlPluginIncluded(params)).To(Equal(expected))
			},
			Entry("Is not present on insecure cluster", []string{"--enable-admission-plugins=Foo,Bar"}, false),
			Entry("Is not present on insecure deprecated cluster", []string{"--admission-control=Foo,Bar"}, false),
			Entry("Is not present on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Is not present on Dublin cluster", kubeApiServerDublin, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
		)

		DescribeTable("DenyEscalatingExec admission control plugin",
			func(params []string, expected bool) {
				Expect(IsDenyEscalatingExecAdmissionControlPluginIncluded(params)).To(Equal(expected))
			},
			Entry("Is not present on insecure cluster", []string{"--enable-admission-plugins=Foo,Bar"}, false),
			Entry("Is not present on insecure deprecated cluster", []string{"--admission-control=Foo,Bar"}, false),
			Entry("Is not present on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Is not present on Dublin cluster", kubeApiServerDublin, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
		)

		DescribeTable("SecurityContextDeny admission control plugin",
			func(params []string, expected bool) {
				Expect(IsSecurityContextDenyAdmissionControlPluginIncluded(params)).To(Equal(expected))
			},
			Entry("Is not present on insecure cluster", []string{"--enable-admission-plugins=Foo,Bar"}, false),
			Entry("Is not present on insecure deprecated cluster", []string{"--admission-control=Foo,Bar"}, false),
			Entry("Is not present on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Is not present on Dublin cluster", kubeApiServerDublin, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
		)

		DescribeTable("PodSecurityPolicy admission control plugin",
			func(params []string, expected bool) {
				Expect(IsPodSecurityPolicyAdmissionControlPluginIncluded(params)).To(Equal(expected))
			},
			Entry("Is not present on insecure cluster", []string{"--enable-admission-plugins=Foo,Bar"}, false),
			Entry("Is not present on insecure deprecated cluster", []string{"--admission-control=Foo,Bar"}, false),
			Entry("Is not present on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Is not present on Dublin cluster", kubeApiServerDublin, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
		)

		DescribeTable("ServiceAccount admission control plugin",
			func(params []string, expected bool) {
				Expect(IsServiceAccountAdmissionControlPluginIncluded(params)).To(Equal(expected))
			},
			Entry("Is not present on insecure cluster", []string{"--enable-admission-plugins=Foo,Bar"}, false),
			Entry("Is not present on insecure deprecated cluster", []string{"--admission-control=Foo,Bar"}, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be present on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should be present on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("NodeRestriction admission control plugin",
			func(params []string, expected bool) {
				Expect(IsNodeRestrictionAdmissionControlPluginIncluded(params)).To(Equal(expected))
			},
			Entry("Is not present on insecure cluster", []string{"--enable-admission-plugins=Foo,Bar"}, false),
			Entry("Is not present on insecure deprecated cluster", []string{"--admission-control=Foo,Bar"}, false),
			Entry("Is not present on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be present on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("EventRateLimit admission control plugin",
			func(params []string, expected bool) {
				Expect(IsEventRateLimitAdmissionControlPluginIncluded(params)).To(Equal(expected))
			},
			Entry("Is not present on insecure cluster", []string{"--enable-admission-plugins=Foo,Bar"}, false),
			Entry("Is not present on insecure deprecated cluster", []string{"--admission-control=Foo,Bar"}, false),
			Entry("Is not present on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Is not present on Dublin cluster", kubeApiServerDublin, false),
			Entry("Should be present on CIS-compliant cluster", kubeApiServerCISCompliant, true),
		)

		DescribeTable("NamespaceLifecycle admission control plugin",
			func(params []string, expected bool) {
				Expect(IsNamespaceLifecycleAdmissionControlPluginNotExcluded(params)).To(Equal(expected))
			},
			Entry("Is explicitly disabled on insecure cluster", []string{"--disable-admission-plugins=Foo,Bar,NamespaceLifecycle,Baz,Quuz"}, false),
			Entry("Should not be disabled on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should not be disabled on Casablanca cluster", kubeApiServerCasablanca, true),
			Entry("Should not be disabled on Dublin cluster", kubeApiServerDublin, true),
		)

		DescribeTable("AlwaysAllow authorization mode",
			func(params []string, expected bool) {
				Expect(IsAlwaysAllowAuthorizationModeExcluded(params)).To(Equal(expected))
			},
			Entry("Is not explicitly disabled on insecure cluster", []string{}, false),
			Entry("Is not absent on insecure cluster", []string{"--authorization-mode=Foo,Bar,AlwaysAllow,Baz,Quuz"}, false),
			Entry("Is not explicitly disabled on Casablanca cluster", kubeApiServerCasablanca, false),
			Entry("Should be absent on CIS-compliant cluster", kubeApiServerCISCompliant, true),
			Entry("Should be absent on Dublin cluster", kubeApiServerDublin, true),
		)
	})
})