MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_regular_mode_no_hook

Function test_regular_mode_no_hook

test/mitmproxy/proxy/layers/test_dns.py:105–144  ·  view source on GitHub ↗
(tctx, transport_protocol)

Source from the content-addressed store, hash-verified

103
104@pytest.mark.parametrize("transport_protocol", ["tcp", "udp"])
105def test_regular_mode_no_hook(tctx, transport_protocol):
106 tctx.client.transport_protocol = transport_protocol
107 tctx.server.transport_protocol = transport_protocol
108
109 f = Placeholder(DNSFlow)
110 layer = dns.DNSLayer(tctx)
111 layer.context.server.address = None
112
113 req = tdnsreq()
114
115 def no_resolve(flow: DNSFlow):
116 nonlocal req
117 assert flow.request
118 req.timestamp = flow.request.timestamp
119 assert flow.request == req
120
121 assert (
122 Playbook(layer)
123 >> DataReceived(
124 tctx.client, dns.pack_message(req, tctx.client.transport_protocol)
125 )
126 << dns.DnsRequestHook(f)
127 >> reply(side_effect=no_resolve)
128 << dns.DnsErrorHook(f)
129 >> reply()
130 << SendData(
131 tctx.client,
132 dns.pack_message(
133 req.fail(response_codes.SERVFAIL), tctx.client.transport_protocol
134 ),
135 )
136 >> ConnectionClosed(tctx.client)
137 << None
138 )
139 assert f().request == req
140 assert not f().response
141 assert not f().live
142 assert (
143 f().error.msg == "No hook has set a response and there is no upstream server."
144 )
145
146
147@pytest.mark.parametrize("transport_protocol", ["tcp", "udp"])

Callers

nothing calls this directly

Calls 9

DataReceivedClass · 0.90
SendDataClass · 0.90
ConnectionClosedClass · 0.90
PlaceholderFunction · 0.85
tdnsreqFunction · 0.85
PlaybookClass · 0.85
replyClass · 0.85
failMethod · 0.80
fFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…