diff options
| author | Mikhail Osipov <mike.osipov@gmail.com> | 2020-12-16 15:27:48 +0300 |
|---|---|---|
| committer | Mikhail Osipov <mike.osipov@gmail.com> | 2020-12-16 15:27:48 +0300 |
| commit | 6fed9dd0dd62718f78eca11e30a71c2712636fbd (patch) | |
| tree | 8d1f90b96efbe8ea8aea350c283325adc216ef9d /pkg/test/proxy_test.go | |
| parent | 050ea053dd549f0dd01beddfcd74989858391fd7 (diff) | |
hook and socket args check fix, tests
Diffstat (limited to 'pkg/test/proxy_test.go')
| -rw-r--r-- | pkg/test/proxy_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
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) + } +} |
