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

Function TestHttpsProxy

proxy/serverhttps_internal_test.go:26–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestHttpsProxy(t *testing.T) {
27 testCases := []struct {
28 name string
29 http3 bool
30 }{{
31 name: "https_proxy",
32 http3: false,
33 }, {
34 name: "h3_proxy",
35 http3: true,
36 }}
37
38 for _, tc := range testCases {
39 t.Run(tc.name, func(t *testing.T) {
40 tlsConf, caPem := newTLSConfig(t)
41
42 httpConf := &HTTPConfig{
43 ListenAddresses: []netip.AddrPort{localhostAnyPort},
44 HTTP3Enabled: tc.http3,
45 }
46 dnsProxy := mustNew(t, &Config{
47 Logger: testLogger,
48 TLSListenAddr: []*net.TCPAddr{net.TCPAddrFromAddrPort(localhostAnyPort)},
49 QUICListenAddr: []*net.UDPAddr{net.UDPAddrFromAddrPort(localhostAnyPort)},
50 TLSConfig: tlsConf,
51 UpstreamConfig: newTestUpstreamConfig(t, defaultTimeout, testDefaultUpstreamAddr),
52 TrustedProxies: defaultTrustedProxies,
53 HTTPConfig: httpConf,
54 })
55
56 servicetest.RequireRun(t, dnsProxy, testTimeout)
57
58 // Create the HTTP client that we'll be using for this test.
59 client := createTestHTTPClient(dnsProxy, caPem, tc.http3)
60
61 // Prepare a test message to be sent to the server.
62 msg := newTestMessage()
63
64 // Send the test message and check if the response is what we
65 // expected.
66 resp := sendTestDoHMessage(t, client, msg, nil)
67 requireResponse(t, msg, resp)
68 })
69 }
70}
71
72func TestProxy_trustedProxies(t *testing.T) {
73 var (

Callers

nothing calls this directly

Calls 7

mustNewFunction · 0.85
newTestUpstreamConfigFunction · 0.85
createTestHTTPClientFunction · 0.85
newTestMessageFunction · 0.85
sendTestDoHMessageFunction · 0.85
newTLSConfigFunction · 0.70
requireResponseFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…