diff --git a/deps/wazuh_testing/wazuh_testing/logcollector.py b/deps/wazuh_testing/wazuh_testing/logcollector.py index 6e694e22cd..04c18245ac 100644 --- a/deps/wazuh_testing/wazuh_testing/logcollector.py +++ b/deps/wazuh_testing/wazuh_testing/logcollector.py @@ -17,10 +17,11 @@ GENERIC_CALLBACK_ERROR_ANALYZING_MACOS = "The expected analyzing macos log has not been produced" GENERIC_CALLBACK_ERROR_TARGET_SOCKET = "The expected target socket log has not been produced" GENERIC_CALLBACK_ERROR_TARGET_SOCKET_NOT_FOUND = "The expected target socket not found error has not been produced" -LOG_COLLECTOR_GLOBAL_TIMEOUT = 20 GENERIC_CALLBACK_ERROR_READING_FILE = "The expected invalid content error log has not been produced" GENERIC_CALLBACK_ERROR = 'The expected error output has not been produced' +LOG_COLLECTOR_GLOBAL_TIMEOUT = 30 + DEFAULT_AUTHD_REMOTED_SIMULATOR_CONFIGURATION = { 'ip_address': 'localhost', 'client_keys': os.path.join(WAZUH_PATH, 'etc', 'client.keys'), @@ -690,6 +691,37 @@ def callback_invalid_state_interval(interval): return monitoring.make_callback(pattern=msg, prefix=prefix, escape=True) +def callback_logcollector_started(): + """Check if logcollector started.""" + return monitoring.make_callback(pattern='Started', prefix=prefix) + + +def callback_log_bad_predicate(): + """Check for the macOS ULS bad predicate message.""" + return monitoring.make_callback(pattern="Execution error 'log:", prefix=prefix) + + +def callback_macos_uls_log(expected_message): + """Callback function to wait for a macOS' ULS log, collected by logcollector.""" + return monitoring.make_callback(pattern=expected_message, prefix=prefix, escape=False) + + +def callback_logcollector_log_stream_log(): + """Check for logcollector's macOS ULS module start message.""" + return monitoring.make_callback(pattern='Monitoring macOS logs with:(.+?)log stream', + prefix=prefix, escape=False) + + +def callback_file_status_macos_key(line): + """Check for 'macos' key.""" + return monitoring.make_callback(pattern='"macos"', prefix='') + + +def callback_log_macos_stream_exit(): + """Check for the macOS ULS log stream exit message.""" + return monitoring.make_callback(pattern="macOS 'log stream' process exited, pid:", prefix=prefix) + + def wait_statistics_file(timeout=LOG_COLLECTOR_GLOBAL_TIMEOUT): """Wait until statistics file is available. @@ -766,6 +798,7 @@ def format_macos_message_pattern(process_name, message, type='log', subsystem=No return macos_message + def compose_macos_log_command(type='', level='', predicate='', is_sierra=False): """ This function replicates how the command 'log' will be called from the Wazuh agent given the query parameters @@ -775,7 +808,7 @@ def compose_macos_log_command(type='', level='', predicate='', is_sierra=False): level (str): < default | info | debug > Include events at, and below, the given level. predicate (str): Filter events using the given predicate. is_sierra (boolean): True if running on macOS Sierra, False otherwise. - + Returns: string: Full log command composed with the given parameters. """ diff --git a/tests/integration/test_logcollector/test_macos/conftest.py b/tests/integration/test_logcollector/test_macos/conftest.py new file mode 100644 index 0000000000..5fbe3dab77 --- /dev/null +++ b/tests/integration/test_logcollector/test_macos/conftest.py @@ -0,0 +1,33 @@ +# Copyright (C) 2015-2021, Wazuh Inc. +# Created by Wazuh, Inc. . +# This program is free software; you can redistribute it and/or modify it under the terms of GPLv2 + +import pytest + +from wazuh_testing.tools import LOGCOLLECTOR_FILE_STATUS_PATH, LOG_FILE_PATH +from wazuh_testing.tools.services import control_service +from wazuh_testing.tools.file import truncate_file +from os.path import exists +from os import remove + + +required_test_daemons = ['wazuh-agentd', 'wazuh-modulesd', 'wazuh-logcollector'] + + +@pytest.fixture(scope='function') +def restart_required_logcollector_test_daemons(): + """Wazuh logcollector daemons handler.""" + + for daemon in required_test_daemons: + control_service('stop', daemon=daemon) + + truncate_file(LOG_FILE_PATH) + remove(LOGCOLLECTOR_FILE_STATUS_PATH) if exists(LOGCOLLECTOR_FILE_STATUS_PATH) else None + + for daemon in required_test_daemons: + control_service('start', daemon=daemon) + + yield + + for daemon in required_test_daemons: + control_service('stop', daemon=daemon) diff --git a/tests/integration/test_logcollector/test_macos/test_macos_file_status_basic.py b/tests/integration/test_logcollector/test_macos/test_macos_file_status_basic.py index cccd04f381..a04c7067b0 100644 --- a/tests/integration/test_logcollector/test_macos/test_macos_file_status_basic.py +++ b/tests/integration/test_logcollector/test_macos/test_macos_file_status_basic.py @@ -2,59 +2,52 @@ # Created by Wazuh, Inc. . # This program is free software; you can redistribute it and/or modify it under the terms of GPLv2 -import os -import re import pytest import wazuh_testing.logcollector as logcollector from wazuh_testing.tools import LOGCOLLECTOR_FILE_STATUS_PATH, LOG_FILE_PATH, WAZUH_LOCAL_INTERNAL_OPTIONS -from wazuh_testing.tools.monitoring import FileMonitor, wait_file, make_callback from wazuh_testing.tools.configuration import load_wazuh_configurations -from wazuh_testing.logcollector import prefix as logcollector_prefix +from wazuh_testing.logcollector import LOG_COLLECTOR_GLOBAL_TIMEOUT +from wazuh_testing.tools.monitoring import FileMonitor, wait_file from wazuh_testing.tools.file import read_json, truncate_file -from wazuh_testing.tools.services import control_service +from os.path import dirname, join, realpath +from re import match + # Marks pytestmark = [pytest.mark.darwin, pytest.mark.tier(level=0)] # Configuration -test_data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data') -configurations_path = os.path.join(test_data_path, 'wazuh_macos_file_status_basic.yaml') +test_data_path = join(dirname(realpath(__file__)), 'data') +configurations_path = join(test_data_path, 'wazuh_macos_file_status_basic.yaml') parameters = [{'ONLY_FUTURE_EVENTS': 'yes'}, {'ONLY_FUTURE_EVENTS': 'no'}] metadata = [{'only-future-events': 'yes'}, {'only-future-events': 'no'}] # Configuration data configurations = load_wazuh_configurations(configurations_path, __name__, params=parameters, metadata=metadata) -configuration_ids = [f"{x['ONLY_FUTURE_EVENTS']}" for x in parameters] - -daemons_handler_configuration = {'daemons': ['wazuh-logcollector'], 'ignore_errors': False} +configuration_ids = [f"only_future_events_{x['ONLY_FUTURE_EVENTS']}" for x in parameters] # Max number of characters to be displayed in the log's debug message sample_log_length = 100 # Time in seconds to update the file_status.json file_status_update_time = 4 -local_internal_options = { 'logcollector.debug': 2, - 'logcollector.vcheck_files': file_status_update_time, - 'logcollector.sample_log_length': sample_log_length } - -macos_message = { 'command': 'logger', - 'message': 'Logger testing message - file status' } +local_internal_options = {'logcollector.debug': 2, + 'logcollector.vcheck_files': file_status_update_time, + 'logcollector.sample_log_length': sample_log_length} -# Maximum waiting time in seconds to find the logs on ossec.log -file_monitor_timeout = 30 +macos_message = {'command': 'logger', + 'message': 'Logger testing message - file status'} # Expected message to be used on the "callback_macos_uls_log" callback expected_message = logcollector.format_macos_message_pattern(macos_message['command'], macos_message['message']) -wazuh_log_monitor = None - # Fixtures @pytest.fixture(scope='module') -def startup_cleanup(): - """Truncate ossec.log and remove logcollector's file_status.json file.""" +def handle_files(): + """Truncate the 'local_internal_options.conf' file.""" truncate_file(WAZUH_LOCAL_INTERNAL_OPTIONS) @@ -64,82 +57,46 @@ def get_configuration(request): return request.param -@pytest.fixture(scope='module') -def restart_required_logcollector_daemons(): - """Wazuh logcollector daemons handler.""" - - required_logcollector_daemons = ['wazuh-logcollector'] - - for daemon in required_logcollector_daemons: - control_service('stop', daemon=daemon) - - truncate_file(LOG_FILE_PATH) - os.remove(LOGCOLLECTOR_FILE_STATUS_PATH) if os.path.exists(LOGCOLLECTOR_FILE_STATUS_PATH) else None - - for daemon in required_logcollector_daemons: - control_service('start', daemon=daemon) - - yield - - for daemon in required_logcollector_daemons: - control_service('stop', daemon=daemon) - - -def callback_macos_uls_log(): - """Callback function to wait for the macOS' ULS log collected by logcollector.""" - return make_callback(pattern=expected_message, prefix=logcollector_prefix, escape=False) - - -def callback_logcollector_log_stream_log(): - """Check for logcollector's macOS ULS module start message.""" - return make_callback(pattern='Monitoring macOS logs with:(.+?)log stream', prefix=logcollector_prefix, escape=False) - - -def callback_file_status_macos_key(line): - """Check for 'macos' key.""" - return make_callback(pattern='"macos"', prefix='') - - -def test_macos_file_status_basic(startup_cleanup, - configure_local_internal_options_module, +def test_macos_file_status_basic(handle_files, + configure_local_internal_options_module, get_configuration, configure_environment, - restart_required_logcollector_daemons): + restart_required_logcollector_test_daemons): """Checks if logcollector stores correctly "macos"-formatted localfile data. - This test uses logger tool and a custom log to generate an ULS event. The agent is connected to the authd simulator - and sends an event to trigger the file_status.json update. + This test uses logger tool and a custom log to generate an ULS event. When logcollector receives a valid log, then + the file_status.json is updated. Raises: TimeoutError: If the callbacks, that checks the expected logs, are not satisfied in the expected time. FileNotFoundError: If the file_status.json is not available in the expected time. """ + log_monitor = FileMonitor(LOG_FILE_PATH) - wazuh_log_monitor = FileMonitor(LOG_FILE_PATH) - - wazuh_log_monitor.start(timeout=file_monitor_timeout, - callback=logcollector.callback_monitoring_macos_logs, - error_message=logcollector.GENERIC_CALLBACK_ERROR_TARGET_SOCKET) + log_monitor.start(timeout=LOG_COLLECTOR_GLOBAL_TIMEOUT, + callback=logcollector.callback_monitoring_macos_logs, + error_message=logcollector.GENERIC_CALLBACK_ERROR_TARGET_SOCKET) # Watches the ossec.log to check when logcollector starts the macOS ULS module - wazuh_log_monitor.start(timeout=file_monitor_timeout, - callback=callback_logcollector_log_stream_log(), - error_message='Logcollector did not start') + log_monitor.start(timeout=LOG_COLLECTOR_GLOBAL_TIMEOUT, + callback=logcollector.callback_logcollector_log_stream_log(), + error_message='Logcollector did not start.') logcollector.generate_macos_logger_log(macos_message['message']) - wazuh_log_monitor.start(timeout=file_monitor_timeout, - callback=callback_macos_uls_log(), - error_message='MacOS ULS log was not found') + log_monitor.start(timeout=LOG_COLLECTOR_GLOBAL_TIMEOUT, + callback=logcollector.callback_macos_uls_log(expected_message), + error_message="MacOS ULS log was not found: '{}'.".format(expected_message)) # Waits for file_status.json to be created, with a timeout about the time needed to update the file - wait_file(LOGCOLLECTOR_FILE_STATUS_PATH, file_monitor_timeout) + wait_file(LOGCOLLECTOR_FILE_STATUS_PATH, LOG_COLLECTOR_GLOBAL_TIMEOUT) # Watches the file_status.json file for the "macos" key file_status_monitor = FileMonitor(LOGCOLLECTOR_FILE_STATUS_PATH) - file_status_monitor.start(timeout=file_monitor_timeout, - callback=callback_file_status_macos_key, - error_message="The 'macos' key could not be found on the file_status.json file") + + file_status_monitor.start(timeout=LOG_COLLECTOR_GLOBAL_TIMEOUT, + callback=logcollector.callback_file_status_macos_key, + error_message="The 'macos' key could not be found on the file_status.json file") file_status_json = read_json(LOGCOLLECTOR_FILE_STATUS_PATH) @@ -152,13 +109,10 @@ def test_macos_file_status_basic(startup_cleanup, assert file_status_json['macos']['timestamp'], "Error finding 'timestamp' key inside 'macos'" - assert re.match(r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}-\d{4}$', - file_status_json['macos']['timestamp']), \ - 'Error of timestamp format' + assert match(r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[-+]\d{4}$', file_status_json['macos']['timestamp']), \ + 'Error of timestamp format' assert file_status_json['macos']['settings'], "Error finding 'settings' key inside 'macos'" assert file_status_json['macos']['settings'] \ - == logcollector.compose_macos_log_command(conf_type, - conf_level, - conf_predicate) + == logcollector.compose_macos_log_command(conf_type, conf_level, conf_predicate) diff --git a/tests/integration/test_logcollector/test_macos/test_macos_file_status_predicate.py b/tests/integration/test_logcollector/test_macos/test_macos_file_status_predicate.py index 82b1ffbda3..dc984bf20f 100644 --- a/tests/integration/test_logcollector/test_macos/test_macos_file_status_predicate.py +++ b/tests/integration/test_logcollector/test_macos/test_macos_file_status_predicate.py @@ -2,54 +2,44 @@ # Created by Wazuh, Inc. . # This program is free software; you can redistribute it and/or modify it under the terms of GPLv2 -import os import pytest -import re -# from wazuh_testing.logcollector import DEFAULT_AUTHD_REMOTED_SIMULATOR_CONFIGURATION -from wazuh_testing.tools import LOGCOLLECTOR_FILE_STATUS_PATH, LOG_FILE_PATH, WAZUH_LOCAL_INTERNAL_OPTIONS -from wazuh_testing.tools.monitoring import FileMonitor, wait_file, make_callback +from wazuh_testing.logcollector import (LOG_COLLECTOR_GLOBAL_TIMEOUT, + callback_log_macos_stream_exit, + callback_log_bad_predicate) +from wazuh_testing.tools import LOGCOLLECTOR_FILE_STATUS_PATH, WAZUH_LOCAL_INTERNAL_OPTIONS from wazuh_testing.tools.configuration import load_wazuh_configurations -from wazuh_testing.logcollector import prefix as logcollector_prefix from wazuh_testing.tools.file import read_json, truncate_file +from wazuh_testing.tools.monitoring import wait_file +from os.path import dirname, join, realpath # Marks pytestmark = [pytest.mark.darwin, pytest.mark.tier(level=0)] # Configuration -test_data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data') -configurations_path = os.path.join(test_data_path, 'wazuh_macos_file_status_predicate.yaml') +test_data_path = join(dirname(realpath(__file__)), 'data') +configurations_path = join(test_data_path, 'wazuh_macos_file_status_predicate.yaml') parameters = [{'ONLY_FUTURE_EVENTS': 'yes'}, {'ONLY_FUTURE_EVENTS': 'no'}] metadata = [{'only-future-events': 'yes'}, {'only-future-events': 'no'}] # Configuration data configurations = load_wazuh_configurations(configurations_path, __name__, params=parameters, metadata=metadata) -configuration_ids = [f"{x['ONLY_FUTURE_EVENTS']}" for x in parameters] - -daemons_handler_configuration = {'daemons': ['wazuh-logcollector'], 'ignore_errors': False} +configuration_ids = [f"only_future_events_{x['ONLY_FUTURE_EVENTS']}" for x in parameters] # Max number of characters to be displayed in the log's debug message sample_log_length = 100 # Time in seconds to update the file_status.json file_status_update_time = 4 -local_internal_options = { 'logcollector.vcheck_files': file_status_update_time, - 'logcollector.sample_log_length': sample_log_length } - -# Maximum waiting time in seconds to find the logs on ossec.log -file_monitor_timeout = 30 - -wazuh_log_monitor = None +local_internal_options = {'logcollector.vcheck_files': file_status_update_time} # Fixtures @pytest.fixture(scope='module') -def startup_cleanup(): - """Truncate ossec.log and remove logcollector's file_status.json file.""" +def handle_files(): + """Truncate local_internal_options.conf, ossec.log and remove logcollector's file_status.json file.""" truncate_file(WAZUH_LOCAL_INTERNAL_OPTIONS) - truncate_file(LOG_FILE_PATH) - os.remove(LOGCOLLECTOR_FILE_STATUS_PATH) if os.path.exists(LOGCOLLECTOR_FILE_STATUS_PATH) else None @pytest.fixture(scope='module', params=configurations, ids=configuration_ids) @@ -58,44 +48,33 @@ def get_configuration(request): return request.param -def callback_log_bad_predicate(): - """Check if 'line' has the macOS ULS bad predicate message on it.""" - return make_callback(pattern="Execution error 'log:", prefix=logcollector_prefix) - - -def callback_log_exit_log(): - """Check if 'line' has the macOS ULS log stream exited message on it.""" - return make_callback(pattern="macOS 'log stream' process exited, pid:", prefix=logcollector_prefix) - - -def test_macos_file_status_predicate(startup_cleanup, +def test_macos_file_status_predicate(handle_files, configure_local_internal_options_module, get_configuration, configure_environment, - daemons_handler): + file_monitoring, + restart_required_logcollector_test_daemons): """Checks that logcollector does not store 'macos'-formatted localfile data since its predicate is erroneous. - The agent is connected to the authd simulator and uses a dummy localfile (/Library/Ossec/logs/active-responses.log) - which triggers the creation of file_status.json + The agent uses a dummy localfile (/Library/Ossec/logs/active-responses.log) which triggers the creation of + file_status.json file. Raises: TimeoutError: If the callbacks, that checks the expected logs, are not satisfied in the expected time. FileNotFoundError: If the file_status.json is not available in the expected time. """ - wazuh_log_monitor = FileMonitor(LOG_FILE_PATH) - wazuh_log_monitor.start(timeout=file_monitor_timeout, - callback=callback_log_bad_predicate(), - error_message='Expected log that matches the regex ' - '".*Execution error \'log:" could not be found') + log_monitor.start(timeout=LOG_COLLECTOR_GLOBAL_TIMEOUT, + callback=callback_log_bad_predicate(), + error_message='Expected log that matches the regex ".*Execution error \'log:" could not be found') - wazuh_log_monitor.start(timeout=file_monitor_timeout, - callback=callback_log_exit_log(), - error_message='Expected log that matches the regex ' - '".*macOS \'log stream\' process exited, pid:" could not be found') + log_monitor.start(timeout=LOG_COLLECTOR_GLOBAL_TIMEOUT, + callback=callback_log_macos_stream_exit(), + error_message='Expected log that matches the regex ' + '".*macOS \'log stream\' process exited, pid:" could not be found') # Waiting for file_status.json to be created, with a timeout about the time needed to update the file - wait_file(LOGCOLLECTOR_FILE_STATUS_PATH, file_monitor_timeout) + wait_file(LOGCOLLECTOR_FILE_STATUS_PATH, LOG_COLLECTOR_GLOBAL_TIMEOUT) file_status_json = read_json(LOGCOLLECTOR_FILE_STATUS_PATH) diff --git a/tests/integration/test_logcollector/test_macos/test_macos_file_status_when_no_macos.py b/tests/integration/test_logcollector/test_macos/test_macos_file_status_when_no_macos.py index 4ce4538270..e47d5094ce 100644 --- a/tests/integration/test_logcollector/test_macos/test_macos_file_status_when_no_macos.py +++ b/tests/integration/test_logcollector/test_macos/test_macos_file_status_when_no_macos.py @@ -2,97 +2,68 @@ # Created by Wazuh, Inc. . # This program is free software; you can redistribute it and/or modify it under the terms of GPLv2 -import os import pytest -import wazuh_testing.logcollector as logcollector -from wazuh_testing.tools import LOGCOLLECTOR_FILE_STATUS_PATH, LOG_FILE_PATH, WAZUH_LOCAL_INTERNAL_OPTIONS -from wazuh_testing.tools.monitoring import FileMonitor, wait_file, make_callback +from wazuh_testing.logcollector import LOG_COLLECTOR_GLOBAL_TIMEOUT, callback_logcollector_started +from wazuh_testing.tools import LOGCOLLECTOR_FILE_STATUS_PATH, WAZUH_LOCAL_INTERNAL_OPTIONS from wazuh_testing.tools.file import read_json, write_json_file, truncate_file from wazuh_testing.tools.configuration import load_wazuh_configurations -from wazuh_testing.logcollector import prefix as logcollector_prefix -from wazuh_testing.tools.services import control_service +from wazuh_testing.tools.monitoring import wait_file +from os.path import dirname, join, exists, realpath from tempfile import gettempdir from time import sleep +from os import remove # Marks pytestmark = [pytest.mark.darwin, pytest.mark.tier(level=0)] # Configuration -test_data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data') -configurations_path = os.path.join(test_data_path, 'wazuh_macos_file_status_when_no_macos.yaml') +test_data_path = join(dirname(realpath(__file__)), 'data') +configurations_path = join(test_data_path, 'wazuh_macos_file_status_when_no_macos.yaml') -dummy_file = os.path.join(gettempdir(), 'dummy_file.log') +dummy_file = join(gettempdir(), 'dummy_file.log') parameters = [{'FILE_TO_MONITOR': dummy_file}] # Configuration data configurations = load_wazuh_configurations(configurations_path, __name__, params=parameters) -configuration_ids = [f"{x['FILE_TO_MONITOR']}" for x in parameters] # Max number of characters to be displayed in the log's debug message sample_log_length = 100 # Time in seconds to update the file_status.json file_status_update_time = 4 -local_internal_options = { 'logcollector.vcheck_files': file_status_update_time, - 'logcollector.sample_log_length': sample_log_length } +local_internal_options = {'logcollector.vcheck_files': file_status_update_time} -# Maximum waiting time in seconds to find the logs on ossec.log -file_monitor_timeout = 30 - -# Time to wait for file_status.json to be updated -wait_file_status_update_time = file_status_update_time + 2 - -wazuh_log_monitor = None +# Time to wait for file_status.json to be updated (the +8 is due to a delay added by the wazuh-agentd daemmon) +wait_file_status_update_time = file_status_update_time + 8 # Fixtures -@pytest.fixture(scope='module', params=configurations, ids=configuration_ids) -def get_configuration(request): - """Get configurations from the module.""" - return request.param - - @pytest.fixture(scope='module') -def restart_required_logcollector_daemons(): - """Wazuh logcollector daemons handler.""" - - required_logcollector_daemons = ['wazuh-logcollector'] - - for daemon in required_logcollector_daemons: - control_service('stop', daemon=daemon) - - truncate_file(LOG_FILE_PATH) - os.remove(LOGCOLLECTOR_FILE_STATUS_PATH) if os.path.exists(LOGCOLLECTOR_FILE_STATUS_PATH) else None +def handle_files(): + """Truncate local_internals file and create dummy file to be monitored by logcollector, then it is deleted.""" + truncate_file(WAZUH_LOCAL_INTERNAL_OPTIONS) - for daemon in required_logcollector_daemons: - control_service('start', daemon=daemon) + with open(dummy_file, 'w') as f: + pass yield - for daemon in required_logcollector_daemons: - control_service('stop', daemon=daemon) + remove(dummy_file) if exists(dummy_file) else None -@pytest.fixture(scope='module') -def startup_cleanup(): - """Truncate local_internals file and create dummy file to be monitored by logcollector.""" - truncate_file(WAZUH_LOCAL_INTERNAL_OPTIONS) - - with open(dummy_file, 'w') as f: - pass - - -def callback_logcollector_started(): - """Check for 'macos' key.""" - return make_callback(pattern='Started', prefix=logcollector_prefix) +@pytest.fixture(scope='module', params=configurations) +def get_configuration(request): + """Get configurations from the module.""" + return request.param -def test_macos_file_status_when_no_macos(startup_cleanup, +def test_macos_file_status_when_no_macos(handle_files, configure_local_internal_options_module, get_configuration, configure_environment, - restart_required_logcollector_daemons): + file_monitoring, + restart_required_logcollector_test_daemons): """Checks that logcollector does not store and removes, if exists, previous "macos"-formatted localfile data in the file_status.json @@ -106,14 +77,12 @@ def test_macos_file_status_when_no_macos(startup_cleanup, file_status_json = {} - wazuh_log_monitor = FileMonitor(LOG_FILE_PATH) - - wazuh_log_monitor.start(timeout=file_monitor_timeout, - callback=callback_logcollector_started(), - error_message="Logcollector did not start") + log_monitor.start(timeout=LOG_COLLECTOR_GLOBAL_TIMEOUT, + callback=callback_logcollector_started(), + error_message="Logcollector did not start") # Check if json_status contains 'macos' data and if not insert it - if os.path.exists(LOGCOLLECTOR_FILE_STATUS_PATH): + if exists(LOGCOLLECTOR_FILE_STATUS_PATH): file_status_json = read_json(LOGCOLLECTOR_FILE_STATUS_PATH) if 'macos' not in file_status_json: file_status_json['macos'] = {} @@ -130,7 +99,7 @@ def test_macos_file_status_when_no_macos(startup_cleanup, write_json_file(LOGCOLLECTOR_FILE_STATUS_PATH, file_status_json) # Waits for file_status.json to be created, with a timeout about the time needed to update the file - wait_file(LOGCOLLECTOR_FILE_STATUS_PATH, file_monitor_timeout) + wait_file(LOGCOLLECTOR_FILE_STATUS_PATH, LOG_COLLECTOR_GLOBAL_TIMEOUT) # Waits about the time needed to update the file status sleep(wait_file_status_update_time)