From 6fed9dd0dd62718f78eca11e30a71c2712636fbd Mon Sep 17 00:00:00 2001 From: Mikhail Osipov Date: Wed, 16 Dec 2020 15:27:48 +0300 Subject: hook and socket args check fix, tests --- pkg/test/proxy_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pkg/test/proxy_test.go (limited to 'pkg/test/proxy_test.go') diff --git a/pkg/test/proxy_test.go b/pkg/test/proxy_test.go new file mode 100644 index 0000000..b2fb097 --- /dev/null +++ b/pkg/test/proxy_test.go @@ -0,0 +1,36 @@ +package test + +import ( + "testing" +) + +func TestProxyHook(t *testing.T) { + const msg = "Hello, World!" + + c, s := newClientServer(t) + defer closeClientServer(c, s) + + listen := xListen(t, "tcp", "127.0.0.1:0") + defer listen.Close() + + saddr := c.AddListenTunnel("S", "proxy") + caddr := c.AddListenTunnel("C", "proxy,addr=%s dial,addr=%s", listen.Addr(), saddr) + + c.Exec("set tunnel.S.proxy.auth user:password") + c.Exec("set tunnel.C.proxy.auth user:password") + + out := xDial(t, "tcp", caddr) + defer out.Close() + + in := xAccept(t, listen) + defer in.Close() + + xWrite(t, out, msg) + + buf := make([]byte, len(msg)) + xReadFull(t, in, buf) + + if r := string(buf); r != msg { + t.Fatalf("wrong reply: send '%s', recv '%s'", msg, r) + } +} -- cgit v1.2.3-70-g09d2