Пример #1
0
def main():
    """
    Setup consumer
    """
    config = loader.load_config()
    if config.version:
        show_version()
    if config.show_rules:
        show_rules()
    if not config.configfile and not (hasattr(config, "status") or hasattr(config, "stop")):
        show_configfile_warning()

    # Check if we have permissions to open the log file.
    check_write_permissions(config.logfile)
    start_proxy(config)
Пример #2
0
def main():
    """
    Setup consumer
    """
    config = loader.load_config()
    if config.version:
        show_version()
    if config.show_rules:
        show_rules()
    if not config.configfile and not (hasattr(config, "status") or hasattr(config, "stop")):
        show_configfile_warning()

    # Check if we have permissions to open the log file.
    check_write_permissions(config.logfile)
    start_proxy(config)
Пример #3
0
    def test_cli_overwrite(self):
        # Fake commandline arguments
        # Argparse returns a namespace, not a dictionary
        fake_args = argparse.Namespace()
        fake_args.host = "myhost"

        with patch('argparse.ArgumentParser.parse_args') as parse_args_mock:
            parse_args_mock.return_value = fake_args

            # Fake default config
            with patch('protector.config.default_config.DEFAULT_CONFIG') as default_config_mock:
                default_config_mock.return_value = {"host": "yourhost"}
                config = loader.load_config()

        # Check if the default setting got overwritten
        self.assertEqual(config.host, "myhost")
Пример #4
0
    def test_cli_overwrite(self):
        # Fake commandline arguments
        # Argparse returns a namespace, not a dictionary
        fake_args = argparse.Namespace()
        fake_args.host = "myhost"

        with patch('argparse.ArgumentParser.parse_args') as parse_args_mock:
            parse_args_mock.return_value = fake_args

            # Fake default config
            with patch('protector.config.default_config.DEFAULT_CONFIG'
                       ) as default_config_mock:
                default_config_mock.return_value = {"host": "yourhost"}
                config = loader.load_config()

        # Check if the default setting got overwritten
        self.assertEqual(config.host, "myhost")