(tctx, strategy)
| 1011 | |
| 1012 | @pytest.mark.parametrize("strategy", ["eager", "lazy"]) |
| 1013 | def test_proxy_chain(tctx, strategy): |
| 1014 | server = Placeholder(Server) |
| 1015 | tctx.options.connection_strategy = strategy |
| 1016 | playbook = Playbook(http.HttpLayer(tctx, HTTPMode.regular), hooks=False) |
| 1017 | |
| 1018 | playbook >> DataReceived( |
| 1019 | tctx.client, b"CONNECT proxy:8080 HTTP/1.1\r\nHost: proxy:8080\r\n\r\n" |
| 1020 | ) |
| 1021 | if strategy == "eager": |
| 1022 | playbook << OpenConnection(server) |
| 1023 | playbook >> reply(None) |
| 1024 | playbook << SendData(tctx.client, b"HTTP/1.1 200 Connection established\r\n\r\n") |
| 1025 | |
| 1026 | playbook >> DataReceived( |
| 1027 | tctx.client, b"CONNECT second-proxy:8080 HTTP/1.1\r\nHost: proxy:8080\r\n\r\n" |
| 1028 | ) |
| 1029 | playbook << layer.NextLayerHook(Placeholder()) |
| 1030 | playbook >> reply_next_layer(lambda ctx: http.HttpLayer(ctx, HTTPMode.transparent)) |
| 1031 | playbook << SendData( |
| 1032 | tctx.client, |
| 1033 | BytesMatching( |
| 1034 | b"mitmproxy received an HTTP CONNECT request even though it is not running in regular/upstream mode." |
| 1035 | ), |
| 1036 | ) |
| 1037 | playbook << CloseConnection(tctx.client) |
| 1038 | |
| 1039 | assert playbook |
| 1040 | |
| 1041 | |
| 1042 | def test_no_headers(tctx): |
nothing calls this directly
no test coverage detected
searching dependent graphs…