diff options
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) + } +} |
