test/e2e: do not assume /etc/containers/policy.json

With the new config work we expect policy.json to be shipped under
/usr/share/containers/policy.json. However the CI VMs and local users
might still have it in /etc so instead of assuming any host path lets
just create our own files for the --signature-policy tests.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2026-07-14 18:59:39 +02:00
parent f9cd40e5af
commit d79cff0799
No known key found for this signature in database
GPG key ID: EB145DD938A3CAF2
6 changed files with 31 additions and 5 deletions

View file

@ -1830,3 +1830,29 @@ func SkipIfNotAMD64() {
Skip("test only valid on amd64")
}
}
const policyContent = `{
"default": [
{
"type": "insecureAcceptAnything"
}
],
"transports":
{
"docker-daemon":
{
"": [{"type":"insecureAcceptAnything"}]
}
}
}
`
// createPolicyJSONFile creates a policy.json file in podmanTest.TempDir with an
// insecureAcceptAnything policy and returns the path to that file.
func createPolicyJSONFile() string {
GinkgoHelper()
path := filepath.Join(podmanTest.TempDir, "policy.json")
err := os.WriteFile(path, []byte(policyContent), 0o600)
Expect(err).ToNot(HaveOccurred())
return path
}

View file

@ -354,7 +354,7 @@ var _ = Describe("Podman create", func() {
Expect(session).To(ExitWithError(125, "open /no/such/file: no such file or directory"))
}
session = podmanTest.Podman([]string{"create", "-q", "--pull=always", "--signature-policy", "/etc/containers/policy.json", ALPINE})
session = podmanTest.Podman([]string{"create", "-q", "--pull=always", "--signature-policy", createPolicyJSONFile(), ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
})

View file

@ -174,7 +174,7 @@ var _ = Describe("Podman import", func() {
importImage.WaitWithDefaultTimeout()
Expect(importImage).To(ExitWithError(125, "open /no/such/file: no such file or directory"))
result := podmanTest.Podman([]string{"import", "-q", "--signature-policy", "/etc/containers/policy.json", outfile})
result := podmanTest.Podman([]string{"import", "-q", "--signature-policy", createPolicyJSONFile(), outfile})
result.WaitWithDefaultTimeout()
Expect(result).Should(ExitCleanly())
})

View file

@ -85,7 +85,7 @@ var _ = Describe("Podman load", func() {
rmi.WaitWithDefaultTimeout()
Expect(rmi).Should(ExitCleanly())
result := podmanTest.Podman([]string{"load", "-q", "--signature-policy", "/etc/containers/policy.json", "-i", outfile})
result := podmanTest.Podman([]string{"load", "-q", "--signature-policy", createPolicyJSONFile(), "-i", outfile})
result.WaitWithDefaultTimeout()
if IsRemote() {
Expect(result).To(ExitWithError(125, "unknown flag: --signature-policy"))

View file

@ -146,7 +146,7 @@ var _ = Describe("Podman run", func() {
}
Expect(session).To(ExitWithError(125, "open /no/such/file: no such file or directory"))
session = podmanTest.Podman([]string{"run", "--pull=always", "--signature-policy", "/etc/containers/policy.json", ALPINE})
session = podmanTest.Podman([]string{"run", "--pull=always", "--signature-policy", createPolicyJSONFile(), ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.ErrorToString()).To(ContainSubstring("Getting image source signatures"))

View file

@ -29,7 +29,7 @@ var _ = Describe("Podman save", func() {
SkipIfRemote("--signature-policy N/A for remote")
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
save := podmanTest.Podman([]string{"save", "-q", "--signature-policy", "/etc/containers/policy.json", "-o", outfile, ALPINE})
save := podmanTest.Podman([]string{"save", "-q", "--signature-policy", createPolicyJSONFile(), "-o", outfile, ALPINE})
save.WaitWithDefaultTimeout()
Expect(save).Should(ExitCleanly())
})