Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix error assertion and container layer sha256 #1725

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/cri-containerd/policy-v0.1.0.rego
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ containers := [
{
"command": ["ash","-c","echo 'Hello'"],
"env_rules": [{"pattern": `PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`, "strategy": "string", "required": true},{"pattern": `TERM=xterm`, "strategy": "string", "required": false}],
"layers": ["0196c8ecca6c885a250b186ed8449cf42d737b8551b8d0839381461d95461802"],
"layers": ["ebac866d4031abdde44160431606f4b4d75db0b0c675e9e4f46244dd5f3e81e2"],
"mounts": [],
"exec_processes": [],
"signals": [],
Expand Down
7 changes: 5 additions & 2 deletions test/cri-containerd/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ func Test_RunPrivilegedContainer_WithPolicy_And_AllowElevated_NotSet(t *testing.
); err == nil {
t.Fatalf("expected to fail")
} else {
expectedErrStr := "privileged escalation unmatched by policy rule"
expectedErrStr := "privileged escalation not allowed"
if !assertErrorContains(t, err, expectedErrStr) {
t.Fatalf("expected different error: %s", err)
}
Expand Down Expand Up @@ -1021,6 +1021,9 @@ func Test_RunPodSandboxAllowed_WithPolicy_EncryptedScratchPolicy(t *testing.T) {
},
} {
t.Run(fmt.Sprintf("AllowUnencrypted_%t_EncryptionEnabled_%t", tc.allowUnencrypted, tc.encryptAnnotation), func(t *testing.T) {
if tc.encryptAnnotation && !*flagSevSnp {
t.Skip("not running on SNP hardware, dm-crypt not supported")
}
policy := policyFromOpts(
t,
"rego",
Expand Down Expand Up @@ -1954,7 +1957,7 @@ func Test_Plan9Mount_WithPolicy(t *testing.T) {
t.Fatalf("container creation should have succeeded: %s", err)
}
expectedErrStr := "invalid mount list: /mounts/p9"
if !strings.Contains(err.Error(), expectedErrStr) {
if !assertErrorContains(t, err, expectedErrStr) {
t.Fatalf("expected '%s' policy error, got: %s", expectedErrStr, err)
}
}
Expand Down