MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_tunnel_handshake_start

Function test_tunnel_handshake_start

test/mitmproxy/proxy/test_tunnel.py:66–93  ·  view source on GitHub ↗
(tctx: Context, success)

Source from the content-addressed store, hash-verified

64
65@pytest.mark.parametrize("success", ["success", "fail"])
66def test_tunnel_handshake_start(tctx: Context, success):
67 server = Server(address=("proxy", 1234))
68 server.state = ConnectionState.OPEN
69
70 tl = TTunnelLayer(tctx, server, tctx.server)
71 tl.child_layer = TChildLayer(tctx)
72 assert repr(tl)
73
74 playbook = Playbook(tl, logs=True)
75 (
76 playbook
77 << SendData(server, b"handshake-hello")
78 >> DataReceived(tctx.client, b"client-hello")
79 >> DataReceived(server, b"handshake-" + success.encode())
80 << SendData(server, b"handshake-" + success.encode())
81 )
82 if success == "success":
83 playbook << Log("Got start. Server state: OPEN")
84 else:
85 playbook << CloseConnection(server)
86 playbook << Log("Got start. Server state: CLOSED")
87
88 playbook << SendData(tctx.client, b"client-hello-reply")
89 if success == "success":
90 playbook >> DataReceived(server, b"tunneled-server-hello")
91 playbook << SendData(server, b"tunneled-server-hello-reply")
92
93 assert playbook
94
95
96@pytest.mark.parametrize("success", ["success", "fail"])

Callers

nothing calls this directly

Calls 9

ServerClass · 0.90
PlaybookClass · 0.90
SendDataClass · 0.90
DataReceivedClass · 0.90
LogClass · 0.90
CloseConnectionClass · 0.90
TTunnelLayerClass · 0.85
TChildLayerClass · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…