MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_simple

Function test_simple

test/mitmproxy/proxy/layers/test_udp.py:42–67  ·  view source on GitHub ↗

open connection, receive data, send it to peer

(tctx)

Source from the content-addressed store, hash-verified

40
41
42def test_simple(tctx):
43 """open connection, receive data, send it to peer"""
44 f = Placeholder(UDPFlow)
45
46 assert (
47 Playbook(udp.UDPLayer(tctx))
48 << udp.UdpStartHook(f)
49 >> reply()
50 << OpenConnection(tctx.server)
51 >> reply(None)
52 >> DataReceived(tctx.client, b"hello!")
53 << udp.UdpMessageHook(f)
54 >> reply()
55 << SendData(tctx.server, b"hello!")
56 >> DataReceived(tctx.server, b"hi")
57 << udp.UdpMessageHook(f)
58 >> reply()
59 << SendData(tctx.client, b"hi")
60 >> ConnectionClosed(tctx.server)
61 << CloseConnection(tctx.client)
62 << udp.UdpEndHook(f)
63 >> reply()
64 >> DataReceived(tctx.server, b"ignored")
65 << None
66 )
67 assert len(f().messages) == 2
68
69
70def test_receive_data_before_server_connected(tctx):

Callers

nothing calls this directly

Calls 9

OpenConnectionClass · 0.90
DataReceivedClass · 0.90
SendDataClass · 0.90
ConnectionClosedClass · 0.90
CloseConnectionClass · 0.90
PlaceholderFunction · 0.85
PlaybookClass · 0.85
replyClass · 0.85
fFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…