1
1
Fork 0
mirror of https://github.com/mjl-/mox.git synced 2025-04-21 21:40:01 +03:00

fix tests on bsds, since previous commit

the tls resumption test was failing due to switch from net.Pipe to unix domain
socket pairs. on bsds, they have an empty name (on linux it is "@"), which
prevents tls resumption from working.
This commit is contained in:
Mechiel Lukkien 2025-02-21 20:38:37 +01:00
parent f40f94670e
commit 7c7473ef0e
No known key found for this signature in database

View file

@ -350,6 +350,17 @@ func startArgs(t *testing.T, first, immediateTLS bool, allowLoginWithoutTLS, set
return startArgsMore(t, first, immediateTLS, nil, nil, allowLoginWithoutTLS, false, setPassword, accname, nil)
}
// namedConn wraps a conn so it can return a RemoteAddr with a non-empty name.
// The TLS resumption test needs a non-empty name, but on BSDs, the unix domain
// socket pair has an empty peer name.
type namedConn struct {
net.Conn
}
func (c namedConn) RemoteAddr() net.Addr {
return &net.TCPAddr{IP: net.ParseIP("127.0.0.10"), Port: 1234}
}
// todo: the parameters and usage are too much now. change to scheme similar to smtpserver, with params in a struct, and a separate method for init and making a connection.
func startArgsMore(t *testing.T, first, immediateTLS bool, serverConfig, clientConfig *tls.Config, allowLoginWithoutTLS, noCloseSwitchboard, setPassword bool, accname string, afterInit func() error) *testconn {
limitersInit() // Reset rate limiters.
@ -391,7 +402,7 @@ func startArgsMore(t *testing.T, first, immediateTLS bool, serverConfig, clientC
tcheck(t, err, "fileconn")
err = f.Close()
tcheck(t, err, "close file for conn")
return fc
return namedConn{fc}
}
serverConn := xfdconn(fds[0], "server")
clientConn := xfdconn(fds[1], "client")