diff --git a/deps/wazuh_testing/wazuh_testing/fim.py b/deps/wazuh_testing/wazuh_testing/fim.py index c34cfcbf1f..c296d221cd 100644 --- a/deps/wazuh_testing/wazuh_testing/fim.py +++ b/deps/wazuh_testing/wazuh_testing/fim.py @@ -882,7 +882,7 @@ def modify_file_inode(path, name): path_to_file = os.path.join(path, name) shutil.copy2(path_to_file, os.path.join(tempfile.gettempdir(), inode_file)) - os.replace(os.path.join(tempfile.gettempdir(), inode_file), path_to_file) + shutil.move(os.path.join(tempfile.gettempdir(), inode_file), path_to_file) def modify_file_win_attributes(path, name): diff --git a/tests/integration/test_fim/test_files/test_basic_usage/data/wazuh_conf_check_realtime.yaml b/tests/integration/test_fim/test_files/test_basic_usage/data/wazuh_conf_check_realtime.yaml index ee742df6cc..082f331331 100644 --- a/tests/integration/test_fim/test_files/test_basic_usage/data/wazuh_conf_check_realtime.yaml +++ b/tests/integration/test_fim/test_files/test_basic_usage/data/wazuh_conf_check_realtime.yaml @@ -2,7 +2,7 @@ - tags: - ossec_conf apply_to_modules: - - MODULE_NAME + - test_basic_usage_realtime_unsupported sections: - section: syscheck elements: @@ -13,3 +13,17 @@ attributes: - check_all: 'yes' - realtime: 'yes' + - section: sca + elements: + - enabled: + value: 'no' + - section: rootcheck + elements: + - disabled: + value: 'yes' + - section: wodle + attributes: + - name: 'syscollector' + elements: + - disabled: + value: 'yes' diff --git a/tests/integration/test_fim/test_files/test_basic_usage/test_basic_usage_realtime_unsupported.py b/tests/integration/test_fim/test_files/test_basic_usage/test_basic_usage_realtime_unsupported.py index d3c278aa34..1b2094cad2 100644 --- a/tests/integration/test_fim/test_files/test_basic_usage/test_basic_usage_realtime_unsupported.py +++ b/tests/integration/test_fim/test_files/test_basic_usage/test_basic_usage_realtime_unsupported.py @@ -52,20 +52,17 @@ import os import pytest -import re -from wazuh_testing import global_parameters -from wazuh_testing.fim import generate_params, regular_file_cud, LOG_FILE_PATH, callback_num_inotify_watches, \ - detect_initial_scan, callback_ignore_realtime_flag, CHECK_ALL, REQUIRED_ATTRIBUTES -from wazuh_testing.tools import PREFIX -from wazuh_testing.tools.configuration import load_wazuh_configurations, check_apply_test -# Marks +from wazuh_testing.fim import generate_params, regular_file_cud, detect_initial_scan, callback_ignore_realtime_flag +from wazuh_testing.tools import PREFIX +from wazuh_testing.tools.configuration import load_wazuh_configurations +# Marks pytestmark = [pytest.mark.darwin, pytest.mark.sunos5, pytest.mark.tier(level=0)] -# variables +# Variables realtime_flag_timeout = 60 directory_str = os.path.join(PREFIX, 'dir') test_data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data') @@ -73,27 +70,22 @@ test_file = 'testfile.txt' test_directories = [directory_str] -# configurations - -conf_params = {'TEST_DIRECTORIES': directory_str, 'MODULE_NAME': __name__} +# Configurations +conf_params = {'TEST_DIRECTORIES': directory_str} parameters, metadata = generate_params(extra_params=conf_params, modes=['scheduled']) configurations = load_wazuh_configurations(configurations_path, __name__, params=parameters, metadata=metadata) local_internal_options = {'syscheck.debug': '2', 'monitord.rotate_log': '0'} daemons_handler_configuration = {'daemons': ['wazuh-syscheckd']} -# fixtures - - +# Fixtures @pytest.fixture(scope='module', params=configurations) def get_configuration(request): """Get configurations from the module.""" return request.param -# tests - - +# Tests def test_realtime_unsupported(get_configuration, configure_environment, file_monitoring, configure_local_internal_options_module, daemons_handler): ''' @@ -144,5 +136,5 @@ def test_realtime_unsupported(get_configuration, configure_environment, file_mon detect_initial_scan(log_monitor) regular_file_cud(directory_str, log_monitor, file_list=[test_file], time_travel=True, triggers_event=True, - event_mode="scheduled") + event_mode="scheduled", min_timeout=15) diff --git a/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_change_target.py b/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_change_target.py index 8080159a3b..8051dc6134 100644 --- a/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_change_target.py +++ b/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_change_target.py @@ -192,19 +192,19 @@ def modify_and_check_events(f1, f2, text): fim.create_file(fim.REGULAR, main_folder, file1, content='') fim.create_file(fim.REGULAR, aux_folder, file1, content='') fim.check_time_travel(scheduled, monitor=wazuh_log_monitor) - add = wazuh_log_monitor.start(timeout=3, callback=fim.callback_detect_event, + add = wazuh_log_monitor.start(timeout=10, callback=fim.callback_detect_event, error_message='Did not receive expected "Sending FIM event: ..." event' ).result() assert 'added' in add['data']['type'] and file1 in add['data']['path'], \ f"'added' event not matching for {file1}" with pytest.raises(TimeoutError): - event = wazuh_log_monitor.start(timeout=3, callback=fim.callback_detect_event) + event = wazuh_log_monitor.start(timeout=10, callback=fim.callback_detect_event) logger.error(f'Unexpected event {event.result()}') raise AttributeError(f'Unexpected event {event.result()}') else: fim.create_file(fim.REGULAR, aux_folder, file1, content='') with pytest.raises(TimeoutError): - event = wazuh_log_monitor.start(timeout=3, callback=fim.callback_detect_event) + event = wazuh_log_monitor.start(timeout=10, callback=fim.callback_detect_event) logger.error(f'Unexpected event {event.result()}') raise AttributeError(f'Unexpected event {event.result()}') diff --git a/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_delete_symlink.py b/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_delete_symlink.py index e16239a787..a6d5c9adc3 100644 --- a/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_delete_symlink.py +++ b/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_delete_symlink.py @@ -171,7 +171,7 @@ def test_symbolic_delete_symlink(tags_to_apply, main_folder, aux_folder, get_con if tags_to_apply == {'monitored_dir'}: fim.create_file(fim.REGULAR, main_folder, file1, content='') fim.check_time_travel(scheduled, monitor=wazuh_log_monitor) - wazuh_log_monitor.start(timeout=3, callback=fim.callback_detect_event, + wazuh_log_monitor.start(timeout=10, callback=fim.callback_detect_event, error_message='Did not receive expected "Sending FIM event: ..." event') # Remove symlink and don't expect events @@ -181,7 +181,7 @@ def test_symbolic_delete_symlink(tags_to_apply, main_folder, aux_folder, get_con fim.modify_file_content(main_folder, file1, new_content='Sample modification') fim.check_time_travel(scheduled, monitor=wazuh_log_monitor) with pytest.raises(TimeoutError): - event = wazuh_log_monitor.start(timeout=3, callback=fim.callback_detect_event) + event = wazuh_log_monitor.start(timeout=10, callback=fim.callback_detect_event) logger.error(f'Unexpected event {event.result()}') raise AttributeError(f'Unexpected event {event.result()}') @@ -193,6 +193,6 @@ def test_symbolic_delete_symlink(tags_to_apply, main_folder, aux_folder, get_con fim.modify_file_content(main_folder, file1, new_content='Sample modification 2') fim.check_time_travel(scheduled, monitor=wazuh_log_monitor) - modify = wazuh_log_monitor.start(timeout=3, callback=fim.callback_detect_event).result() + modify = wazuh_log_monitor.start(timeout=10, callback=fim.callback_detect_event).result() assert 'modified' in modify['data']['type'] and file1 in modify['data']['path'], \ f"'modified' event not matching for {file1}" diff --git a/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_monitor_symlink.py b/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_monitor_symlink.py index e2b55a0bde..c92414c2b6 100644 --- a/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_monitor_symlink.py +++ b/tests/integration/test_fim/test_files/test_follow_symbolic_link/test_monitor_symlink.py @@ -163,14 +163,14 @@ def test_symbolic_monitor_symlink(tags_to_apply, main_folder, get_configuration, if tags_to_apply == {'monitored_dir'}: fim.create_file(fim.REGULAR, main_folder, file1, content='') fim.check_time_travel(scheduled, monitor=wazuh_log_monitor) - add = wazuh_log_monitor.start(timeout=3, callback=fim.callback_detect_event).result() + add = wazuh_log_monitor.start(timeout=10, callback=fim.callback_detect_event).result() assert 'added' in add['data']['type'] and file1 in add['data']['path'], \ "'added' event not matching" # Modify the linked file and expect an event fim.modify_file_content(main_folder, file1, 'Sample modification') fim.check_time_travel(scheduled, monitor=wazuh_log_monitor) - modify = wazuh_log_monitor.start(timeout=3, callback=fim.callback_detect_event, + modify = wazuh_log_monitor.start(timeout=10, callback=fim.callback_detect_event, error_message='Did not receive expected ' '"Sending FIM event: ..." event').result() assert 'modified' in modify['data']['type'] and file1 in modify['data']['path'], \ @@ -179,7 +179,7 @@ def test_symbolic_monitor_symlink(tags_to_apply, main_folder, get_configuration, # Delete the linked file and expect an event delete_f(main_folder, file1) fim.check_time_travel(scheduled, monitor=wazuh_log_monitor) - delete = wazuh_log_monitor.start(timeout=3, callback=fim.callback_detect_event, + delete = wazuh_log_monitor.start(timeout=10, callback=fim.callback_detect_event, error_message='Did not receive expected ' '"Sending FIM event: ..." event').result() assert 'deleted' in delete['data']['type'] and file1 in delete['data']['path'], \