1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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)
}
}
|