MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_regular_http3

Function test_regular_http3

test/mitmproxy/addons/test_proxyserver.py:848–888  ·  view source on GitHub ↗
(caplog_async, monkeypatch)

Source from the content-addressed store, hash-verified

846
847@pytest.mark.skip("HTTP/3 for regular mode is not fully supported yet")
848async def test_regular_http3(caplog_async, monkeypatch) -> None:
849 caplog_async.set_level("INFO")
850 ps = Proxyserver()
851 nl = NextLayer()
852 ta = TlsConfig()
853 with taddons.context(ps, nl, ta) as tctx:
854 ta.configure(["confdir"])
855 async with quic_server(H3EchoServer, alpn=["h3"]) as server_addr:
856 orig_open_connection = mitmproxy_rs.udp.open_udp_connection
857
858 async def open_connection_path(
859 host: str, port: int, *args, **kwargs
860 ) -> mitmproxy_rs.Stream:
861 if host == "example.mitmproxy.org" and port == 443:
862 host = server_addr[0]
863 port = server_addr[1]
864 return orig_open_connection(host, port, *args, **kwargs)
865
866 monkeypatch.setattr(
867 mitmproxy_rs.udp, "open_udp_connection", open_connection_path
868 )
869 mode = f"http3@127.0.0.1:0"
870 tctx.configure(
871 ta,
872 ssl_verify_upstream_trusted_ca=tlsdata.path(
873 "../net/data/verificationcerts/trusted-root.crt"
874 ),
875 )
876 tctx.configure(ps, mode=[mode])
877 assert await ps.setup_servers()
878 ps.running()
879 await caplog_async.await_log(f"HTTP3 proxy listening")
880 assert ps.servers
881 addr = ps.servers[mode].listen_addrs[0]
882 async with quic_connect(H3Client, alpn=["h3"], address=addr) as client:
883 await _test_echo(client=client, strict=True)
884 assert len(ps.connections) == 1
885
886 tctx.configure(ps, server=False)
887 await caplog_async.await_log("stopped")
888 await _wait_for_connection_closes(ps)

Callers

nothing calls this directly

Calls 15

configureMethod · 0.95
setup_serversMethod · 0.95
runningMethod · 0.95
ProxyserverClass · 0.90
NextLayerClass · 0.90
TlsConfigClass · 0.90
quic_serverFunction · 0.85
quic_connectFunction · 0.85
set_levelMethod · 0.80
contextMethod · 0.80
await_logMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…