Exemplo n.º 1
0
    def test_single_process_active_and_inactive(self):
        processes = copy.deepcopy(test_data.PROCESSES_1)

        process_iterator_factory = dummy_process_iterator.DummyProcessFactory(
            p_processes=processes, p_login_mapping=test_data.LOGIN_MAPPING)

        config = client_process_handler.ClientProcessHandlerConfigModel()
        process_handler = client_process_handler.ClientProcessHandler(
            p_config=config,
            p_process_iterator_factory=process_iterator_factory)
        session_context = object()
        process_iterator_factory.set_reference_time(
            p_reference_time=test_data.START_TIME_1 +
            datetime.timedelta(seconds=1))
        events = process_handler.scan_processes(
            p_session_context=session_context,
            p_server_group=login_mapping.DEFAULT_SERVER_GROUP,
            p_login_mapping=test_data.LOGIN_MAPPING,
            p_host_name=test_data.HOSTNAME_1,
            p_process_regex_map=test_data.PROCESS_REGEX_MAP_1,
            p_reference_time=datetime.datetime.now())

        self.check_list_has_n_elements(p_list=events, p_n=1)

        event = events[0]

        self.assertEqual(event.event_type,
                         admin_event.EVENT_TYPE_PROCESS_START)
        self.assertEqual(event.processhandler, process_handler.id)
        self.check_default_data(p_event=event)

        process_handler.handle_event_process_start(p_event=event)

        processes[0].end_time = test_data.END_TIME_1

        now = datetime.datetime.now()
        process_iterator_factory.set_reference_time(
            p_reference_time=test_data.END_TIME_1 +
            datetime.timedelta(seconds=1))
        events = process_handler.scan_processes(
            p_session_context=session_context,
            p_server_group=login_mapping.DEFAULT_SERVER_GROUP,
            p_login_mapping=test_data.LOGIN_MAPPING,
            p_host_name=test_data.HOSTNAME_1,
            p_process_regex_map=test_data.PROCESS_REGEX_MAP_1,
            p_reference_time=now)

        self.check_list_has_n_elements(p_list=events, p_n=1)

        event = events[0]

        self.assertEqual(event.event_type, admin_event.EVENT_TYPE_PROCESS_END)
        self.assertEqual(event.event_time, now)
        self.assertEqual(event.processhandler, process_handler.id)

        self.check_default_data(p_event=event)
Exemplo n.º 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)
Exemplo n.º 3
0
    def get_dummy_process_handler(p_reference_time=None,
                                  p_processes=test_data.PROCESSES_1):

        if p_reference_time is None:
            p_reference_time = test_data.START_TIME_1 + datetime.timedelta(
                seconds=1)

        process_iterator_factory = dummy_process_iterator.DummyProcessFactory(
            p_processes=p_processes, p_uid_map=test_data.UID_MAP)

        config = client_process_handler.ClientProcessHandlerConfigModel()
        process_handler = client_process_handler.ClientProcessHandler(
            p_config=config,
            p_process_iterator_factory=process_iterator_factory)
        process_iterator_factory.set_reference_time(
            p_reference_time=p_reference_time)

        return process_handler
Exemplo n.º 4
0
    def test_single_process_before(self):
        process_iterator_factory = dummy_process_iterator.DummyProcessFactory(
            p_processes=test_data.PROCESSES_1, p_uid_map=test_data.UID_MAP)

        config = client_process_handler.ClientProcessHandlerConfigModel()
        process_handler = client_process_handler.ClientProcessHandler(
            p_config=config,
            p_process_iterator_factory=process_iterator_factory)
        process_iterator_factory.set_reference_time(
            p_reference_time=test_data.START_TIME_1 +
            datetime.timedelta(seconds=-1))
        events = process_handler.scan_processes(
            p_uid_map=test_data.UID_MAP,
            p_host_name=test_data.HOSTNAME_1,
            p_process_regex_map=test_data.PROCESS_REGEX_MAP_1,
            p_reference_time=datetime.datetime.now())

        self.check_list_has_n_elements(p_list=events, p_n=0)
Exemplo n.º 5
0
    def test_single_process_before(self):
        process_iterator_factory = dummy_process_iterator.DummyProcessFactory(
            p_processes=test_data.PROCESSES_1,
            p_login_mapping=test_data.LOGIN_MAPPING)

        config = client_process_handler.ClientProcessHandlerConfigModel()
        process_handler = client_process_handler.ClientProcessHandler(
            p_config=config,
            p_process_iterator_factory=process_iterator_factory)
        session_context = object()
        process_iterator_factory.set_reference_time(
            p_reference_time=test_data.START_TIME_1 +
            datetime.timedelta(seconds=-1))
        events = process_handler.scan_processes(
            p_session_context=session_context,
            p_server_group=login_mapping.DEFAULT_SERVER_GROUP,
            p_login_mapping=test_data.LOGIN_MAPPING,
            p_host_name=test_data.HOSTNAME_1,
            p_process_regex_map=test_data.PROCESS_REGEX_MAP_1,
            p_reference_time=datetime.datetime.now())

        self.check_list_has_n_elements(p_list=events, p_n=0)
Exemplo n.º 6
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)