MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_quic

Function test_quic

test/mitmproxy/proxy/layers/test_modes.py:197–222  ·  view source on GitHub ↗
(tctx: Context, keep_host_header: bool)

Source from the content-addressed store, hash-verified

195
196@pytest.mark.parametrize("keep_host_header", [True, False])
197def test_quic(tctx: Context, keep_host_header: bool):
198 with taddons.context():
199 tctx.options.keep_host_header = keep_host_header
200 tctx.server.sni = "other.example.com"
201 tctx.client.proxy_mode = ProxyMode.parse("reverse:quic://example.org:443")
202 client_hello = Placeholder(bytes)
203
204 def set_settings(data: quic.QuicTlsData):
205 data.settings = quic.QuicTlsSettings()
206
207 assert (
208 Playbook(modes.ReverseProxy(tctx))
209 << OpenConnection(tctx.server)
210 >> reply(None)
211 >> DataReceived(tctx.client, b"\x00")
212 << NextLayerHook(Placeholder(NextLayer))
213 >> reply_next_layer(layers.ServerQuicLayer)
214 << quic.QuicStartServerHook(Placeholder(quic.QuicTlsData))
215 >> reply(side_effect=set_settings)
216 << SendData(tctx.server, client_hello)
217 << RequestWakeup(Placeholder(float))
218 )
219 assert tctx.server.address == ("example.org", 443)
220 assert quic.quic_parse_client_hello_from_datagrams([client_hello()]).sni == (
221 "other.example.com" if keep_host_header else "example.org"
222 )
223
224
225def test_udp(tctx: Context):

Callers

nothing calls this directly

Calls 11

PlaceholderFunction · 0.90
PlaybookClass · 0.90
OpenConnectionClass · 0.90
replyClass · 0.90
DataReceivedClass · 0.90
NextLayerHookClass · 0.90
reply_next_layerFunction · 0.90
SendDataClass · 0.90
RequestWakeupClass · 0.90
contextMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…