github.com/containers/podman/v4@v4.9.4/pkg/machine/e2e/proxy_test.go (about) 1 package e2e_test 2 3 import ( 4 "os" 5 6 "github.com/containers/podman/v4/pkg/machine" 7 . "github.com/onsi/ginkgo/v2" 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gexec" 10 ) 11 12 var _ = Describe("podman machine proxy settings propagation", func() { 13 var ( 14 mb *machineTestBuilder 15 testDir string 16 ) 17 18 BeforeEach(func() { 19 testDir, mb = setup() 20 }) 21 AfterEach(func() { 22 teardown(originalHomeDir, testDir, mb) 23 }) 24 25 It("ssh to running machine and check proxy settings", func() { 26 // https://github.com/containers/podman/issues/20129 27 if testProvider.VMType() == machine.HyperVVirt { 28 Skip("proxy settings not yet supported") 29 } 30 name := randomString() 31 i := new(initMachine) 32 session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run() 33 Expect(err).ToNot(HaveOccurred()) 34 Expect(session).To(Exit(0)) 35 36 defer func() { 37 httpProxyEnv := os.Getenv("HTTP_PROXY") 38 httpsProxyEnv := os.Getenv("HTTPS_PROXY") 39 if httpProxyEnv != "" { 40 os.Unsetenv("HTTP_PROXY") 41 } 42 if httpsProxyEnv != "" { 43 os.Unsetenv("HTTPS_PROXY") 44 } 45 }() 46 proxyURL := "http://abcdefghijklmnopqrstuvwxyz-proxy" 47 os.Setenv("HTTP_PROXY", proxyURL) 48 os.Setenv("HTTPS_PROXY", proxyURL) 49 50 s := new(startMachine) 51 startSession, err := mb.setName(name).setCmd(s).run() 52 Expect(err).ToNot(HaveOccurred()) 53 Expect(startSession).To(Exit(0)) 54 55 sshProxy := sshMachine{} 56 sshSession, err := mb.setName(name).setCmd(sshProxy.withSSHCommand([]string{"printenv", "HTTP_PROXY"})).run() 57 Expect(err).ToNot(HaveOccurred()) 58 Expect(sshSession).To(Exit(0)) 59 Expect(sshSession.outputToString()).To(ContainSubstring(proxyURL)) 60 61 sshSession, err = mb.setName(name).setCmd(sshProxy.withSSHCommand([]string{"printenv", "HTTPS_PROXY"})).run() 62 Expect(err).ToNot(HaveOccurred()) 63 Expect(sshSession).To(Exit(0)) 64 Expect(sshSession.outputToString()).To(ContainSubstring(proxyURL)) 65 }) 66 })