mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2024-11-22 08:08:07 +00:00
Update tests for check states (#550)
- Tests that did not increase coverage and were redundant are removed. - New tests reflecting the meaning of the state as explained in the README are added. Co-authored-by: s-nirali <25746945+s-nirali@users.noreply.github.com>
This commit is contained in:
parent
ca749ccb32
commit
dc14cb14b0
@ -15,6 +15,7 @@
|
|||||||
package check
|
package check
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,10 +28,27 @@ func TestCheck_Run(t *testing.T) {
|
|||||||
testCases := []TestCase{
|
testCases := []TestCase{
|
||||||
{check: Check{Type: MANUAL}, Expected: WARN},
|
{check: Check{Type: MANUAL}, Expected: WARN},
|
||||||
{check: Check{Type: "skip"}, Expected: INFO},
|
{check: Check{Type: "skip"}, Expected: INFO},
|
||||||
{check: Check{Type: "", Scored: false}, Expected: WARN}, // Not scored checks with no type should be marked warn
|
|
||||||
{check: Check{Type: "", Scored: true}, Expected: WARN}, // If there are no tests in the check, warn
|
{check: Check{Scored: false}, Expected: WARN}, // Not scored checks with no type, or not scored failing tests are marked warn
|
||||||
{check: Check{Type: MANUAL, Scored: false}, Expected: WARN},
|
{
|
||||||
{check: Check{Type: "skip", Scored: false}, Expected: INFO},
|
check: Check{ // Not scored checks with passing tests are marked pass
|
||||||
|
Scored: false,
|
||||||
|
Audit: ":", Commands: []*exec.Cmd{exec.Command("")},
|
||||||
|
Tests: &tests{TestItems: []*testItem{&testItem{}}},
|
||||||
|
},
|
||||||
|
Expected: PASS,
|
||||||
|
},
|
||||||
|
|
||||||
|
{check: Check{Scored: true}, Expected: WARN}, // If there are no tests in the check, warn
|
||||||
|
{check: Check{Scored: true, Tests: &tests{}}, Expected: FAIL}, // If there are tests that are not passing, fail
|
||||||
|
{
|
||||||
|
check: Check{ // Scored checks with passing tests are marked pass
|
||||||
|
Scored: true,
|
||||||
|
Audit: ":", Commands: []*exec.Cmd{exec.Command("")},
|
||||||
|
Tests: &tests{TestItems: []*testItem{&testItem{}}},
|
||||||
|
},
|
||||||
|
Expected: PASS,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user