From b1b4debc890144cd71c974fb98eef8670a920f9e Mon Sep 17 00:00:00 2001 From: Alexis Rivas Date: Wed, 18 Aug 2021 12:53:50 -0300 Subject: [PATCH 01/11] Fix cached dependencies and update debian repos --- .../agentless_cluster/roles/master-role/tasks/main.yml | 8 +++++++- .../agentless_cluster/roles/worker-role/tasks/main.yml | 8 +++++++- .../basic_cluster/roles/agent-role/tasks/main.yml | 8 +++++++- .../basic_cluster/roles/master-role/tasks/main.yml | 8 ++++++-- .../basic_cluster/roles/worker-role/tasks/main.yml | 8 ++++++-- .../enrollment_cluster/roles/agent-role/tasks/main.yml | 8 +++++++- .../enrollment_cluster/roles/master-role/tasks/main.yml | 8 +++++++- .../enrollment_cluster/roles/worker-role/tasks/main.yml | 8 +++++++- 8 files changed, 54 insertions(+), 10 deletions(-) diff --git a/tests/system/provisioning/agentless_cluster/roles/master-role/tasks/main.yml b/tests/system/provisioning/agentless_cluster/roles/master-role/tasks/main.yml index 5b1e12ba1f..bbb48d5a30 100644 --- a/tests/system/provisioning/agentless_cluster/roles/master-role/tasks/main.yml +++ b/tests/system/provisioning/agentless_cluster/roles/master-role/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: "Check and update debian repositories" + shell: + cmd: apt-get update --allow-releaseinfo-change + - name: "Installing dependencies using apt" apt: pkg: @@ -12,8 +16,10 @@ - automake - autoconf - libtool - force_apt_get: True + force_apt_get: yes state: present + update_cache: yes + cache_valid_time: 3600 - name: "Clone wazuh repository" git: diff --git a/tests/system/provisioning/agentless_cluster/roles/worker-role/tasks/main.yml b/tests/system/provisioning/agentless_cluster/roles/worker-role/tasks/main.yml index dfea0a1ce5..ea47be9eb5 100644 --- a/tests/system/provisioning/agentless_cluster/roles/worker-role/tasks/main.yml +++ b/tests/system/provisioning/agentless_cluster/roles/worker-role/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: "Check and update debian repositories" + shell: + cmd: apt-get update --allow-releaseinfo-change + - name: "Installing dependencies using apt" apt: pkg: @@ -13,8 +17,10 @@ - autoconf - libtool - python3-pytest - force_apt_get: True + force_apt_get: yes state: present + update_cache: yes + cache_valid_time: 3600 - name: "Clone wazuh repository" git: diff --git a/tests/system/provisioning/basic_cluster/roles/agent-role/tasks/main.yml b/tests/system/provisioning/basic_cluster/roles/agent-role/tasks/main.yml index b7e3f4b9d6..4ff95f1277 100644 --- a/tests/system/provisioning/basic_cluster/roles/agent-role/tasks/main.yml +++ b/tests/system/provisioning/basic_cluster/roles/agent-role/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: "Check and update debian repositories" + shell: + cmd: apt-get update --allow-releaseinfo-change + - name: "Installing dependencies using apt" apt: pkg: @@ -13,8 +17,10 @@ - autoconf - libtool - python3-pytest - force_apt_get: True + force_apt_get: yes state: present + update_cache: yes + cache_valid_time: 3600 - name: "Clone wazuh repository" git: diff --git a/tests/system/provisioning/basic_cluster/roles/master-role/tasks/main.yml b/tests/system/provisioning/basic_cluster/roles/master-role/tasks/main.yml index a448cce85d..dbd4f8d578 100644 --- a/tests/system/provisioning/basic_cluster/roles/master-role/tasks/main.yml +++ b/tests/system/provisioning/basic_cluster/roles/master-role/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: "Check and update debian repositories" + shell: + cmd: apt-get update --allow-releaseinfo-change + - name: "Installing dependencies using apt" apt: pkg: @@ -13,9 +17,9 @@ - autoconf - libtool - sqlite3 - force_apt_get: True + force_apt_get: yes state: present - update-cache: true + update_cache: yes cache_valid_time: 3600 - name: "Clone wazuh repository" diff --git a/tests/system/provisioning/basic_cluster/roles/worker-role/tasks/main.yml b/tests/system/provisioning/basic_cluster/roles/worker-role/tasks/main.yml index 0be482195d..bb2bd19fcd 100644 --- a/tests/system/provisioning/basic_cluster/roles/worker-role/tasks/main.yml +++ b/tests/system/provisioning/basic_cluster/roles/worker-role/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: "Check and update debian repositories" + shell: + cmd: apt-get update --allow-releaseinfo-change + - name: "Installing dependencies using apt" apt: pkg: @@ -14,9 +18,9 @@ - libtool - python3-pytest - sqlite3 - force_apt_get: True + force_apt_get: yes state: present - update-cache: true + update_cache: yes cache_valid_time: 3600 - name: "Clone wazuh repository" diff --git a/tests/system/provisioning/enrollment_cluster/roles/agent-role/tasks/main.yml b/tests/system/provisioning/enrollment_cluster/roles/agent-role/tasks/main.yml index 64197cf22c..a23f3bcf8d 100644 --- a/tests/system/provisioning/enrollment_cluster/roles/agent-role/tasks/main.yml +++ b/tests/system/provisioning/enrollment_cluster/roles/agent-role/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: "Check and update debian repositories" + shell: + cmd: apt-get update --allow-releaseinfo-change + - name: "Installing dependencies using apt" apt: pkg: @@ -13,8 +17,10 @@ - autoconf - libtool - python3-pytest - force_apt_get: True + force_apt_get: yes state: present + update_cache: yes + cache_valid_time: 3600 - name: "Clone wazuh repository" git: diff --git a/tests/system/provisioning/enrollment_cluster/roles/master-role/tasks/main.yml b/tests/system/provisioning/enrollment_cluster/roles/master-role/tasks/main.yml index b42a147421..b9afc0d5a3 100644 --- a/tests/system/provisioning/enrollment_cluster/roles/master-role/tasks/main.yml +++ b/tests/system/provisioning/enrollment_cluster/roles/master-role/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: "Check and update debian repositories" + shell: + cmd: apt-get update --allow-releaseinfo-change + - name: "Installing dependencies using apt" apt: pkg: @@ -12,8 +16,10 @@ - automake - autoconf - libtool - force_apt_get: True + force_apt_get: yes state: present + update_cache: yes + cache_valid_time: 3600 - name: "Clone wazuh repository" git: diff --git a/tests/system/provisioning/enrollment_cluster/roles/worker-role/tasks/main.yml b/tests/system/provisioning/enrollment_cluster/roles/worker-role/tasks/main.yml index 36e0e2e324..c33017f855 100644 --- a/tests/system/provisioning/enrollment_cluster/roles/worker-role/tasks/main.yml +++ b/tests/system/provisioning/enrollment_cluster/roles/worker-role/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: "Check and update debian repositories" + shell: + cmd: apt-get update --allow-releaseinfo-change + - name: "Installing dependencies using apt" apt: pkg: @@ -13,8 +17,10 @@ - autoconf - libtool - python3-pytest - force_apt_get: True + force_apt_get: yes state: present + update_cache: yes + cache_valid_time: 3600 - name: "Clone wazuh repository" git: From ff3ec448a2edf45b71dc6cc0ee45dd4ecb377337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo?= Date: Fri, 3 Sep 2021 13:53:58 +0200 Subject: [PATCH 02/11] Create configure_local_internal_options_module fixture --- .../wazuh_testing/tools/configuration.py | 29 +++++++++++++++++ tests/integration/conftest.py | 31 ++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/deps/wazuh_testing/wazuh_testing/tools/configuration.py b/deps/wazuh_testing/wazuh_testing/tools/configuration.py index 08099091be..1315e08a0a 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/configuration.py +++ b/deps/wazuh_testing/wazuh_testing/tools/configuration.py @@ -600,3 +600,32 @@ def local_internal_options_to_dict(local_internal_options): dict_local_internal_options[key.rstrip("\n")] = value return dict_local_internal_options + + +def get_local_internal_options_dict(): + """Return the local internal options in a dictionary + + Returns: + dict: Local internal options. + """ + local_internal_option_dict = {} + with open(WAZUH_LOCAL_INTERNAL_OPTIONS, 'r') as local_internal_option_file: + configuration_options = local_internal_option_file.readlines() + for configuration_option in configuration_options: + if not configuration_option.startswith('#'): + option_name, option_value = configuration_option.split('=') + local_internal_option_dict[option_name] = option_value + + return local_internal_option_dict + + +def set_local_internal_options_dict(dict_local_internal_options): + """Set the local internal options using a dictionary + + Args: + local_internal_options_dict (dict): A dictionary containing local internal options. + """ + with open(WAZUH_LOCAL_INTERNAL_OPTIONS, 'w') as local_internal_option_file: + for option_name, option_value in dict_local_internal_options.items(): + local_internal_configuration_string = f"{str(option_name)}={str(option_value)}\n" + local_internal_option_file.write(local_internal_configuration_string) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 33d2787753..c85bd78f64 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -16,7 +16,7 @@ from py.xml import html import wazuh_testing.tools.configuration as conf -from wazuh_testing import global_parameters +from wazuh_testing import global_parameters, logger from wazuh_testing.logcollector import create_file_structure, delete_file_structure from wazuh_testing.tools import LOG_FILE_PATH, WAZUH_CONF, get_service, ALERT_FILE_PATH from wazuh_testing.tools.file import truncate_file @@ -602,3 +602,32 @@ def create_file_structure_function(get_files_list): yield delete_file_structure(get_files_list) + + +@pytest.fixture(scope="module") +def configure_local_internal_options_module(request): + """Fixture to configure the local internal options file. + + It uses the test variable local_internal_options. This should be + a dictionary wich keys and values corresponds to the internal option configuration, For example: + local_internal_options = ['monitord.rotate_log': '0', 'syscheck.debug': '0' ] + """ + try: + local_internal_options = getattr(request.module, 'local_internal_options', []) + except AttributeError as local_internal_configuration_not_set: + logger.error('Configure Local Internal Options: Error - local_internal_options is not set') + raise local_internal_configuration_not_set + + + backup_local_internal_options = conf.get_local_internal_options_dict() + + logger.error('Configure Local Internal Options: DEBUG - Set local_internal_option to ' + + f"{str(local_internal_options)}") + conf.set_local_internal_options_dict(local_internal_options) + + yield + + + logger.error('Configure Local Internal Options: DEBUG - Restore local_internal_option to ' + + f"{str(backup_local_internal_options)}") + conf.set_local_internal_options_dict(backup_local_internal_options) From 0a1c57d5a0353c323ffffd2318cd9c1e92a690b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo?= Date: Fri, 3 Sep 2021 14:45:27 +0200 Subject: [PATCH 03/11] Fix minnor style errors in configure_local_internal fixture Define default internal_option_configurations for wazuh daemons --- .../wazuh_testing/tools/__init__.py | 20 +++++++++++++++++++ .../wazuh_testing/tools/configuration.py | 4 ++-- tests/integration/conftest.py | 4 +--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/deps/wazuh_testing/wazuh_testing/tools/__init__.py b/deps/wazuh_testing/wazuh_testing/tools/__init__.py index 04f2bb3068..d4a980eb68 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/__init__.py +++ b/deps/wazuh_testing/wazuh_testing/tools/__init__.py @@ -146,3 +146,23 @@ def get_service(): MODULESD_KREQUEST_SOCKET_PATH, AUTHD_SOCKET_PATH ] + +DISABLE_MONITORD_ROTATE_LOG_OPTION = {'monitord.rotate_log': '0'} +REMOTED_LOCAL_INTERNAL_OPTIONS = {'remoted.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) +ANALYSISD_LOCAL_INTERNAL_OPTIONS = {'analysisd.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) +AGENTD_LOCAL_INTERNAL_OPTIONS = {'agent.debug': '2', 'execd': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) + +FIM_LOCAL_INTERNAL_OPTIONS_MANAGER = {'syscheck.debug': '2', + 'analysisd.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) +FIM_LOCAL_INTERNAL_OPTIONS_AGENT_UNIX = {'syscheck.debug': '2', + 'agent.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) +FIM_LOCAL_INTERNAL_OPTIONS_AGENT_WINDOWS = {'syscheck.debug': '2', + 'windows.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) + +GCLOUD_LOCAL_INTERNAL_OPTIONS = {'analysisd.debug': '2', + 'wazuh_modules.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) +LOGTEST_LOCAL_INTERNAL_OPTIONS = {'analysisd.debug': '2'} +REMOTED_LOCAL_INTERNAL_OPTIONS = {'remoted.debug': '2', 'wazuh_database.interval': '2', 'wazuh_db.commit_time': '2', + 'wazuh_db.commit_time_max': '3' }.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) +VD_LOCAL_INTERNAL_OPTIONS = {'wazuh_modules.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) +WPK_LOCAL_INTERNAL_OPTIONS = {'wazuh_modules.debug': '2'} diff --git a/deps/wazuh_testing/wazuh_testing/tools/configuration.py b/deps/wazuh_testing/wazuh_testing/tools/configuration.py index 1315e08a0a..81ad279a39 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/configuration.py +++ b/deps/wazuh_testing/wazuh_testing/tools/configuration.py @@ -603,7 +603,7 @@ def local_internal_options_to_dict(local_internal_options): def get_local_internal_options_dict(): - """Return the local internal options in a dictionary + """Return the local internal options in a dictionary. Returns: dict: Local internal options. @@ -620,7 +620,7 @@ def get_local_internal_options_dict(): def set_local_internal_options_dict(dict_local_internal_options): - """Set the local internal options using a dictionary + """Set the local internal options using a dictionary. Args: local_internal_options_dict (dict): A dictionary containing local internal options. diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index c85bd78f64..f548a4cd48 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -613,12 +613,11 @@ def configure_local_internal_options_module(request): local_internal_options = ['monitord.rotate_log': '0', 'syscheck.debug': '0' ] """ try: - local_internal_options = getattr(request.module, 'local_internal_options', []) + local_internal_options = getattr(request.module, 'local_internal_options') except AttributeError as local_internal_configuration_not_set: logger.error('Configure Local Internal Options: Error - local_internal_options is not set') raise local_internal_configuration_not_set - backup_local_internal_options = conf.get_local_internal_options_dict() logger.error('Configure Local Internal Options: DEBUG - Set local_internal_option to ' + @@ -627,7 +626,6 @@ def configure_local_internal_options_module(request): yield - logger.error('Configure Local Internal Options: DEBUG - Restore local_internal_option to ' + f"{str(backup_local_internal_options)}") conf.set_local_internal_options_dict(backup_local_internal_options) From a267b08fa261d93ea2f711ba3eb944726cb85076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo?= Date: Fri, 3 Sep 2021 14:46:47 +0200 Subject: [PATCH 04/11] Remove useless whitespaces in tools packages --- deps/wazuh_testing/wazuh_testing/tools/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/deps/wazuh_testing/wazuh_testing/tools/__init__.py b/deps/wazuh_testing/wazuh_testing/tools/__init__.py index d4a980eb68..a4018ce0e6 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/__init__.py +++ b/deps/wazuh_testing/wazuh_testing/tools/__init__.py @@ -151,14 +151,12 @@ def get_service(): REMOTED_LOCAL_INTERNAL_OPTIONS = {'remoted.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) ANALYSISD_LOCAL_INTERNAL_OPTIONS = {'analysisd.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) AGENTD_LOCAL_INTERNAL_OPTIONS = {'agent.debug': '2', 'execd': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) - FIM_LOCAL_INTERNAL_OPTIONS_MANAGER = {'syscheck.debug': '2', 'analysisd.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) FIM_LOCAL_INTERNAL_OPTIONS_AGENT_UNIX = {'syscheck.debug': '2', 'agent.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) FIM_LOCAL_INTERNAL_OPTIONS_AGENT_WINDOWS = {'syscheck.debug': '2', 'windows.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) - GCLOUD_LOCAL_INTERNAL_OPTIONS = {'analysisd.debug': '2', 'wazuh_modules.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) LOGTEST_LOCAL_INTERNAL_OPTIONS = {'analysisd.debug': '2'} From 61e35a8f5b3351f023fab031dbaa1744866cf1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Jes=C3=BAs=20Pe=C3=B1a=20Rodr=C3=ADguez?= Date: Mon, 6 Sep 2021 11:29:42 +0200 Subject: [PATCH 05/11] Update API performance tests (#1519) * Update API performance tests * Change DELETE /groups and DELETE /agents * Add the tests pending to be fixed to the xfailed tests * Fix over-indented for visual indent * General improvements to follow the repo standard --- tests/performance/test_api/conftest.py | 13 +- .../test_api/data/configuration.yaml | 291 ---------------- .../data/wazuh_api_endpoints_performance.yaml | 315 ++++++++++++++++++ tests/performance/test_api/test_api.py | 47 --- .../test_api_endpoints_performance.py | 70 ++++ 5 files changed, 391 insertions(+), 345 deletions(-) create mode 100755 tests/performance/test_api/data/wazuh_api_endpoints_performance.yaml delete mode 100755 tests/performance/test_api/test_api.py create mode 100755 tests/performance/test_api/test_api_endpoints_performance.py diff --git a/tests/performance/test_api/conftest.py b/tests/performance/test_api/conftest.py index 2ed7ac1c0e..d1324a68f2 100755 --- a/tests/performance/test_api/conftest.py +++ b/tests/performance/test_api/conftest.py @@ -2,22 +2,24 @@ # Created by Wazuh, Inc. . # This program is free software; you can redistribute it and/or modify it under the terms of GPLv2 +from os.path import join, dirname, realpath from time import sleep import pytest import requests from py.xml import html +from yaml import safe_load + from wazuh_testing.api import get_api_details_dict results = dict() +configuration = safe_load(open(join(dirname(realpath(__file__)), 'data', 'configuration.yaml')))['configuration'] @pytest.fixture(scope='module') def set_api_test_environment(request): kwargs = dict() - if hasattr(request.module, 'configuration'): - configuration = getattr(request.module, 'configuration') - kwargs.update({'host': configuration['host'], 'port': configuration['port']}) + kwargs.update({'host': configuration['host'], 'port': configuration['port']}) api_details = get_api_details_dict(**kwargs) @@ -167,10 +169,7 @@ def pytest_html_results_summary(prefix, summary, postfix): def pytest_collection_modifyitems(session, config, items): # Add test configuration as metadata (environment table) - try: - config._metadata = items[0].callspec.params['test_configuration'] - except IndexError: - pass + config._metadata = configuration # Add each test_case metadata as user_properties for its item for item in items: diff --git a/tests/performance/test_api/data/configuration.yaml b/tests/performance/test_api/data/configuration.yaml index 7619233e15..48adb3a68f 100755 --- a/tests/performance/test_api/data/configuration.yaml +++ b/tests/performance/test_api/data/configuration.yaml @@ -2,294 +2,3 @@ configuration: host: 'localhost' port: 55000 restart_delay: 30 - -test_cases: - - - endpoint: /cluster/local/info - method: get - parameters: {} - body: {} - - - endpoint: /cluster/nodes - method: get - parameters: {} - body: {} - - - endpoint: /cluster/healthcheck - method: get - parameters: {} - body: {} - - - endpoint: /cluster/status - method: get - parameters: {} - body: {} - - - endpoint: /cluster/local/config - method: get - parameters: {} - body: {} - - - endpoint: /cluster/api/config - method: get - parameters: {} - body: {} - - - endpoint: /cluster/configuration/validation - method: get - parameters: {} - body: {} - - - endpoint: /manager/status - method: get - parameters: {} - body: {} - - - endpoint: /manager/info - method: get - parameters: {} - body: {} - - - endpoint: /manager/configuration - method: get - parameters: {} - body: {} - - - endpoint: /manager/logs - method: get - parameters: {} - body: {} - - - endpoint: /manager/api/config - method: get - parameters: {} - body: {} - - - endpoint: /manager/configuration/validation - method: get - parameters: {} - body: {} - - - endpoint: /mitre - method: get - parameters: {} - body: {} - - - endpoint: /overview/agents - method: get - parameters: {} - body: {} - - - endpoint: /tasks/status - method: get - parameters: {} - body: {} - - - endpoint: /active-response - method: put - parameters: {} - body: - command: custom - custom: True - restart: False - - - endpoint: /rootcheck - method: put - parameters: {} - body: {} - restart: False - - - endpoint: /syscheck - method: put - parameters: {} - body: {} - restart: False - - - endpoint: /rootcheck - method: delete - parameters: {} - body: {} - - - endpoint: /groups - method: post - parameters: {} - body: - group_id: "new_test_group" - - - endpoint: /security/users - method: post - parameters: {} - body: - username: "new_test_user" - password: "Password1!" - - - endpoint: /security/roles - method: post - parameters: {} - body: - name: "new_test_role" - - - endpoint: /security/policies - method: post - parameters: {} - body: - name: "new_test_policy" - policy: - actions: - - "agent:read" - resources: - - "agent:id:99" - effect: "allow" - - - endpoint: /security/rules - method: post - parameters: {} - body: - name: "new_test_security_rule" - rule: - MATCH: - name: "test" - - - endpoint: /agents/group - method: put - parameters: - group_id: "new_test_group" - body: {} - restart: True - - - endpoint: /agents/group/new_test_group/restart - method: put - parameters: {} - body: {} - restart: True - - - endpoint: /agents/restart - method: put - parameters: {} - body: {} - restart: True - - - endpoint: /agents - method: post - parameters: {} - body: - name: "new_test_agent" - ip: "any" - - - endpoint: /agents/insert - method: post - parameters: {} - body: - name: "new_test_agent_insert" - ip: "any" - - - endpoint: /agents/insert/quick - method: post - parameters: - agent_name: "new_test_agent_insert_quick" - body: {} - - - endpoint: /agents - method: get - parameters: {} - body: {} - - - endpoint: /agents/no_group - method: get - parameters: {} - body: {} - - - endpoint: /agents/outdated - method: get - parameters: {} - body: {} - - - endpoint: /decoders - method: get - parameters: {} - body: {} - - - endpoint: /groups - method: get - parameters: {} - body: {} - - - endpoint: /lists - method: get - parameters: {} - body: {} - - - endpoint: /rules - method: get - parameters: {} - body: {} - - - endpoint: /security/users - method: get - parameters: {} - body: {} - - - endpoint: /security/roles - method: get - parameters: {} - body: {} - - - endpoint: /security/policies - method: get - parameters: {} - body: {} - - - endpoint: /security/rules - method: get - parameters: {} - body: {} - - - endpoint: /agents - method: delete - parameters: - agents_list: "all" - status: "all" - older_than: "0s" - body: {} - - - endpoint: /groups - method: delete - parameters: - groups_list: "all" - body: {} - - - endpoint: /security/users - method: delete - parameters: - user_ids: "all" - body: {} - - - endpoint: /security/roles - method: delete - parameters: - role_ids: "all" - body: {} - - - endpoint: /security/policies - method: delete - parameters: - policy_ids: "all" - body: {} - - - endpoint: /security/rules - method: delete - parameters: - rule_ids: "all" - body: {} - - - endpoint: /manager/restart - method: put - parameters: {} - body: {} - restart: True - - - endpoint: /cluster/restart - method: put - parameters: {} - body: {} - restart: True diff --git a/tests/performance/test_api/data/wazuh_api_endpoints_performance.yaml b/tests/performance/test_api/data/wazuh_api_endpoints_performance.yaml new file mode 100755 index 0000000000..f0e458e3a9 --- /dev/null +++ b/tests/performance/test_api/data/wazuh_api_endpoints_performance.yaml @@ -0,0 +1,315 @@ +test_cases: + + - endpoint: /cluster/local/info + method: get + parameters: {} + body: {} + + - endpoint: /cluster/nodes + method: get + parameters: {} + body: {} + + - endpoint: /cluster/healthcheck + method: get + parameters: {} + body: {} + + - endpoint: /cluster/status + method: get + parameters: {} + body: {} + + - endpoint: /cluster/local/config + method: get + parameters: {} + body: {} + + - endpoint: /cluster/api/config + method: get + parameters: {} + body: {} + + - endpoint: /cluster/configuration/validation + method: get + parameters: {} + body: {} + + - endpoint: /manager/status + method: get + parameters: {} + body: {} + + - endpoint: /manager/info + method: get + parameters: {} + body: {} + + - endpoint: /manager/configuration + method: get + parameters: {} + body: {} + + - endpoint: /manager/logs + method: get + parameters: {} + body: {} + + - endpoint: /manager/api/config + method: get + parameters: {} + body: {} + + - endpoint: /manager/configuration/validation + method: get + parameters: {} + body: {} + + - endpoint: /mitre/groups + method: get + parameters: {} + body: {} + + - endpoint: /mitre/metadata + method: get + parameters: {} + body: {} + + - endpoint: /mitre/mitigations + method: get + parameters: {} + body: {} + + - endpoint: /mitre/references + method: get + parameters: {} + body: {} + + - endpoint: /mitre/software + method: get + parameters: {} + body: {} + + - endpoint: /mitre/tactics + method: get + parameters: {} + body: {} + + - endpoint: /mitre/techniques + method: get + parameters: {} + body: {} + + - endpoint: /overview/agents + method: get + parameters: {} + body: {} + + - endpoint: /tasks/status + method: get + parameters: {} + body: {} + + - endpoint: /active-response + method: put + parameters: {} + body: + command: custom + custom: True + restart: False + + - endpoint: /rootcheck + method: put + parameters: {} + body: {} + restart: False + + - endpoint: /syscheck + method: put + parameters: {} + body: {} + restart: False + + - endpoint: /groups + method: post + parameters: {} + body: + group_id: "new_test_group" + + - endpoint: /security/users + method: post + parameters: {} + body: + username: "new_test_user" + password: "Password1!" + + - endpoint: /security/roles + method: post + parameters: {} + body: + name: "new_test_role" + + - endpoint: /security/policies + method: post + parameters: {} + body: + name: "new_test_policy" + policy: + actions: + - "agent:read" + resources: + - "agent:id:99" + effect: "allow" + + - endpoint: /security/rules + method: post + parameters: {} + body: + name: "new_test_security_rule" + rule: + MATCH: + name: "test" + + - endpoint: /agents/group + method: put + parameters: + group_id: "new_test_group" + body: {} + restart: True + + - endpoint: /agents/group/new_test_group/restart + method: put + parameters: {} + body: {} + restart: True + + - endpoint: /agents/restart + method: put + parameters: {} + body: {} + restart: True + + - endpoint: /agents + method: post + parameters: {} + body: + name: "new_test_agent" + ip: "any" + + - endpoint: /agents/insert + method: post + parameters: {} + body: + name: "new_test_agent_insert" + ip: "any" + + - endpoint: /agents/insert/quick + method: post + parameters: + agent_name: "new_test_agent_insert_quick" + body: {} + + - endpoint: /agents + method: get + parameters: {} + body: {} + + - endpoint: /agents/no_group + method: get + parameters: {} + body: {} + + - endpoint: /agents/outdated + method: get + parameters: {} + body: {} + + - endpoint: /decoders + method: get + parameters: {} + body: {} + + - endpoint: /groups + method: get + parameters: {} + body: {} + + - endpoint: /lists + method: get + parameters: {} + body: {} + + - endpoint: /rules + method: get + parameters: {} + body: {} + + - endpoint: /security/users + method: get + parameters: {} + body: {} + + - endpoint: /security/roles + method: get + parameters: {} + body: {} + + - endpoint: /security/policies + method: get + parameters: {} + body: {} + + - endpoint: /security/rules + method: get + parameters: {} + body: {} + + - endpoint: /groups + method: delete + parameters: + groups_list: "all" + body: {} + + - endpoint: /agents + method: delete + parameters: + agents_list: "all" + status: "all" + older_than: "0s" + body: {} + + - endpoint: /security/users + method: delete + parameters: + user_ids: "all" + body: {} + + - endpoint: /security/roles + method: delete + parameters: + role_ids: "all" + body: {} + + - endpoint: /security/policies + method: delete + parameters: + policy_ids: "all" + body: {} + + - endpoint: /security/rules + method: delete + parameters: + rule_ids: "all" + body: {} + + - endpoint: /manager/restart + method: put + parameters: {} + body: {} + restart: True + + - endpoint: /cluster/restart + method: put + parameters: {} + body: {} + restart: True diff --git a/tests/performance/test_api/test_api.py b/tests/performance/test_api/test_api.py deleted file mode 100755 index 1c191fed50..0000000000 --- a/tests/performance/test_api/test_api.py +++ /dev/null @@ -1,47 +0,0 @@ -from json import dumps -from os.path import join, dirname, realpath -from time import sleep - -import pytest -import requests -from yaml import safe_load - -test_data = safe_load(open(join(dirname(realpath(__file__)), 'data', 'configuration.yaml'))) -configuration = test_data['configuration'] -api_details = dict() - -xfailed_items = { - '/active-response': 'Agent simulator not handling active-response messages: ' - 'https://github.com/wazuh/wazuh-qa/issues/1266' -} - - -# Tests -@pytest.mark.parametrize('test_configuration', [configuration]) -@pytest.mark.parametrize('test_case', test_data['test_cases']) -def test_api_endpoints(test_case, test_configuration, set_api_test_environment, api_healthcheck): - """Make an API request for each `test_case`. `test_configuration` fixture is only used to add metadata to the - HTML report.""" - # Apply xfails - test_case['endpoint'] in xfailed_items and pytest.xfail(xfailed_items[test_case['endpoint']]) - - base_url = api_details['base_url'] - headers = api_details['auth_headers'] - response = None - try: - response = getattr(requests, test_case['method'])(f"{base_url}{test_case['endpoint']}", headers=headers, - params=test_case['parameters'], json=test_case['body'], - verify=False) - assert response.status_code == 200 - assert response.json()['error'] == 0 - - finally: - # Add useful information to report as stdout - try: - print(f'Request elapsed time: {response.elapsed.total_seconds():.3f}s\n') - print(f'Status code: {response.status_code}\n') - print(f'Full response: \n{dumps(response.json(), indent=2)}') - except KeyError: - print('No response available') - - test_case['method'] == 'put' and test_case['restart'] and sleep(configuration['restart_delay']) diff --git a/tests/performance/test_api/test_api_endpoints_performance.py b/tests/performance/test_api/test_api_endpoints_performance.py new file mode 100755 index 0000000000..99724e120f --- /dev/null +++ b/tests/performance/test_api/test_api_endpoints_performance.py @@ -0,0 +1,70 @@ +from json import dumps +from os.path import join, dirname, realpath +from time import sleep + +import pytest +import requests +from yaml import safe_load + +restart_delay = safe_load(open(join(dirname(realpath(__file__)), 'data', 'configuration.yaml')) + )['configuration']['restart_delay'] +test_data = safe_load(open(join(dirname(realpath(__file__)), 'data', 'wazuh_api_endpoints_performance.yaml'))) +case_ids = [f"{case['method']}_{case['endpoint']}" for case in test_data['test_cases']] +api_details = dict() + +xfailed_items = { + '/active-response': {'message': 'Agent simulator not handling active-response messages: ' + 'https://github.com/wazuh/wazuh-qa/issues/1266', + 'method': 'put'}, + '/agents/group': {'message': 'Slow agent-group files creation: https://github.com/wazuh/wazuh/issues/8625', + 'method': 'put'}, + '/syscheck': {'message': 'The `queue/alerts/ar` socket does not accept agent lists: ' + 'https://github.com/wazuh/wazuh/issues/9125', + 'method': 'put'}, + '/rootcheck': {'message': 'The `queue/alerts/ar` socket does not accept agent lists: ' + 'https://github.com/wazuh/wazuh/issues/9125', + 'method': 'put'}, + '/agents': {'message': 'The `queue/sockets/auth` socket does not accept agent lists: ' + 'https://github.com/wazuh/wazuh/issues/9127', + 'method': 'delete'}, + '/groups': {'message': 'Timeout caused by agent-group file manipulation in the Framework: ' + 'https://github.com/wazuh/wazuh/issues/9141', + 'method': 'delete'} +} + + +# Tests +@pytest.mark.parametrize('test_case', test_data['test_cases'], ids=case_ids) +def test_api_endpoints(test_case, set_api_test_environment, api_healthcheck): + """Make an API request for each `test_case`. + + Args: + test_case (dict): Dictionary with the endpoint to be tested and the necessary parameters for the test. + set_api_test_environment (fixture): Fixture that modifies the API security options. + api_healthcheck (fixture): Fixture used to check that the API is ready to respond requests. + """ + # Apply xfails + if test_case['endpoint'] in xfailed_items.keys() and \ + test_case['method'] == xfailed_items[test_case['endpoint']]['method']: + pytest.xfail(xfailed_items[test_case['endpoint']]['message']) + + base_url = api_details['base_url'] + headers = api_details['auth_headers'] + response = None + try: + response = getattr(requests, test_case['method'])(f"{base_url}{test_case['endpoint']}", headers=headers, + params=test_case['parameters'], json=test_case['body'], + verify=False) + assert response.status_code == 200 + assert response.json()['error'] == 0 + + finally: + # Add useful information to report as stdout + try: + print(f'Request elapsed time: {response.elapsed.total_seconds():.3f}s\n') + print(f'Status code: {response.status_code}\n') + print(f'Full response: \n{dumps(response.json(), indent=2)}') + except KeyError: + print('No response available') + + test_case['method'] == 'put' and test_case['restart'] and sleep(restart_delay) From 21847eea88abc803a5ba5e56fcd8d8151cc17ae0 Mon Sep 17 00:00:00 2001 From: Manuel Carmona Date: Mon, 6 Sep 2021 11:31:25 +0200 Subject: [PATCH 06/11] Update default user and password in the APISimulator constructor (#1822) --- deps/wazuh_testing/wazuh_testing/tools/api_simulator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/wazuh_testing/wazuh_testing/tools/api_simulator.py b/deps/wazuh_testing/wazuh_testing/tools/api_simulator.py index 539d5a5705..a0633a564c 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/api_simulator.py +++ b/deps/wazuh_testing/wazuh_testing/tools/api_simulator.py @@ -44,7 +44,7 @@ def get_logger(self): class APISimulator: - def __init__(self, host, port, protocol='https', frequency=60, user='wazuh', password='wazuh', + def __init__(self, host, port, protocol='https', frequency=60, user='wazuh-wui', password='wazuh-wui', external_logger=None, request_percentage=0, request_template=None): self.host = host self.port = port From 453f1c611122a255011b1d06d5fca2fe5822d993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo?= Date: Mon, 6 Sep 2021 17:07:40 +0200 Subject: [PATCH 07/11] Minnor changes to fullfill pep8-style --- .../wazuh_testing/tools/__init__.py | 14 ++++++------- .../wazuh_testing/tools/configuration.py | 21 ++++++++++++------- tests/integration/conftest.py | 8 +++---- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/deps/wazuh_testing/wazuh_testing/tools/__init__.py b/deps/wazuh_testing/wazuh_testing/tools/__init__.py index a4018ce0e6..41d8711339 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/__init__.py +++ b/deps/wazuh_testing/wazuh_testing/tools/__init__.py @@ -103,8 +103,8 @@ def get_service(): CLUSTER_SOCKET_PATH = os.path.join(WAZUH_PATH, 'queue', 'cluster') -ANALYSISD_ANALISIS_SOCKET_PATH= os.path.join(QUEUE_SOCKETS_PATH, 'analysis') -ANALYSISD_QUEUE_SOCKET_PATH= os.path.join(QUEUE_SOCKETS_PATH, 'queue') +ANALYSISD_ANALISIS_SOCKET_PATH = os.path.join(QUEUE_SOCKETS_PATH, 'analysis') +ANALYSISD_QUEUE_SOCKET_PATH = os.path.join(QUEUE_SOCKETS_PATH, 'queue') AUTHD_SOCKET_PATH = os.path.join(QUEUE_SOCKETS_PATH, 'auth') EXECD_SOCKET_PATH = os.path.join(QUEUE_SOCKETS_PATH, 'com') LOGCOLLECTOR_SOCKET_PATH = os.path.join(QUEUE_SOCKETS_PATH, 'logcollector') @@ -117,7 +117,7 @@ def get_service(): MODULESD_CONTROL_SOCKET_PATH = os.path.join(QUEUE_SOCKETS_PATH, 'control') MODULESD_KREQUEST_SOCKET_PATH = os.path.join(QUEUE_SOCKETS_PATH, 'krequest') MODULESD_C_INTERNAL_SOCKET_PATH = os.path.join(CLUSTER_SOCKET_PATH, 'c-internal.sock') -ACTIVE_RESPONSE_SOCKET_PATH = os.path.join(QUEUE_ALERTS_PATH,'ar') +ACTIVE_RESPONSE_SOCKET_PATH = os.path.join(QUEUE_ALERTS_PATH, 'ar') WAZUH_SOCKETS = { 'wazuh-agentd': [], @@ -152,15 +152,15 @@ def get_service(): ANALYSISD_LOCAL_INTERNAL_OPTIONS = {'analysisd.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) AGENTD_LOCAL_INTERNAL_OPTIONS = {'agent.debug': '2', 'execd': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) FIM_LOCAL_INTERNAL_OPTIONS_MANAGER = {'syscheck.debug': '2', - 'analysisd.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) + 'analysisd.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) FIM_LOCAL_INTERNAL_OPTIONS_AGENT_UNIX = {'syscheck.debug': '2', - 'agent.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) + 'agent.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) FIM_LOCAL_INTERNAL_OPTIONS_AGENT_WINDOWS = {'syscheck.debug': '2', 'windows.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) GCLOUD_LOCAL_INTERNAL_OPTIONS = {'analysisd.debug': '2', - 'wazuh_modules.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) + 'wazuh_modules.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) LOGTEST_LOCAL_INTERNAL_OPTIONS = {'analysisd.debug': '2'} REMOTED_LOCAL_INTERNAL_OPTIONS = {'remoted.debug': '2', 'wazuh_database.interval': '2', 'wazuh_db.commit_time': '2', - 'wazuh_db.commit_time_max': '3' }.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) + 'wazuh_db.commit_time_max': '3'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) VD_LOCAL_INTERNAL_OPTIONS = {'wazuh_modules.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION) WPK_LOCAL_INTERNAL_OPTIONS = {'wazuh_modules.debug': '2'} diff --git a/deps/wazuh_testing/wazuh_testing/tools/configuration.py b/deps/wazuh_testing/wazuh_testing/tools/configuration.py index 81ad279a39..214710ff3a 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/configuration.py +++ b/deps/wazuh_testing/wazuh_testing/tools/configuration.py @@ -227,10 +227,12 @@ def purge_multiple_root_elements(str_list: List[str], root_delimeter: str = "" + root_delimeter (str, optional: The expected string to identify when the first root element ends, + by default "" Returns: - list of str : The first N lines of the specified str_list until the root_delimeter is found. The rest of the list will be ignored. + list of str : The first N lines of the specified str_list until the root_delimeter is found. The rest of + the list will be ignored. """ line_counter = 0 for line in str_list: @@ -277,7 +279,8 @@ def find_module_config(wazuh_conf: ET.ElementTree, section: str, attributes: Lis Args: wazuh_conf (ElementTree): An ElementTree object with all the data of the ossec.conf section (str): Name of the tag or configuration section to search for. For example: vulnerability_detector - attributes (list\ ): List with section attributes. Needed to check if the section exists with all the searched attributes and values. For example (wodle section) [{'name': 'syscollector'}] + attributes (list of dict): List with section attributes. Needed to check if the section exists with all the + searched attributes and values. For example (wodle section) [{'name': 'syscollector'}] Returns: ElementTree: An ElementTree object with the section data found in ossec.conf. None if nothing was found. """ @@ -399,7 +402,8 @@ def load_wazuh_configurations(yaml_file_path: str, test_name: str, params: list Args: yaml_file_path (str): Full path of the YAML file to be loaded. test_name (str): Name of the file which contains the test that will be executed. - params (list, optional) : List of dicts where each dict represents a replacement MATCH -\> REPLACEMENT. Default `None` + params (list, optional) : List of dicts where each dict represents a replacement + MATCH/REPLACEMENT. Default `None` metadata (list, optional): Custom metadata to be inserted in the configuration. Default `None` Returns: @@ -439,7 +443,8 @@ def set_correct_prefix(configurations, new_prefix): new_prefix (str): Prefix to be inserted before every path. Returns: - configurations (list): List of configurations with the correct prefix added in the directories and ignore sections. + configurations (list): List of configurations with the correct prefix added in the directories and + ignore sections. """ def inserter(path): @@ -512,7 +517,7 @@ def check_apply_test(apply_to_tags: Set, tags: List): def generate_syscheck_config(): """Generate all possible syscheck configurations with 'check_*', 'report_changes' and 'tags'. - Every configuration is ready to be applied in the tag \. + Every configuration is ready to be applied in the tag directories. """ check_platform = 'check_attrs' if sys.platform == 'win32' else 'check_inode' check_names = ['check_all', 'check_sha1sum', 'check_md5sum', 'check_sha256sum', 'check_size', 'check_owner', @@ -529,7 +534,7 @@ def generate_syscheck_config(): def generate_syscheck_registry_config(): """Generate all possible syscheck configurations with 'check_*', 'report_changes' and 'tags' for Windowsregistries. - Every configuration is ready to be applied in the tag \. + Every configuration is ready to be applied in the tag directories. """ check_names = ['check_all', 'check_sha1sum', 'check_md5sum', 'check_sha256sum', 'check_size', 'check_owner', 'check_group', 'check_perm', 'check_mtime', 'check_type', 'report_changes'] @@ -592,7 +597,7 @@ def local_internal_options_to_dict(local_internal_options): Args: local_internal_options (List of str): A list containing local internal options. """ - dict_local_internal_options= {} + dict_local_internal_options = {} no_comments_options = [line.strip() for line in local_internal_options if not (line.startswith('#') or line == '\n')] for line in no_comments_options: diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index f548a4cd48..78cf771fe8 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -620,12 +620,12 @@ def configure_local_internal_options_module(request): backup_local_internal_options = conf.get_local_internal_options_dict() - logger.error('Configure Local Internal Options: DEBUG - Set local_internal_option to ' + - f"{str(local_internal_options)}") + logger.error('Configure Local Internal Options: DEBUG - Set local_internal_option to ' + + f"{str(local_internal_options)}") conf.set_local_internal_options_dict(local_internal_options) yield - logger.error('Configure Local Internal Options: DEBUG - Restore local_internal_option to ' + - f"{str(backup_local_internal_options)}") + logger.error('Configure Local Internal Options: DEBUG - Restore local_internal_option to ' + + f"{str(backup_local_internal_options)}") conf.set_local_internal_options_dict(backup_local_internal_options) From 87039c12c10a6430991b78dae1796a53496c1600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo?= Date: Mon, 6 Sep 2021 17:15:50 +0200 Subject: [PATCH 08/11] Fix minnor style error in configure local internal options module fixture Logger of local internal option module fixture change to debug level --- tests/integration/conftest.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 78cf771fe8..be7a9df22f 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -604,7 +604,7 @@ def create_file_structure_function(get_files_list): delete_file_structure(get_files_list) -@pytest.fixture(scope="module") +@pytest.fixture(scope='module') def configure_local_internal_options_module(request): """Fixture to configure the local internal options file. @@ -615,17 +615,17 @@ def configure_local_internal_options_module(request): try: local_internal_options = getattr(request.module, 'local_internal_options') except AttributeError as local_internal_configuration_not_set: - logger.error('Configure Local Internal Options: Error - local_internal_options is not set') + logger.debug('Configure Local Internal Options: Error - local_internal_options is not set') raise local_internal_configuration_not_set backup_local_internal_options = conf.get_local_internal_options_dict() - logger.error('Configure Local Internal Options: DEBUG - Set local_internal_option to ' + + logger.debug('Configure Local Internal Options: DEBUG - Set local_internal_option to ' + f"{str(local_internal_options)}") conf.set_local_internal_options_dict(local_internal_options) yield - logger.error('Configure Local Internal Options: DEBUG - Restore local_internal_option to ' + + logger.debug('Configure Local Internal Options: DEBUG - Restore local_internal_option to ' + f"{str(backup_local_internal_options)}") conf.set_local_internal_options_dict(backup_local_internal_options) From b644ff1c9f993e850c9544bacb475f33314ad8cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo?= Date: Mon, 6 Sep 2021 17:45:11 +0200 Subject: [PATCH 09/11] Remove redundant logging messages --- tests/integration/conftest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index be7a9df22f..f28b7aefbc 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -615,17 +615,17 @@ def configure_local_internal_options_module(request): try: local_internal_options = getattr(request.module, 'local_internal_options') except AttributeError as local_internal_configuration_not_set: - logger.debug('Configure Local Internal Options: Error - local_internal_options is not set') + logger.debug('local_internal_options is not set') raise local_internal_configuration_not_set backup_local_internal_options = conf.get_local_internal_options_dict() - logger.debug('Configure Local Internal Options: DEBUG - Set local_internal_option to ' + + logger.debug('Set local_internal_option to ' + f"{str(local_internal_options)}") conf.set_local_internal_options_dict(local_internal_options) yield - logger.debug('Configure Local Internal Options: DEBUG - Restore local_internal_option to ' + + logger.debug('Restore local_internal_option to ' + f"{str(backup_local_internal_options)}") conf.set_local_internal_options_dict(backup_local_internal_options) From 6552d172b81f6796840ec6cd760b7181a2a2c37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo?= Date: Mon, 6 Sep 2021 17:46:39 +0200 Subject: [PATCH 10/11] Refactor fixture --- tests/integration/conftest.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index f28b7aefbc..3746afe726 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -620,12 +620,10 @@ def configure_local_internal_options_module(request): backup_local_internal_options = conf.get_local_internal_options_dict() - logger.debug('Set local_internal_option to ' + - f"{str(local_internal_options)}") + logger.debug(f"Set local_internal_option to {str(local_internal_options)}") conf.set_local_internal_options_dict(local_internal_options) yield - logger.debug('Restore local_internal_option to ' + - f"{str(backup_local_internal_options)}") + logger.debug(f"Restore local_internal_option to {str(backup_local_internal_options)}") conf.set_local_internal_options_dict(backup_local_internal_options) From fefed7dc3a0716dc05fa64267254295afabad666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo?= Date: Tue, 7 Sep 2021 09:11:00 +0200 Subject: [PATCH 11/11] Fix local internal option handler documentation --- tests/integration/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 3746afe726..7bd89b3afe 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -610,7 +610,7 @@ def configure_local_internal_options_module(request): It uses the test variable local_internal_options. This should be a dictionary wich keys and values corresponds to the internal option configuration, For example: - local_internal_options = ['monitord.rotate_log': '0', 'syscheck.debug': '0' ] + local_internal_options = {'monitord.rotate_log': '0', 'syscheck.debug': '0' } """ try: local_internal_options = getattr(request.module, 'local_internal_options')