summaryrefslogtreecommitdiff
path: root/pkg/test/auth_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/test/auth_test.go')
-rw-r--r--pkg/test/auth_test.go27
1 files changed, 12 insertions, 15 deletions
diff --git a/pkg/test/auth_test.go b/pkg/test/auth_test.go
index 41d1c2d..3b84874 100644
--- a/pkg/test/auth_test.go
+++ b/pkg/test/auth_test.go
@@ -5,8 +5,10 @@ import (
)
func TestAuthHook(t *testing.T) {
- c, s := newClientServer(t)
- defer closeClientServer(c, s)
+ e := newEnv(t)
+ defer e.Free()
+
+ c := e.newInstance()
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]")
@@ -14,23 +16,18 @@ func TestAuthHook(t *testing.T) {
c.Exec("set tunnel.X.secret secret")
c.Exec("set tunnel.T.secret secret")
- listen := xListen(t, "tcp", "127.0.0.1:0")
- defer listen.Close()
-
+ listen := e.Listen("tcp", "127.0.0.1:0")
c.Set("addr", listen.Addr())
- out := xDial(t, "tcp", c.Get("tunnel.T.listen"))
- defer out.Close()
-
- in := xAccept(t, listen)
- defer in.Close()
+ out := e.Dial("tcp", c.Get("tunnel.T.listen"))
+ in := e.Accept(listen)
- xWrite(t, out, xData)
+ e.Write(out, dummy)
- buf := make([]byte, len(xData))
- xReadFull(t, in, buf)
+ buf := make([]byte, len(dummy))
+ e.ReadFull(in, buf)
- if r := string(buf); r != xData {
- t.Fatalf("wrong reply: send '%s', recv '%s'", xData, r)
+ if r := string(buf); r != dummy {
+ e.Fatalf("wrong reply: send '%s', recv '%s'", dummy, r)
}
}