cc24f28b9d
* feat(netxlite): support extracting the CNAME Closes https://github.com/ooni/probe/issues/2225 * fix(netxlite): attempt to increase coverage and improve tests 1. dnsovergetaddrinfo: specify the behavior of a DNSResponse returned by this file to make it line with normal responses and write unit tests to make sure we adhere to expectations; 2. dnsoverudp: make sure we wait to deferred responses also w/o a custom context and post on a private channel and test that; 3. utls: recognize that we can actually write a test for NetConn and what needs to change when we'll use go1.19 by default will just be a cast that at that point can be removed.
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package mocks
|
|
|
|
//
|
|
// Mocks for model.DNSResponse
|
|
//
|
|
|
|
import (
|
|
"net"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
|
)
|
|
|
|
// DNSResponse allows mocking model.DNSResponse.
|
|
type DNSResponse struct {
|
|
MockQuery func() model.DNSQuery
|
|
MockBytes func() []byte
|
|
MockRcode func() int
|
|
MockDecodeHTTPS func() (*model.HTTPSSvc, error)
|
|
MockDecodeLookupHost func() ([]string, error)
|
|
MockDecodeNS func() ([]*net.NS, error)
|
|
MockDecodeCNAME func() (string, error)
|
|
}
|
|
|
|
var _ model.DNSResponse = &DNSResponse{}
|
|
|
|
func (r *DNSResponse) Query() model.DNSQuery {
|
|
return r.MockQuery()
|
|
}
|
|
|
|
func (r *DNSResponse) Bytes() []byte {
|
|
return r.MockBytes()
|
|
}
|
|
|
|
func (r *DNSResponse) Rcode() int {
|
|
return r.MockRcode()
|
|
}
|
|
|
|
func (r *DNSResponse) DecodeHTTPS() (*model.HTTPSSvc, error) {
|
|
return r.MockDecodeHTTPS()
|
|
}
|
|
|
|
func (r *DNSResponse) DecodeLookupHost() ([]string, error) {
|
|
return r.MockDecodeLookupHost()
|
|
}
|
|
|
|
func (r *DNSResponse) DecodeNS() ([]*net.NS, error) {
|
|
return r.MockDecodeNS()
|
|
}
|
|
|
|
func (r *DNSResponse) DecodeCNAME() (string, error) {
|
|
return r.MockDecodeCNAME()
|
|
}
|