aboutsummaryrefslogtreecommitdiffstats
path: root/test/security/k8s/src/check/validators/master/controllermanager/controllermanager_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/security/k8s/src/check/validators/master/controllermanager/controllermanager_test.go')
-rw-r--r--test/security/k8s/src/check/validators/master/controllermanager/controllermanager_test.go43
1 files changed, 42 insertions, 1 deletions
diff --git a/test/security/k8s/src/check/validators/master/controllermanager/controllermanager_test.go b/test/security/k8s/src/check/validators/master/controllermanager/controllermanager_test.go
index d417b7d9f..7fd8b5d53 100644
--- a/test/security/k8s/src/check/validators/master/controllermanager/controllermanager_test.go
+++ b/test/security/k8s/src/check/validators/master/controllermanager/controllermanager_test.go
@@ -12,7 +12,11 @@ import (
var _ = Describe("Controllermanager", func() {
var (
// kubeControllerManagerCISCompliant uses secure defaults or follows CIS guidelines explicitly.
- kubeControllerManagerCISCompliant = []string{}
+ kubeControllerManagerCISCompliant = []string{
+ "--profiling=false",
+ "--use-service-account-credentials=true",
+ "--feature-gates=RotateKubeletServerCertificate=true",
+ }
// kubeControllerManagerCasablanca was obtained from virtual environment for testing
// (introduced in Change-Id: I57f9f3caac0e8b391e9ed480f6bebba98e006882).
@@ -50,6 +54,30 @@ var _ = Describe("Controllermanager", func() {
}
)
+ Describe("Boolean flags", func() {
+ 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", kubeControllerManagerCasablanca, false),
+ Entry("Should be set to false on CIS-compliant cluster", kubeControllerManagerCISCompliant, true),
+ Entry("Should be set to false on Dublin cluster", kubeControllerManagerDublin, true),
+ )
+
+ DescribeTable("Service account credentials use",
+ func(params []string, expected bool) {
+ Expect(IsUseServiceAccountCredentialsEnabled(params)).To(Equal(expected))
+ },
+ Entry("Is not set on insecure cluster", []string{}, false),
+ Entry("Is explicitly disabled on insecure cluster", []string{"--use-service-account-credentials=false"}, false),
+ Entry("Is not set on Casablanca cluster", kubeControllerManagerCasablanca, false),
+ Entry("Should be set to true on CIS-compliant cluster", kubeControllerManagerCISCompliant, true),
+ Entry("Should be set to true on Dublin cluster", kubeControllerManagerDublin, true),
+ )
+ })
+
Describe("Address flag", func() {
DescribeTable("Bind address",
func(params []string, expected bool) {
@@ -61,4 +89,17 @@ var _ = Describe("Controllermanager", func() {
Entry("Should be absent or set to loopback on CIS-compliant cluster", kubeControllerManagerCISCompliant, true),
)
})
+
+ Describe("Argument list flags", func() {
+ DescribeTable("RotateKubeletServerCertificate",
+ func(params []string, expected bool) {
+ Expect(IsRotateKubeletServerCertificateIncluded(params)).To(Equal(expected))
+ },
+ Entry("Is not enabled on insecure cluster", []string{"--feature-gates=Foo=Bar,Baz=Quuz"}, false),
+ Entry("Is explicitly disabled on insecure cluster", []string{"--feature-gates=Foo=Bar,RotateKubeletServerCertificate=false,Baz=Quuz"}, false),
+ Entry("Is not enabled on Casablanca cluster", kubeControllerManagerCasablanca, false),
+ Entry("Is not enabled on Dublin cluster", kubeControllerManagerDublin, false),
+ Entry("Should be enabled on CIS-compliant cluster", kubeControllerManagerCISCompliant, true),
+ )
+ })
})