Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -3,10 +3,12 @@ |
| 3 | 3 |
package seccomp // import "github.com/docker/docker/profiles/seccomp" |
| 4 | 4 |
|
| 5 | 5 |
import ( |
| 6 |
+ "encoding/json" |
|
| 6 | 7 |
"io/ioutil" |
| 7 | 8 |
"testing" |
| 8 | 9 |
|
| 9 | 10 |
"github.com/opencontainers/runtime-spec/specs-go" |
| 11 |
+ "gotest.tools/v3/assert" |
|
| 10 | 12 |
) |
| 11 | 13 |
|
| 12 | 14 |
func TestLoadProfile(t *testing.T) {
|
| ... | ... |
@@ -44,6 +46,27 @@ func TestLoadDefaultProfile(t *testing.T) {
|
| 44 | 44 |
} |
| 45 | 45 |
} |
| 46 | 46 |
|
| 47 |
+func TestUnmarshalDefaultProfile(t *testing.T) {
|
|
| 48 |
+ expected := DefaultProfile() |
|
| 49 |
+ if expected == nil {
|
|
| 50 |
+ t.Skip("seccomp not supported")
|
|
| 51 |
+ } |
|
| 52 |
+ |
|
| 53 |
+ f, err := ioutil.ReadFile("default.json")
|
|
| 54 |
+ if err != nil {
|
|
| 55 |
+ t.Fatal(err) |
|
| 56 |
+ } |
|
| 57 |
+ var profile Seccomp |
|
| 58 |
+ err = json.Unmarshal(f, &profile) |
|
| 59 |
+ if err != nil {
|
|
| 60 |
+ t.Fatal(err) |
|
| 61 |
+ } |
|
| 62 |
+ assert.DeepEqual(t, expected.Architectures, profile.Architectures) |
|
| 63 |
+ assert.DeepEqual(t, expected.ArchMap, profile.ArchMap) |
|
| 64 |
+ assert.DeepEqual(t, expected.DefaultAction, profile.DefaultAction) |
|
| 65 |
+ assert.DeepEqual(t, expected.Syscalls, profile.Syscalls) |
|
| 66 |
+} |
|
| 67 |
+ |
|
| 47 | 68 |
func TestLoadConditional(t *testing.T) {
|
| 48 | 69 |
f, err := ioutil.ReadFile("fixtures/conditional_include.json")
|
| 49 | 70 |
if err != nil {
|