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/auth_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pkg/test/auth_test.go (limited to 'pkg/test/auth_test.go') diff --git a/pkg/test/auth_test.go b/pkg/test/auth_test.go new file mode 100644 index 0000000..cf5f28b --- /dev/null +++ b/pkg/test/auth_test.go @@ -0,0 +1,36 @@ +package test + +import ( + "testing" +) + +func TestAuthHook(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() + + xaddr := c.AddListenTunnel("X", "-aes -auth dial,addr=%s", listen.Addr()) + taddr := c.AddListenTunnel("T", "auth aes dial,addr=%s", xaddr) + + c.Exec("set tunnel.X.secret secret") + c.Exec("set tunnel.T.secret secret") + + out := xDial(t, "tcp", taddr) + 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