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)
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
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)
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)