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

Method test_client_only

test/mitmproxy/proxy/layers/test_tls.py:537–569  ·  view source on GitHub ↗

Test TLS with client only

(self, tctx: context.Context)

Source from the content-addressed store, hash-verified

535
536class TestClientTLS:
537 def test_client_only(self, tctx: context.Context):
538 """Test TLS with client only"""
539 playbook, client_layer, tssl_client = make_client_tls_layer(tctx)
540 client_layer.debug = " "
541 assert not tctx.client.tls_established
542
543 # Send ClientHello, receive ServerHello
544 data = tutils.Placeholder(bytes)
545 assert (
546 playbook
547 >> events.DataReceived(tctx.client, tssl_client.bio_read())
548 << tls.TlsClienthelloHook(tutils.Placeholder())
549 >> tutils.reply()
550 << tls.TlsStartClientHook(tutils.Placeholder())
551 >> reply_tls_start_client()
552 << commands.SendData(tctx.client, data)
553 )
554 tssl_client.bio_write(data())
555 tssl_client.do_handshake()
556 # Finish Handshake
557 finish_handshake(playbook, tctx.client, tssl_client)
558
559 assert tssl_client.obj.getpeercert(True)
560 assert tctx.client.tls_established
561
562 # Echo
563 _test_echo(playbook, tssl_client, tctx.client)
564 other_server = Server(address=None)
565 assert (
566 playbook
567 >> events.DataReceived(other_server, b"Plaintext")
568 << commands.SendData(other_server, b"plaintext")
569 )
570
571 @pytest.mark.parametrize("server_state", ["open", "closed"])
572 def test_server_required(self, tctx, server_state):

Callers

nothing calls this directly

Calls 9

ServerClass · 0.90
dataFunction · 0.85
bio_readMethod · 0.80
bio_writeMethod · 0.80
make_client_tls_layerFunction · 0.70
reply_tls_start_clientFunction · 0.70
finish_handshakeFunction · 0.70
_test_echoFunction · 0.70
do_handshakeMethod · 0.45

Tested by

no test coverage detected