forked from containers/common
-
Notifications
You must be signed in to change notification settings - Fork 1
/
validate_test.go
41 lines (37 loc) · 885 Bytes
/
validate_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
//go:build seccomp
// +build seccomp
package seccomp
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestValidateProfile(t *testing.T) {
for _, tc := range []struct {
input string
shouldErr bool
}{
{ // success
input: `{"defaultAction": "SCMP_ACT_KILL"}`,
shouldErr: false,
},
{ // Unmarshal failed
input: "wrong",
shouldErr: true,
},
{ // setupSeccomp failed
input: `{"defaultAction": "SCMP_ACT_KILL", "architectures": ["SCMP_ARCH_X86"], "archMap": [{"architecture": "SCMP_ARCH_X86"}]}`,
shouldErr: true,
},
{ // BuildFilter failed
input: `{"defaultAction": "SCMP_ACT_KILL", "architectures": ["SCMP_ARCH_X86"], "syscalls": [{ "name": "open" }]}`,
shouldErr: true,
},
} {
err := ValidateProfile(tc.input)
if tc.shouldErr {
require.NotNil(t, err)
} else {
require.Nil(t, err)
}
}
}