diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 9f17bed52a..c5d0cd3162 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -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 +} diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 3a2673d0c7..fafb1dfe39 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -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()) }) diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go index bebe589c2f..2a54604ea5 100644 --- a/test/e2e/import_test.go +++ b/test/e2e/import_test.go @@ -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()) }) diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index 9acac1ffcf..4f1a956fa0 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -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")) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 5429dbfebb..43954536a9 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -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")) diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index 2a072c2ed7..0e3ae15159 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -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()) })