Skip to content

Commit

Permalink
test: Add a test to check an already exposed port cannot be exposed a…
Browse files Browse the repository at this point in the history
…gain

Signed-off-by: Gunjan Vyas <[email protected]>
  • Loading branch information
vyasgun committed Jan 10, 2025
1 parent e897a4a commit 989f20d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test-qemu/port_forwarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ var _ = ginkgo.Describe("port forwarding", func() {
g.Expect(err).ShouldNot(gomega.HaveOccurred())
g.Expect(resp.StatusCode).To(gomega.Equal(http.StatusOK))
}).Should(gomega.Succeed())

gomega.Eventually(func(g gomega.Gomega) {
// exposing the port again should return an error
out, _ = sshExec(`curl http://gateway.containers.internal/services/forwarder/expose -X POST -d'{"protocol":"unix","local":"` + unix2tcpfwdsock + `","remote":"tcp://192.168.127.2:8080"}'`)
g.Expect(string(out)).Should(gomega.ContainSubstring("proxy already running"))

// unexpose the port
out, err = sshExec(`curl http://gateway.containers.internal/services/forwarder/unexpose -X POST -d'{"protocol":"unix","local":"` + unix2tcpfwdsock + `","remote":"tcp://192.168.127.2:8080"}'`)
g.Expect(err).ShouldNot(gomega.HaveOccurred())
}).Should(gomega.Succeed())
})

ginkgo.It("should expose and reach rootless podman API using unix to unix forwarding over ssh", func() {
Expand Down

0 comments on commit 989f20d

Please sign in to comment.