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/auth_test.go | |
| parent | 050ea053dd549f0dd01beddfcd74989858391fd7 (diff) | |
hook and socket args check fix, tests
Diffstat (limited to 'pkg/test/auth_test.go')
| -rw-r--r-- | pkg/test/auth_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
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) + } +} |
