refactor(netxlite): expose useful HTTPTransport/DNSTransport factories (#813)
These factories will soon be useful to finish with https://github.com/ooni/probe/issues/2135.
This commit is contained in:
parent
1a706e47bc
commit
1685ef75b5
9 changed files with 224 additions and 30 deletions
|
|
@ -13,6 +13,36 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/internal/model/mocks"
|
||||
)
|
||||
|
||||
func TestNewDNSOverHTTPSTransport(t *testing.T) {
|
||||
const URL = "https://1.1.1.1/dns-query"
|
||||
clnt := NewHTTPClientStdlib(model.DiscardLogger)
|
||||
txp := NewDNSOverHTTPSTransport(clnt, URL)
|
||||
ew := txp.(*dnsTransportErrWrapper)
|
||||
https := ew.DNSTransport.(*DNSOverHTTPSTransport)
|
||||
if https.Client != clnt {
|
||||
t.Fatal("invalid client")
|
||||
}
|
||||
if https.URL != URL {
|
||||
t.Fatal("invalid URL")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewDNSOverHTTPSTransportWithHTTPTransport(t *testing.T) {
|
||||
const URL = "https://1.1.1.1/dns-query"
|
||||
httpTxp := NewHTTPTransportStdlib(model.DiscardLogger)
|
||||
txp := NewDNSOverHTTPSTransportWithHTTPTransport(httpTxp, URL)
|
||||
ew := txp.(*dnsTransportErrWrapper)
|
||||
https := ew.DNSTransport.(*DNSOverHTTPSTransport)
|
||||
ewClient := https.Client.(*httpClientErrWrapper)
|
||||
clnt := ewClient.HTTPClient.(*http.Client)
|
||||
if clnt.Transport != httpTxp {
|
||||
t.Fatal("invalid transport")
|
||||
}
|
||||
if https.URL != URL {
|
||||
t.Fatal("invalid URL")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDNSOverHTTPSTransport(t *testing.T) {
|
||||
t.Run("RoundTrip", func(t *testing.T) {
|
||||
t.Run("query serialization failure", func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue