forked from aquasecurity/linux-bench
-
Notifications
You must be signed in to change notification settings - Fork 3
/
app_test.go
47 lines (39 loc) · 907 Bytes
/
app_test.go
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
package main
import (
"os"
"testing"
)
// Tests all standard linux-bench defintion files
func TestGetDefinitionFilePath(t *testing.T) {
d, err := os.Open("./cfg")
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
vers, err := d.Readdirnames(-1)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
for _, ver := range vers {
t.Logf("%v", ver)
_, err := getDefinitionFilePath(ver)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
}
}
func TestRunControls(t *testing.T) {
cfgDir = "./hack"
path, err := getDefinitionFilePath("test-definitions")
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
control, err := getControls(path, nil)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
// Run all checks
_ = runControls(control, "")
// Run only specified checks
checkList := "1.2, 2.1"
_ = runControls(control, checkList)
}