MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / test_simple

Function test_simple

test/mitmproxy/proxy/layers/test_tcp.py:43–70  ·  view source on GitHub ↗

open connection, receive data, send it to peer

(tctx)

Source from the content-addressed store, hash-verified

41
42
43def test_simple(tctx):
44 """open connection, receive data, send it to peer"""
45 f = Placeholder(TCPFlow)
46
47 assert (
48 Playbook(tcp.TCPLayer(tctx))
49 << tcp.TcpStartHook(f)
50 >> reply()
51 << OpenConnection(tctx.server)
52 >> reply(None)
53 >> DataReceived(tctx.client, b"hello!")
54 << tcp.TcpMessageHook(f)
55 >> reply()
56 << SendData(tctx.server, b"hello!")
57 >> DataReceived(tctx.server, b"hi")
58 << tcp.TcpMessageHook(f)
59 >> reply()
60 << SendData(tctx.client, b"hi")
61 >> ConnectionClosed(tctx.server)
62 << CloseTcpConnection(tctx.client, half_close=True)
63 >> ConnectionClosed(tctx.client)
64 << CloseConnection(tctx.server)
65 << tcp.TcpEndHook(f)
66 >> reply()
67 >> ConnectionClosed(tctx.client)
68 << None
69 )
70 assert len(f().messages) == 2
71
72
73def test_receive_data_before_server_connected(tctx):

Callers

nothing calls this directly

Calls 10

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