fix(quic): properly unwrap OONI errors from TransportError (#495)
Noticed while playing around with QUIC code. Part of https://github.com/ooni/probe/issues/1544.
This commit is contained in:
parent
50b58672c6
commit
00a85cb7f0
10 changed files with 128 additions and 27 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
utls "gitlab.com/yawning/utls.git"
|
||||
)
|
||||
|
|
@ -90,3 +91,45 @@ func TestUTLSHandshaker(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestQUICDialer(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skip test in short mode")
|
||||
}
|
||||
|
||||
t.Run("works as intended", func(t *testing.T) {
|
||||
tlsConfig := &tls.Config{
|
||||
ServerName: "dns.google",
|
||||
}
|
||||
d := netxlite.NewQUICDialerWithoutResolver(
|
||||
netxlite.NewQUICListener(), log.Log,
|
||||
)
|
||||
ctx := context.Background()
|
||||
sess, err := d.DialContext(
|
||||
ctx, "udp", "8.8.8.8:443", tlsConfig, &quic.Config{})
|
||||
if err != nil {
|
||||
t.Fatal("not the error we expected", err)
|
||||
}
|
||||
<-sess.HandshakeComplete().Done()
|
||||
if err := sess.CloseWithError(0, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("can guess the SNI and ALPN when using a domain name for web", func(t *testing.T) {
|
||||
d := netxlite.NewQUICDialerWithResolver(
|
||||
netxlite.NewQUICListener(), log.Log,
|
||||
netxlite.NewResolverSystem(log.Log),
|
||||
)
|
||||
ctx := context.Background()
|
||||
sess, err := d.DialContext(
|
||||
ctx, "udp", "dns.google:443", &tls.Config{}, &quic.Config{})
|
||||
if err != nil {
|
||||
t.Fatal("not the error we expected", err)
|
||||
}
|
||||
<-sess.HandshakeComplete().Done()
|
||||
if err := sess.CloseWithError(0, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue