refactor(netx): extract tlsdialer from dialer
This commit is contained in:
parent
e0311e8fed
commit
704e5bd870
18 changed files with 699 additions and 494 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package dialer_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
|
@ -10,31 +9,6 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/internal/engine/netx/dialer"
|
||||
)
|
||||
|
||||
func TestTLSDialerSuccess(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skip test in short mode")
|
||||
}
|
||||
log.SetLevel(log.DebugLevel)
|
||||
dialer := dialer.TLSDialer{Dialer: new(net.Dialer),
|
||||
TLSHandshaker: dialer.LoggingTLSHandshaker{
|
||||
TLSHandshaker: dialer.SystemTLSHandshaker{},
|
||||
Logger: log.Log,
|
||||
},
|
||||
}
|
||||
txp := &http.Transport{DialTLS: func(network, address string) (net.Conn, error) {
|
||||
// AlpineLinux edge is still using Go 1.13. We cannot switch to
|
||||
// using DialTLSContext here as we'd like to until either Alpine
|
||||
// switches to Go 1.14 or we drop the MK dependency.
|
||||
return dialer.DialTLSContext(context.Background(), network, address)
|
||||
}}
|
||||
client := &http.Client{Transport: txp}
|
||||
resp, err := client.Get("https://www.google.com")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
}
|
||||
|
||||
func TestDNSDialerSuccess(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skip test in short mode")
|
||||
|
|
|
|||
Loading…
Reference in a new issue