ooni-probe-cli/internal/engine/experiment/tlstool/internal/internal_test.go
Simone Basso 566c6b246a
cleanup: remove unnecessary legacy interfaces (#656)
This diff addresses another point of https://github.com/ooni/probe/issues/1956:

> - [ ] observe that we're still using a bunch of private interfaces for common interfaces such as the `Dialer`, so we can get rid of these private interfaces and always use the ones in `model`, which allows us to remove a bunch of legacy wrappers

Additional cleanups may still be possible. The more I cleanup, the more I see
there's extra legacy code we can dispose of (which seems good?).
2022-01-07 18:33:37 +01:00

42 lines
962 B
Go

package internal_test
import (
"context"
"testing"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/tlstool/internal"
"github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/model"
)
var config = internal.DialerConfig{
Dialer: netx.NewDialer(netx.Config{}),
Delay: 10,
SNI: "dns.google",
}
func dial(t *testing.T, d model.Dialer) {
td := netx.NewTLSDialer(netx.Config{Dialer: d})
conn, err := td.DialTLSContext(context.Background(), "tcp", "dns.google:853")
if err != nil {
t.Fatal(err)
}
conn.Close()
}
func TestNewSNISplitterDialer(t *testing.T) {
dial(t, internal.NewSNISplitterDialer(config))
}
func TestNewThriceSplitterDialer(t *testing.T) {
dial(t, internal.NewThriceSplitterDialer(config))
}
func TestNewRandomSplitterDialer(t *testing.T) {
dial(t, internal.NewRandomSplitterDialer(config))
}
func TestNewVanillaDialer(t *testing.T) {
dial(t, internal.NewVanillaDialer(config))
}