Skip to content

Commit

Permalink
tests: write seccomp profile to a temporary file (#1736)
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim An <maksiman@microsoft.com>
  • Loading branch information
anmaxvl committed Apr 18, 2023
1 parent 52eee99 commit 792a588
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/cri-containerd/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1731,14 +1731,20 @@ var validSeccomp []byte
var invalidSeccomp []byte

func Test_RunContainer_WithPolicy_And_Seccomp(t *testing.T) {
seccompProfilePath := filepath.Join(t.TempDir(), "seccomp_valid.json")
if err := os.WriteFile(seccompProfilePath, validSeccomp, 0755); err != nil {
t.Fatalf("failed to write seccomp profile to temp file: %s", err)
}
defer os.Remove(seccompProfilePath)

requireFeatures(t, featureLCOW, featureLCOWIntegrity)
pullRequiredLCOWImages(t, []string{imageLcowK8sPause, imageLcowAlpine})

client := newTestRuntimeClient(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

seccompPolicy := alpineSecurityPolicy(t, "rego", false, false, securitypolicy.WithSeccompProfilePath("seccomp_valid.json"))
seccompPolicy := alpineSecurityPolicy(t, "rego", false, false, securitypolicy.WithSeccompProfilePath(seccompProfilePath))
noSeccompPolicy := alpineSecurityPolicy(t, "rego", false, false)

validSeccompBase64 := base64.StdEncoding.EncodeToString(validSeccomp)
Expand Down

0 comments on commit 792a588

Please sign in to comment.