diff --git a/check/data b/check/data index 87117739de1f38343d07976403d5a76e3473db68..1930341691e97887525e4a118e54c7363a502185 100644 --- a/check/data +++ b/check/data @@ -308,6 +308,26 @@ groups: value: '^1\.12.*$' set: true + - id: 27 + text: "check boolean flag with no value" + tests: + test_items: + - flag: "--peer-client-cert-auth" + compare: + op: eq + value: true + set: true + + - id: 28 + text: "check boolean flag with false value" + tests: + test_items: + - flag: "--peer-client-cert-auth" + compare: + op: eq + value: false + set: true + - id: 2.1 text: "audit and audit_config commands" checks: diff --git a/check/test.go b/check/test.go index be068b373e0e7d3199d8e8f0214cffa3a0066b84..ece8ba940ae7819b02ea3c6fbc967f6875e17efc 100644 --- a/check/test.go +++ b/check/test.go @@ -115,7 +115,12 @@ func (t *testItem) execute(s string) *testOutput { if vals[3] != "" { flagVal = vals[3] } else { - flagVal = vals[1] + // --bool-flag + if strings.HasPrefix(t.Flag, "--") { + flagVal = "true" + } else { + flagVal = vals[1] + } } } else { fmt.Fprintf(os.Stderr, "invalid flag in testitem definition") diff --git a/check/test_test.go b/check/test_test.go index ff826e95d77efda0be5a55cf11a043c6069496a2..5323dc94cec93739c2ff3056018aba82b2767a0b 100644 --- a/check/test_test.go +++ b/check/test_test.go @@ -156,6 +156,30 @@ func TestTestExecute(t *testing.T) { controls.Groups[0].Checks[26], "currentMasterVersion: 1.12.7", }, + { + controls.Groups[0].Checks[27], + "--peer-client-cert-auth", + }, + { + controls.Groups[0].Checks[27], + "--abc=true --peer-client-cert-auth --efg=false", + }, + { + controls.Groups[0].Checks[27], + "--abc --peer-client-cert-auth --efg", + }, + { + controls.Groups[0].Checks[27], + "--peer-client-cert-auth=true", + }, + { + controls.Groups[0].Checks[27], + "--abc --peer-client-cert-auth=true --efg", + }, + { + controls.Groups[0].Checks[28], + "--abc --peer-client-cert-auth=false --efg", + }, } for _, c := range cases {