コード例 #1
0
ファイル: test_proxy.py プロジェクト: tran-tien-dat/mitmproxy
    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
コード例 #2
0
ファイル: test_proxy.py プロジェクト: whackashoe/mitmproxy
    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
コード例 #3
0
ファイル: server.py プロジェクト: vvfesik/vgs-satellite
    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()
コード例 #4
0
ファイル: test_proxy.py プロジェクト: mhils/mitmproxy
    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
コード例 #5
0
ファイル: test_proxy.py プロジェクト: s4chin/mitmproxy
    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
コード例 #6
0
    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