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

Method test_next_layer

test/mitmproxy/addons/test_next_layer.py:406–435  ·  view source on GitHub ↗
(self, monkeypatch, caplog)

Source from the content-addressed store, hash-verified

404 assert nl._next_layer(m.context, http_get, b"").flow is not None
405
406 def test_next_layer(self, monkeypatch, caplog):
407 caplog.set_level(logging.DEBUG)
408 nl = NextLayer()
409
410 with taddons.context(nl) as tctx:
411 m = MagicMock()
412 m.context = Context(
413 Client(peername=("192.168.0.42", 51234), sockname=("0.0.0.0", 8080)),
414 tctx.options,
415 )
416 m.context.layers = [modes.TransparentProxy(m.context)]
417 m.context.server.address = ("example.com", 42)
418 tctx.configure(nl, ignore_hosts=["example.com"])
419
420 m.layer = preexisting = object()
421 nl.next_layer(m)
422 assert m.layer is preexisting
423
424 m.layer = None
425 monkeypatch.setattr(m, "data_client", lambda: http_get)
426 nl.next_layer(m)
427 assert m.layer
428
429 m.layer = None
430 monkeypatch.setattr(
431 m, "data_client", lambda: client_hello_with_extensions[:-5]
432 )
433 nl.next_layer(m)
434 assert not m.layer
435 assert "Deferring layer decision" in caplog.text
436
437
438@dataclass

Callers

nothing calls this directly

Calls 7

next_layerMethod · 0.95
NextLayerClass · 0.90
ContextClass · 0.90
ClientClass · 0.90
set_levelMethod · 0.80
contextMethod · 0.80
configureMethod · 0.45

Tested by

no test coverage detected