MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_next_layer

Function test_next_layer

test/mitmproxy/addons/test_next_layer.py:863–897  ·  view source on GitHub ↗
(
    test_conf: TConf,
)

Source from the content-addressed store, hash-verified

861 ],
862)
863def test_next_layer(
864 test_conf: TConf,
865):
866 nl = NextLayer()
867 with taddons.context(nl) as tctx:
868 tctx.configure(
869 nl,
870 ignore_hosts=test_conf.ignore_hosts,
871 tcp_hosts=test_conf.tcp_hosts,
872 udp_hosts=test_conf.udp_hosts,
873 )
874
875 ctx = Context(
876 Client(
877 peername=("192.168.0.42", 51234),
878 sockname=("0.0.0.0", 8080),
879 alpn=test_conf.alpn,
880 ),
881 tctx.options,
882 )
883 ctx.server.address = test_conf.server_address
884 ctx.client.transport_protocol = test_conf.transport_protocol
885 ctx.client.tls_version = test_conf.tls_version
886 ctx.client.proxy_mode = ProxyMode.parse(test_conf.proxy_mode)
887 ctx.layers = [x(ctx) for x in test_conf.before]
888 nl._next_layer(
889 ctx,
890 data_client=test_conf.data_client,
891 data_server=test_conf.data_server,
892 )
893 assert stack_match(ctx, test_conf.after), f"Unexpected stack: {ctx.layers}"
894
895 last_layer = ctx.layers[-1]
896 if isinstance(last_layer, (UDPLayer, TCPLayer)):
897 assert bool(last_layer.flow) ^ test_conf.ignore_conn
898
899
900def test_starts_like_quic():

Callers

nothing calls this directly

Calls 9

_next_layerMethod · 0.95
NextLayerClass · 0.90
ContextClass · 0.90
ClientClass · 0.90
stack_matchFunction · 0.90
xFunction · 0.85
contextMethod · 0.80
configureMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…