diff --git a/pkg/machine/e2e/basic_test.go b/pkg/machine/e2e/basic_test.go index c772b72ce4..c1fa5279f7 100644 --- a/pkg/machine/e2e/basic_test.go +++ b/pkg/machine/e2e/basic_test.go @@ -145,6 +145,32 @@ var _ = Describe("run basic podman commands", func() { Expect(findmnt).To(Exit(0)) Expect(findmnt.outputToString()).To(ContainSubstring("virtiofs")) } + + // Test build context support + mainContextDir := GinkgoT().TempDir() + cfile := filepath.Join(mainContextDir, "test1") + err = os.WriteFile(cfile, []byte("test1-"+name+"\n"), 0o644) + Expect(err).ToNot(HaveOccurred()) + + additionalContextDir := GinkgoT().TempDir() + cfile = filepath.Join(additionalContextDir, "test2") + err = os.WriteFile(cfile, []byte("test2-"+name+"\n"), 0o644) + Expect(err).ToNot(HaveOccurred()) + + cfile = filepath.Join(mainContextDir, "Containerfile") + err = os.WriteFile(cfile, []byte("FROM "+TESTIMAGE+"\nCOPY test1 /\nCOPY --from=test-context test2 /\n"), 0o644) + Expect(err).ToNot(HaveOccurred()) + + bm = basicMachine{} + build, err = mb.setCmd(bm.withPodmanCommand([]string{"build", "-t", name, "--build-context", "test-context=" + additionalContextDir, mainContextDir})).run() + Expect(err).ToNot(HaveOccurred()) + Expect(build).To(Exit(0)) + Expect(build.outputToString()).To(ContainSubstring("COMMIT")) + + run, err = mb.setCmd(bm.withPodmanCommand([]string{"run", name, "cat", "/test1", "/test2"})).run() + Expect(err).ToNot(HaveOccurred()) + Expect(run).To(Exit(0)) + Expect(run.outputToString()).To(And(ContainSubstring("test1-"+name), ContainSubstring("test2-"+name))) }) It("Volume should be disabled by command line", func() { @@ -260,44 +286,6 @@ var _ = Describe("run basic podman commands", func() { Expect(ls.outputToString()).To(ContainSubstring(testString)) }) - It("podman build contexts", func() { - name := randomString() - i := new(initMachine) - session, err := mb.setName(name).setCmd(i.withImage(mb.imagePath).withNow()).run() - Expect(err).ToNot(HaveOccurred()) - Expect(session).To(Exit(0)) - - mainContextDir := GinkgoT().TempDir() - cfile := filepath.Join(mainContextDir, "test1") - err = os.WriteFile(cfile, []byte(name), 0o644) - Expect(err).ToNot(HaveOccurred()) - - additionalContextDir := GinkgoT().TempDir() - cfile = filepath.Join(additionalContextDir, "test2") - err = os.WriteFile(cfile, []byte(name), 0o644) - Expect(err).ToNot(HaveOccurred()) - - cfile = filepath.Join(mainContextDir, "Containerfile") - err = os.WriteFile(cfile, []byte("FROM "+TESTIMAGE+"\nCOPY test1 /\nCOPY --from=test-context test2 /\n"), 0o644) - Expect(err).ToNot(HaveOccurred()) - - bm := basicMachine{} - build, err := mb.setCmd(bm.withPodmanCommand([]string{"build", "-t", name, "--build-context", "test-context=" + additionalContextDir, mainContextDir})).run() - Expect(err).ToNot(HaveOccurred()) - Expect(build).To(Exit(0)) - Expect(build.outputToString()).To(ContainSubstring("COMMIT")) - - run, err := mb.setCmd(bm.withPodmanCommand([]string{"run", name, "cat", "/test1"})).run() - Expect(err).ToNot(HaveOccurred()) - Expect(run).To(Exit(0)) - Expect(build.outputToString()).To(ContainSubstring(name)) - - run, err = mb.setCmd(bm.withPodmanCommand([]string{"run", name, "cat", "/test2"})).run() - Expect(err).ToNot(HaveOccurred()) - Expect(run).To(Exit(0)) - Expect(build.outputToString()).To(ContainSubstring(name)) - }) - It("CVE-2025-6032 regression test - HTTP", func() { // ensure that trying to pull from a local HTTP server fails and the connection will be rejected // ensure that tlsVerify is true by default