566c6b246a
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?).
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package dialer
|
|
|
|
import (
|
|
"net/url"
|
|
"testing"
|
|
|
|
"github.com/apex/log"
|
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
|
)
|
|
|
|
func TestNewCreatesTheExpectedChain(t *testing.T) {
|
|
saver := &trace.Saver{}
|
|
dlr := New(&Config{
|
|
ContextByteCounting: true,
|
|
DialSaver: saver,
|
|
Logger: log.Log,
|
|
ProxyURL: &url.URL{},
|
|
ReadWriteSaver: saver,
|
|
}, netxlite.DefaultResolver)
|
|
shd, ok := dlr.(*shapingDialer)
|
|
if !ok {
|
|
t.Fatal("not a shapingDialer")
|
|
}
|
|
bcd, ok := shd.Dialer.(*byteCounterDialer)
|
|
if !ok {
|
|
t.Fatal("not a byteCounterDialer")
|
|
}
|
|
pd, ok := bcd.Dialer.(*proxyDialer)
|
|
if !ok {
|
|
t.Fatal("not a proxyDialer")
|
|
}
|
|
dnsd, ok := pd.Dialer.(*netxlite.DialerResolver)
|
|
if !ok {
|
|
t.Fatal("not a dnsDialer")
|
|
}
|
|
scd, ok := dnsd.Dialer.(*saverConnDialer)
|
|
if !ok {
|
|
t.Fatal("not a saverConnDialer")
|
|
}
|
|
sd, ok := scd.Dialer.(*saverDialer)
|
|
if !ok {
|
|
t.Fatal("not a saverDialer")
|
|
}
|
|
ld, ok := sd.Dialer.(*netxlite.DialerLogger)
|
|
if !ok {
|
|
t.Fatal("not a loggingDialer")
|
|
}
|
|
ewd, ok := ld.Dialer.(*netxlite.ErrorWrapperDialer)
|
|
if !ok {
|
|
t.Fatal("not an errorWrappingDialer")
|
|
}
|
|
_, ok = ewd.Dialer.(*netxlite.DialerSystem)
|
|
if !ok {
|
|
t.Fatal("not a DialerSystem")
|
|
}
|
|
}
|