Skip to content

Commit

Permalink
fix tests on bsds, since previous commit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mjl- committed Feb 21, 2025
1 parent f40f946 commit 7c7473e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion imapserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 7c7473e

Please sign in to comment.