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

Function test_tunnel_default_impls

test/mitmproxy/proxy/test_tunnel.py:143–176  ·  view source on GitHub ↗

Some tunnels don't need certain features, so the default behaviour should be to be transparent.

(tctx: Context)

Source from the content-addressed store, hash-verified

141
142
143def test_tunnel_default_impls(tctx: Context):
144 """
145 Some tunnels don't need certain features, so the default behaviour
146 should be to be transparent.
147 """
148 server = Server(address=None)
149 server.state = ConnectionState.OPEN
150 tl = tunnel.TunnelLayer(tctx, server, tctx.server)
151 tl.child_layer = TChildLayer(tctx)
152 playbook = Playbook(tl, logs=True)
153 assert (
154 playbook
155 << Log("Got start. Server state: OPEN")
156 >> DataReceived(server, b"server-hello")
157 << SendData(server, b"server-hello-reply")
158 )
159 assert tl.tunnel_state is tunnel.TunnelState.OPEN
160 assert (
161 playbook
162 >> ConnectionClosed(server)
163 << Log("Got server close.")
164 << CloseConnection(server)
165 )
166 assert tl.tunnel_state is tunnel.TunnelState.CLOSED
167
168 assert (
169 playbook
170 >> DataReceived(tctx.client, b"open")
171 << OpenConnection(server)
172 >> reply(None)
173 << Log("Opened: err=None. Server state: OPEN")
174 >> DataReceived(server, b"half-close")
175 << CloseTcpConnection(server, half_close=True)
176 )
177
178
179def test_tunnel_openconnection_error(tctx: Context):

Callers

nothing calls this directly

Calls 11

ServerClass · 0.90
PlaybookClass · 0.90
LogClass · 0.90
DataReceivedClass · 0.90
SendDataClass · 0.90
ConnectionClosedClass · 0.90
CloseConnectionClass · 0.90
OpenConnectionClass · 0.90
replyClass · 0.90
CloseTcpConnectionClass · 0.90
TChildLayerClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…