Skip to content
Merged
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
7 changes: 7 additions & 0 deletions internal/shared/util/image/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,15 @@ func buildSourceContextFunc(t *testing.T, ref reference.Named) func(context.Cont
require.NoError(t, enc.Encode(registriesConf))
require.NoError(t, f.Close())

// Create an insecure policy for testing to override any system-level policy
// that might reject unsigned images
policyPath := filepath.Join(configDir, "policy.json")
insecurePolicy := `{"default":[{"type":"insecureAcceptAnything"}]}`
require.NoError(t, os.WriteFile(policyPath, []byte(insecurePolicy), 0600))

return &types.SystemContext{
SystemRegistriesConfPath: registriesConfPath,
SignaturePolicyPath: policyPath,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @camilamacedo86!
What's the concern here? Is it that we're dropping a file in t.TempDir() for use in this test scenario?
That's the only difference I see between the approaches.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I would love to avoid the temp file generation, this is just a different API than the app uses, and an attempt to avoid writing the overriding signature policy file results in uglier shenanigans.

Copy link
Contributor

@camilamacedo86 camilamacedo86 Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delta is that we are trying to solve it with the signature if not be possible then we let it go instead of fixed se "default": [{"type": "insecureAcceptAnything"}].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following you.
Right now this test fails on users' machines with a restrictive signing policy, but the test should not be sensitive to users' environments.
Here creates an insecure signing policy for the scoped tests to be used instead of detecting the users' policies.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is fine

/lgtm

}, nil
}
}
Loading