MCPcopy
hub / github.com/AdguardTeam/dnsproxy / TestFallbackFromInvalidBootstrap

Function TestFallbackFromInvalidBootstrap

proxy/proxy_internal_test.go:824–873  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

822}
823
824func TestFallbackFromInvalidBootstrap(t *testing.T) {
825 t.Parallel()
826
827 invalidRslv, err := upstream.NewUpstreamResolver("8.8.8.8:555", &upstream.Options{
828 Logger: testLogger,
829 Timeout: testTimeout,
830 })
831 require.NoError(t, err)
832
833 // Prepare the proxy server
834 upsConf, err := ParseUpstreamsConfig([]string{"tls://dns.adguard.com"}, &upstream.Options{
835 Logger: testLogger,
836 Bootstrap: invalidRslv, Timeout: testTimeout,
837 })
838 require.NoError(t, err)
839
840 dnsProxy := mustNew(t, &Config{
841 Logger: testLogger,
842 UDPListenAddr: []*net.UDPAddr{net.UDPAddrFromAddrPort(localhostAnyPort)},
843 TCPListenAddr: []*net.TCPAddr{net.TCPAddrFromAddrPort(localhostAnyPort)},
844 UpstreamConfig: upsConf,
845 TrustedProxies: defaultTrustedProxies,
846 Fallbacks: newTestUpstreamConfig(
847 t,
848 testTimeout,
849 "1.0.0.1",
850 "8.8.8.8",
851 ),
852 })
853
854 servicetest.RequireRun(t, dnsProxy, testTimeout)
855
856 // Create a DNS-over-UDP client connection
857 addr := dnsProxy.Addr(ProtoUDP)
858 conn, err := dns.Dial("udp", addr.String())
859 require.NoError(t, err)
860
861 // Make sure that the response is okay and resolved by the fallback
862 req := newTestMessage()
863 err = conn.WriteMsg(req)
864 require.NoError(t, err)
865
866 start := time.Now()
867 res, err := conn.ReadMsg()
868 require.NoError(t, err)
869 requireResponse(t, req, res)
870
871 elapsed := time.Since(start)
872 assert.Greater(t, 3*testTimeout, elapsed)
873}
874
875// Server must drop incoming Response messages
876func TestResponseInRequest(t *testing.T) {

Callers

nothing calls this directly

Calls 8

NewUpstreamResolverFunction · 0.92
ParseUpstreamsConfigFunction · 0.85
mustNewFunction · 0.85
newTestUpstreamConfigFunction · 0.85
newTestMessageFunction · 0.85
AddrMethod · 0.80
requireResponseFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…