def test_read_config_file(self):
        a_configuration = configuration.Configuration()

        rule_handler_section = rule_handler.RuleHandlerConfigModel()
        a_configuration.add_section(rule_handler_section)

        a_rule_set_section_handler = rule_handler.RuleSetSectionHandler()
        a_configuration.register_section_handler(p_section_handler=a_rule_set_section_handler)

        filename = os.path.join(os.path.dirname(__file__), "resources/ruleset_handler.test.config")
        a_configuration.read_config_file(p_filename=filename)

        ruleset_configs = a_rule_set_section_handler.rule_set_configs

        self.assertIsNotNone(ruleset_configs)

        self.assertEqual(len(ruleset_configs), 2)

        self.assertIn("user1", ruleset_configs)
        self.assertIn("user2", ruleset_configs)

        ruleset_user1 = ruleset_configs["user1"]
        self.assertEqual(len(ruleset_user1), 1)
        ruleset_user2 = ruleset_configs["user2"]
        self.assertEqual(len(ruleset_user2), 4)

        self.assertIsNotNone(a_configuration)
Пример #2
0
    def load_configuration(self, p_configuration):

        app_control_section = app_control.AppControlConfigModel()
        p_configuration.add_section(app_control_section)

        audio_handler_section = audio_handler.AudioHandlerConfigModel()
        p_configuration.add_section(audio_handler_section)

        popup_handler_section = popup_handler.PopupHandlerConfigModel()
        p_configuration.add_section(popup_handler_section)

        persistence_section = persistence.PersistenceConfigModel()
        p_configuration.add_section(persistence_section)

        rule_handler_section = rule_handler.RuleHandlerConfigModel()
        p_configuration.add_section(rule_handler_section)

        self._rule_set_section_handler = rule_handler.RuleSetSectionHandler()
        p_configuration.register_section_handler(
            p_section_handler=self._rule_set_section_handler)

        client_process_handler_section = client_process_handler.ClientProcessHandlerConfigModel(
        )
        p_configuration.add_section(client_process_handler_section)

        client_device_handler_section = client_device_handler.ClientDeviceHandlerConfigModel(
        )
        p_configuration.add_section(client_device_handler_section)

        self._client_device_section_handler = client_device_handler.ClientDeviceSectionHandler(
        )
        p_configuration.register_section_handler(
            p_section_handler=self._client_device_section_handler)

        status_server_section = status_server.StatusServerConfigModel()
        p_configuration.add_section(status_server_section)

        master_connector_section = master_connector.MasterConnectorConfigModel(
        )
        p_configuration.add_section(master_connector_section)

        self.app_config = AppConfigModel()
        p_configuration.add_section(self.app_config)

        return super(App,
                     self).load_configuration(p_configuration=p_configuration)
Пример #3
0
    def prepare_configuration(self, p_configuration):

        app_control_section = app_control.AppControlConfigModel()
        p_configuration.add_section(app_control_section)

        audio_handler_section = audio_handler.AudioHandlerConfigModel()
        audio_handler_section.spool_dir = os.path.join("/var/spool",
                                                       constants.DIR_NAME)
        p_configuration.add_section(audio_handler_section)

        popup_handler_section = popup_handler.PopupHandlerConfigModel()
        p_configuration.add_section(popup_handler_section)

        persistence_section = persistence.PersistenceConfigModel()
        persistence_section.sqlite_dir = os.path.join("/var/spool",
                                                      constants.DIR_NAME)
        p_configuration.add_section(persistence_section)

        rule_handler_section = rule_handler.RuleHandlerConfigModel()
        p_configuration.add_section(rule_handler_section)

        self._rule_set_section_handler = rule_handler.RuleSetSectionHandler()
        p_configuration.register_section_handler(
            p_section_handler=self._rule_set_section_handler)

        client_process_handler_section = client_process_handler.ClientProcessHandlerConfigModel(
        )
        p_configuration.add_section(client_process_handler_section)

        client_device_handler_section = client_device_handler.ClientDeviceHandlerConfigModel(
        )
        p_configuration.add_section(client_device_handler_section)

        self._client_device_section_handler = client_device_handler.ClientDeviceSectionHandler(
        )
        p_configuration.register_section_handler(
            p_section_handler=self._client_device_section_handler)

        status_server_section = status_server.StatusServerConfigModel()
        p_configuration.add_section(status_server_section)

        master_connector_section = master_connector.MasterConnectorConfigModel(
        )
        p_configuration.add_section(master_connector_section)

        prometheus_client_section = prometheus.PrometheusClientConfigModel()
        p_configuration.add_section(prometheus_client_section)

        self.app_config = AppConfigModel()
        p_configuration.add_section(self.app_config)

        user_handler_section = unix_user_handler.BaseUserHandlerConfigModel()
        p_configuration.add_section(user_handler_section)

        self._login_mapping_section_handler = login_mapping.LoginMappingSectionHandler(
        )
        p_configuration.register_section_handler(
            p_section_handler=self._login_mapping_section_handler)

        return super(
            App, self).prepare_configuration(p_configuration=p_configuration)