MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_reverse_fail_connection

Function test_reverse_fail_connection

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

Source from the content-addressed store, hash-verified

248
249@pytest.mark.parametrize("transport_protocol", ["tcp", "udp"])
250def test_reverse_fail_connection(tctx, transport_protocol):
251 tctx.client.transport_protocol = transport_protocol
252 tctx.server.transport_protocol = transport_protocol
253
254 f = Placeholder(DNSFlow)
255 layer = dns.DNSLayer(tctx)
256 layer.context.server.address = ("8.8.8.8", 53)
257
258 req = tdnsreq()
259
260 assert (
261 Playbook(layer)
262 >> DataReceived(
263 tctx.client, dns.pack_message(req, tctx.client.transport_protocol)
264 )
265 << dns.DnsRequestHook(f)
266 >> reply()
267 << OpenConnection(tctx.server)
268 >> reply("UDP no likey today.")
269 << dns.DnsErrorHook(f)
270 >> reply()
271 << SendData(
272 tctx.client,
273 dns.pack_message(
274 req.fail(response_codes.SERVFAIL), tctx.client.transport_protocol
275 ),
276 )
277 << None
278 )
279 assert f().request
280 assert not f().response
281 assert f().error.msg == "UDP no likey today."
282 req.timestamp = f().request.timestamp
283 assert f().request == req
284
285
286@pytest.mark.parametrize("transport_protocol", ["tcp", "udp"])

Callers

nothing calls this directly

Calls 9

DataReceivedClass · 0.90
OpenConnectionClass · 0.90
SendDataClass · 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…