summaryrefslogtreecommitdiff
path: root/pkg/test/auth_test.go
diff options
context:
space:
mode:
authorMikhail Osipov <mike.osipov@gmail.com>2020-12-16 18:03:08 +0300
committerMikhail Osipov <mike.osipov@gmail.com>2020-12-16 18:03:08 +0300
commit6b76a30c04cb74dd9a759789f75bba2eea86a1fb (patch)
tree802dd014510e6d871a8faa32a4c3073ac8d86fa3 /pkg/test/auth_test.go
parent6fed9dd0dd62718f78eca11e30a71c2712636fbd (diff)
add defer test
Diffstat (limited to 'pkg/test/auth_test.go')
-rw-r--r--pkg/test/auth_test.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/pkg/test/auth_test.go b/pkg/test/auth_test.go
index cf5f28b..41d1c2d 100644
--- a/pkg/test/auth_test.go
+++ b/pkg/test/auth_test.go
@@ -5,32 +5,32 @@ import (
)
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("add name T listen,addr=-:0 auth aes dial,addr=@[tunnel.X.listen]")
+ c.Exec("add name X listen,addr=-:0 -aes -auth dial,addr=@[addr]")
c.Exec("set tunnel.X.secret secret")
c.Exec("set tunnel.T.secret secret")
- out := xDial(t, "tcp", taddr)
+ listen := xListen(t, "tcp", "127.0.0.1:0")
+ defer listen.Close()
+
+ c.Set("addr", listen.Addr())
+
+ out := xDial(t, "tcp", c.Get("tunnel.T.listen"))
defer out.Close()
in := xAccept(t, listen)
defer in.Close()
- xWrite(t, out, msg)
+ xWrite(t, out, xData)
- buf := make([]byte, len(msg))
+ buf := make([]byte, len(xData))
xReadFull(t, in, buf)
- if r := string(buf); r != msg {
- t.Fatalf("wrong reply: send '%s', recv '%s'", msg, r)
+ if r := string(buf); r != xData {
+ t.Fatalf("wrong reply: send '%s', recv '%s'", xData, r)
}
}