def test_upstream_proxy(self): MitmProxy( 'somehost', 12345, { 'request_storage_base_dir': '/some/dir', 'proxy': { 'http': 'http://proxyserver:8080', # We pick https when both are specified and the same 'https': 'https://proxyserver:8080' } }) self.mock_options.return_value.update.assert_has_calls([ call(ssl_insecure=True, upstream_cert=False, stream_websockets=True, mode='upstream:https://proxyserver:8080'), call() ])
def test_creates_master(self): proxy = MitmProxy('somehost', 12345, { 'request_storage_base_dir': '/some/dir', }) self.assertEqual(self.mock_master.return_value, proxy._master) self.mock_options.assert_called_once_with(confdir='~/.mitmproxy', listen_host='somehost', listen_port=12345) self.mock_master.assert_called_once_with( self.mock_options.return_value) self.assertEqual(self.mock_proxy_server.return_value, self.mock_master.return_value.server) self.mock_proxy_config.assert_called_once_with( self.mock_options.return_value) self.mock_proxy_server.assert_called_once_with( self.mock_proxy_config.return_value) self.mock_master.return_value.addons.add.assert_has_calls([ call(), call(self.mock_logger.return_value), call(self.mock_handler.return_value) ]) self.mock_addons.default_addons.assert_called_once_with() self.mock_handler.assert_called_once_with(proxy)