From 989f20de41e0740c5abea2fb8e015a2a26ef0c14 Mon Sep 17 00:00:00 2001 From: Gunjan Vyas Date: Fri, 10 Jan 2025 16:15:47 +0530 Subject: [PATCH] test: Add a test to check an already exposed port cannot be exposed again Signed-off-by: Gunjan Vyas --- test-qemu/port_forwarding_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test-qemu/port_forwarding_test.go b/test-qemu/port_forwarding_test.go index d08951c6..b3abc07b 100644 --- a/test-qemu/port_forwarding_test.go +++ b/test-qemu/port_forwarding_test.go @@ -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() {