Merge pull request #69 from aquasecurity/test-order

Make unit tests work under GitHub Actions
This commit is contained in:
Yoav Rotem 2020-12-22 11:31:08 +02:00 committed by GitHub
commit ca36ec8929
Failed to generate hash of commit
3 changed files with 8930 additions and 8974 deletions

View file

@ -5,15 +5,9 @@ import (
"testing"
)
var (
cfgdir = "./cfg"
ver = "1.1.0"
path string
)
// Tests all standard linux-bench defintion files
func TestGetDefinitionFilePath(t *testing.T) {
d, err := os.Open(cfgdir)
d, err := os.Open("./cfg")
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
@ -24,6 +18,7 @@ func TestGetDefinitionFilePath(t *testing.T) {
}
for _, ver := range vers {
t.Logf("%v", ver)
_, err := getDefinitionFilePath(ver)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
@ -31,20 +26,13 @@ func TestGetDefinitionFilePath(t *testing.T) {
}
}
func TestGetControls(t *testing.T) {
var err error
path, err = getDefinitionFilePath(ver)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
_, err = getControls(path, nil)
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)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,35 @@
---
controls:
version: 0.1
id: 1
description: "Test YAMl file"
type: "hack"
groups:
- id: 1.1
description: "Filesystem Configuration"
checks:
- id: 1.1.1
description: "Disable unused filesystems"
checks:
- id: 1.1.1.1.a
description: "Ensure mounting of cramfs filesystems is disabled"
audit: "echo hello"
tests:
test_items:
- flag: "hello"
set: true
remediation: |
Correct something about this test
scored: true
- id: 1.1.1.1.b
description: "Ensure mounting of cramfs filesystems is disabled"
audit: "echo hello=false"
tests:
test_items:
- flag: "hello"
compare:
op: eq
value: "false"
set: true
remediation: |
Put your remediation here