MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_inject

Function test_inject

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

inject data into an open connection.

(tctx)

Source from the content-addressed store, hash-verified

104
105
106def test_inject(tctx):
107 """inject data into an open connection."""
108 f = Placeholder(UDPFlow)
109
110 assert (
111 Playbook(udp.UDPLayer(tctx))
112 << udp.UdpStartHook(f)
113 >> UdpMessageInjected(f, UDPMessage(True, b"hello!"))
114 >> reply(to=-2)
115 << OpenConnection(tctx.server)
116 >> reply(None)
117 << udp.UdpMessageHook(f)
118 >> reply()
119 << SendData(tctx.server, b"hello!")
120 # and the other way...
121 >> UdpMessageInjected(
122 f, UDPMessage(False, b"I have already done the greeting for you.")
123 )
124 << udp.UdpMessageHook(f)
125 >> reply()
126 << SendData(tctx.client, b"I have already done the greeting for you.")
127 << None
128 )
129 assert len(f().messages) == 2

Callers

nothing calls this directly

Calls 8

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