def test_fatal_error(self, capsys): opts = options.Options() pconf = config.ProxyConfig(opts) channel = mock.Mock() def ask(_, x): raise RuntimeError channel.ask = ask c = ConnectionHandler(mock.MagicMock(), ("127.0.0.1", 8080), pconf, channel) c.handle() _, err = capsys.readouterr() assert "mitmproxy has crashed" in err
def test_fatal_error(self, capsys): config = mock.Mock() root_layer = mock.Mock() root_layer.side_effect = RuntimeError config.options.mode.return_value = root_layer channel = mock.Mock() def ask(_, x): return x channel.ask = ask c = ConnectionHandler(mock.MagicMock(), ("127.0.0.1", 8080), config, channel) c.handle() _, err = capsys.readouterr() assert "mitmproxy has crashed" in err
def handle_client_connection(self, conn, client_address): config = self.config if get_proxy_context().mode == ProxyMode.REVERSE: upstream = self._get_upstream() if upstream: options = copy(self.config.options) options.mode = f'reverse:{upstream}' config = ProxyConfig(options) handler = ConnectionHandler( conn, client_address, config, self.channel, ) handler.handle()
def test_fatal_error(self, capsys): opts = options.Options() pconf = config.ProxyConfig(opts) channel = mock.Mock() def ask(_, x): raise RuntimeError channel.ask = ask c = ConnectionHandler( mock.MagicMock(), ("127.0.0.1", 8080), pconf, channel ) c.handle() _, err = capsys.readouterr() assert "mitmproxy has crashed" in err
def test_fatal_error(self, capsys): config = mock.Mock() root_layer = mock.Mock() root_layer.side_effect = RuntimeError config.options.mode.return_value = root_layer channel = mock.Mock() def ask(_, x): return x channel.ask = ask c = ConnectionHandler( mock.MagicMock(), ("127.0.0.1", 8080), config, channel ) c.handle() _, err = capsys.readouterr() assert "mitmproxy has crashed" in err
def test_fatal_error(self): config = mock.Mock() root_layer = mock.Mock() root_layer.side_effect = RuntimeError config.options.mode.return_value = root_layer channel = mock.Mock() def ask(_, x): return x channel.ask = ask c = ConnectionHandler(mock.MagicMock(), ("127.0.0.1", 8080), config, channel) with ttutils.capture_stderr(c.handle) as output: assert "mitmproxy has crashed" in output