http3: migrate the server tests away from Ginkgo (#5085)

* http3: migrate the server tests away from Ginkgo

* http3: add a test for server settings
This commit is contained in:
Marten Seemann
2025-04-30 12:53:37 +08:00
committed by GitHub
parent e4bb2dbd55
commit 9d06679273
3 changed files with 755 additions and 1186 deletions

View File

@@ -1,6 +1,7 @@
package http3
import (
"net"
"os"
"strconv"
"testing"
@@ -8,6 +9,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
@@ -16,6 +18,14 @@ func TestHttp3(t *testing.T) {
RunSpecs(t, "HTTP/3 Suite")
}
func newUDPConnLocalhost(t testing.TB) *net.UDPConn {
t.Helper()
conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0})
require.NoError(t, err)
t.Cleanup(func() { conn.Close() })
return conn
}
var mockCtrl *gomock.Controller
var _ = BeforeEach(func() {

View File

@@ -24,16 +24,6 @@ import (
"github.com/quic-go/qpack"
)
// allows mocking of quic.Listen and quic.ListenAddr
var (
quicListen = func(conn net.PacketConn, tlsConf *tls.Config, config *quic.Config) (QUICEarlyListener, error) {
return quic.ListenEarly(conn, tlsConf, config)
}
quicListenAddr = func(addr string, tlsConf *tls.Config, config *quic.Config) (QUICEarlyListener, error) {
return quic.ListenAddrEarly(addr, tlsConf, config)
}
)
// NextProtoH3 is the ALPN protocol negotiated during the TLS handshake, for QUIC v1 and v2.
const NextProtoH3 = "h3"
@@ -349,9 +339,9 @@ func (s *Server) setupListenerForConn(tlsConf *tls.Config, conn net.PacketConn)
if addr == "" {
addr = ":https"
}
ln, err = quicListenAddr(addr, baseConf, quicConf)
ln, err = quic.ListenAddrEarly(addr, baseConf, quicConf)
} else {
ln, err = quicListen(conn, baseConf, quicConf)
ln, err = quic.ListenEarly(conn, baseConf, quicConf)
}
if err != nil {
return nil, err

File diff suppressed because it is too large Load Diff