refactor(netxlite): finish grouping tests (#488)

They are now more readable. I'll do another pass and start
separating integration testing from unit testing.

I think we need to have some always on integration testing
for netxlite that runs on macOS, linux, and windows.

See https://github.com/ooni/probe/issues/1591
This commit is contained in:
Simone Basso 2021-09-08 11:39:27 +02:00 committed by GitHub
commit f2e3e5cc08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 1100 additions and 1088 deletions

View file

@ -1,12 +1,15 @@
package netxlite_test
import (
"context"
"crypto/tls"
"net"
"net/http"
"testing"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/netxlite"
utls "gitlab.com/yawning/utls.git"
)
func TestHTTPTransport(t *testing.T) {
@ -49,3 +52,21 @@ func TestHTTP3Transport(t *testing.T) {
txp.CloseIdleConnections()
})
}
func TestUTLSHandshaker(t *testing.T) {
t.Run("with chrome fingerprint", func(t *testing.T) {
h := netxlite.NewTLSHandshakerUTLS(log.Log, &utls.HelloChrome_Auto)
cfg := &tls.Config{ServerName: "google.com"}
conn, err := net.Dial("tcp", "google.com:443")
if err != nil {
t.Fatal("unexpected error", err)
}
conn, _, err = h.Handshake(context.Background(), conn, cfg)
if err != nil {
t.Fatal("unexpected error", err)
}
if conn == nil {
t.Fatal("nil connection")
}
})
}