diff --git a/tests/integration/test_agentd/test_agentd_multi_server.py b/tests/integration/test_agentd/test_agentd_multi_server.py index bce1bba4e1..084de68d5e 100644 --- a/tests/integration/test_agentd/test_agentd_multi_server.py +++ b/tests/integration/test_agentd/test_agentd_multi_server.py @@ -1,7 +1,66 @@ -# 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 - +''' +copyright: 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 + +type: integration + +brief: A Wazuh cluster is a group of Wazuh managers that work together to enhance the availability + and scalability of the service. These tests will check the agent enrollment in a multi-server + environment and how the agent manages the connections to the servers depending on their status. + +tier: 0 + +modules: + - agentd + +components: + - agent + +daemons: + - wazuh-agentd + - wazuh-authd + - wazuh-remoted + +os_platform: + - linux + - windows + +os_version: + - Arch Linux + - Amazon Linux 2 + - Amazon Linux 1 + - CentOS 8 + - CentOS 7 + - CentOS 6 + - Ubuntu Focal + - Ubuntu Bionic + - Ubuntu Xenial + - Ubuntu Trusty + - Debian Buster + - Debian Stretch + - Debian Jessie + - Debian Wheezy + - Red Hat 8 + - Red Hat 7 + - Red Hat 6 + - Windows 10 + - Windows 8 + - Windows 7 + - Windows Server 2019 + - Windows Server 2016 + - Windows Server 2012 + - Windows Server 2003 + - Windows XP + +references: + - https://documentation.wazuh.com/current/user-manual/registering/index.html + +tags: + - enrollment +''' import os import pytest from time import sleep @@ -341,19 +400,67 @@ def wait_until(x, log_str): # @pytest.mark.parametrize('test_case', [case for case in tests]) def test_agentd_multi_server(add_hostnames, configure_authd_server, set_authd_id, clean_keys, configure_environment, get_configuration): - """Check the agent's enrollment and connection to a manager in a multi-server environment. - - Initialize an environment with multiple simulated servers in which the agent is forced to enroll - under different test conditions, verifying the agent's behavior through its log files. - - Args: - add_hostnames (fixture): Adds to the OS hosts file the names and IP's of the test servers. - configure_authd_server (fixture): Initializes multiple simulated remoted connections. - set_authd_id (fixture): Sets the agent id to 101 in authd simulated connection. - clean_keys (fixture): Clears the client.key file used by the simulated remote connections. - configure_environment (fixture): Configure a custom environment for testing. - get_configuration (fixture): Get configurations from the module. - """ + ''' + description: Check the agent's enrollment and connection to a manager in a multi-server environment. + Initialize an environment with multiple simulated servers in which the agent is forced to enroll + under different test conditions, verifying the agent's behavior through its log files. + + wazuh_min_version: 4.2.0 + + parameters: + - add_hostnames: + type: fixture + brief: Adds to the 'hosts' file the names and the IP addresses of the testing servers. + - configure_authd_server: + type: fixture + brief: Initializes a simulated 'wazuh-authd' connection. + - set_authd_id: + type: fixture + brief: Sets the agent id to '101' in the 'wazuh-authd' simulated connection. + - clean_keys: + type: fixture + brief: Clears the 'client.keys' file used by the simulated remote connections. + - configure_environment: + type: fixture + brief: Configure a custom environment for testing. + - get_configuration: + type: fixture + brief: Get configurations from the module. + + assertions: + - Agent without keys. Verify that all servers will refuse the connection to the 'wazuh-remoted' daemon + but will accept enrollment. The agent should try to connect and enroll each of them. + - Agent without keys. Verify that the first server only has enrollment available, and the third server + only has the 'wazuh-remoted' daemon available. The agent should enroll in the first server and + connect to the third one. + - Agent without keys. Verify that the agent should enroll and connect to the first server, and then + the first server will disconnect. The agent should connect to the second server with the same key. + - Agent without keys. Verify that the agent should enroll and connect to the first server, and then + the first server will disconnect. The agent should try to enroll in the first server again, + and then after failure, move to the second server and connect. + - Agent with keys. Verify that the agent should enroll and connect to the last server. + - Agent with keys. Verify that the first server is available, but it disconnects, and the second and + third servers are not responding. The agent on disconnection should try the second and third servers + and go back finally to the first server. + + input_description: An external YAML file (wazuh_conf.yaml) includes configuration settings for the agent. + Different test cases are found in the test module and include parameters for + the environment setup, the requests to be made, and the expected result. + + expected_output: + - r'Requesting a key from server' + - r'Valid key received' + - r'Trying to connect to server' + - r'Connected to the server' + - r'Received message' + - r'Server responded. Releasing lock.' + - r'Unable to connect to' + + tags: + - simulator + - ssl + - keys + ''' log_monitor = FileMonitor(LOG_FILE_PATH) for stage in range(0, len(get_configuration['metadata']['LOG_MONITOR_STR'])): diff --git a/tests/integration/test_agentd/test_agentd_parametrized_reconnections.py b/tests/integration/test_agentd/test_agentd_parametrized_reconnections.py index c2d530e321..15f1c29fa1 100644 --- a/tests/integration/test_agentd/test_agentd_parametrized_reconnections.py +++ b/tests/integration/test_agentd/test_agentd_parametrized_reconnections.py @@ -1,7 +1,67 @@ -# 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 - +''' +copyright: 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 + +type: integration + +brief: The 'wazuh-agentd' program is the client-side daemon that communicates with the server. + The objective is to check how the 'wazuh-agentd' daemon behaves when there are delays + between connection attempts to the 'wazuh-remoted' daemon using TCP and UDP protocols. + The 'wazuh-remoted' program is the server side daemon that communicates with the agents. + +tier: 0 + +modules: + - agentd + +components: + - agent + +daemons: + - wazuh-agentd + - wazuh-authd + - wazuh-remoted + +os_platform: + - linux + - windows + +os_version: + - Arch Linux + - Amazon Linux 2 + - Amazon Linux 1 + - CentOS 8 + - CentOS 7 + - CentOS 6 + - Ubuntu Focal + - Ubuntu Bionic + - Ubuntu Xenial + - Ubuntu Trusty + - Debian Buster + - Debian Stretch + - Debian Jessie + - Debian Wheezy + - Red Hat 8 + - Red Hat 7 + - Red Hat 6 + - Windows 10 + - Windows 8 + - Windows 7 + - Windows Server 2019 + - Windows Server 2016 + - Windows Server 2012 + - Windows Server 2003 + - Windows XP + +references: + - https://documentation.wazuh.com/current/user-manual/registering/index.html + +tags: + - enrollment +''' from datetime import datetime, timedelta import os import platform @@ -256,18 +316,53 @@ def parse_time_from_log_line(log_line): def test_agentd_parametrized_reconnections(configure_authd_server, start_authd, stop_agent, set_keys, configure_environment, get_configuration): - """Check how the agent behaves when there are delays between connection attempts to the server. - - For this purpose, different values for max_retries and retry_interval parameters are tested. - - Args: - configure_authd_server (fixture): Initialize a simulated authd connection. - start_authd (fixture): Enable authd to accept connections and perform enrollments. - stop_agent (fixture): Stop Wazuh's agent. - set_keys (fixture): Write to client.keys file the agent's enrollment details. - configure_environment (fixture): Configure a custom environment for testing. - get_configuration (fixture): Get configurations from the module. - """ + ''' + description: Check how the agent behaves when there are delays between connection + attempts to the server. For this purpose, different values for + 'max_retries' and 'retry_interval' parameters are tested. + + wazuh_min_version: 4.2.0 + + parameters: + - configure_authd_server: + type: fixture + brief: Initializes a simulated 'wazuh-authd' connection. + - start_authd: + type: fixture + brief: Enable the 'wazuh-authd' daemon to accept connections and perform enrollments. + - stop_agent: + type: fixture + brief: Stop Wazuh's agent. + - set_keys: + type: fixture + brief: Write to 'client.keys' file the agent's enrollment details. + - configure_environment: + type: fixture + brief: Configure a custom environment for testing. + - get_configuration: + type: fixture + brief: Get configurations from the module. + + assertions: + - Verify that when the 'wazuh-agentd' daemon initializes, it connects to + the 'wazuh-remoted' daemon of the manager before reaching the maximum number of attempts. + - Verify the successful enrollment of the agent if the auto-enrollment option is enabled. + - Verify that the rollback feature of the server works correctly. + + input_description: An external YAML file (wazuh_conf.yaml) includes configuration settings for the agent. + Different test cases are found in the test module and include parameters + for the environment setup using the TCP and UDP protocols. + + expected_output: + - r'Valid key received' + - r'Trying to connect to server' + - r'Unable to connect to any server' + + tags: + - simulator + - ssl + - keys + ''' DELTA = 1 RECV_TIMEOUT = 5 ENROLLMENT_SLEEP = 20 diff --git a/tests/integration/test_agentd/test_agentd_reconnection.py b/tests/integration/test_agentd/test_agentd_reconnection.py index a9bcf1d6ef..a7e16f17cb 100644 --- a/tests/integration/test_agentd/test_agentd_reconnection.py +++ b/tests/integration/test_agentd/test_agentd_reconnection.py @@ -1,7 +1,67 @@ -# 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 - +''' +copyright: 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 + +type: integration + +brief: The 'wazuh-agentd' program is the client-side daemon that communicates with the server. + The objective is to check that, with different states in the 'clients.keys' file, + the agent successfully enrolls after losing connection with the 'wazuh-remoted' daemon. + The wazuh-remoted program is the server side daemon that communicates with the agents. + +tier: 0 + +modules: + - agentd + +components: + - agent + +daemons: + - wazuh-agentd + - wazuh-authd + - wazuh-remoted + +os_platform: + - linux + - windows + +os_version: + - Arch Linux + - Amazon Linux 2 + - Amazon Linux 1 + - CentOS 8 + - CentOS 7 + - CentOS 6 + - Ubuntu Focal + - Ubuntu Bionic + - Ubuntu Xenial + - Ubuntu Trusty + - Debian Buster + - Debian Stretch + - Debian Jessie + - Debian Wheezy + - Red Hat 8 + - Red Hat 7 + - Red Hat 6 + - Windows 10 + - Windows 8 + - Windows 7 + - Windows Server 2019 + - Windows Server 2016 + - Windows Server 2012 + - Windows Server 2003 + - Windows XP + +references: + - https://documentation.wazuh.com/current/user-manual/registering/index.html + +tags: + - enrollment +''' import os import platform from time import sleep @@ -181,18 +241,41 @@ def search_error_messages(): def test_agentd_reconection_enrollment_with_keys(configure_authd_server, configure_environment, get_configuration): - """Check how the agent behaves when losing communication with remoted and a new enrollment is sent to authd. - - In this case, the agent starts with keys. - - Args: - configure_authd_server (fixture): Initialize a simulated authd connection. - start_authd (fixture): Enable authd to accept connections and perform enrollments. - set_authd_id (fixture): Set agent id to 101 in the authd simulated connection. - set_keys (fixture): Write to client.keys file the agent's enrollment details. - configure_environment (fixture): Configure a custom environment for testing. - get_configuration (fixture): Get configurations from the module. - """ + ''' + description: Check how the agent behaves when losing communication with + the 'wazuh-remoted' daemon and a new enrollment is sent to + the 'wazuh-authd' daemon. + In this case, the agent starts with keys. + + wazuh_min_version: 4.2.0 + + parameters: + - configure_authd_server: + type: fixture + brief: Initializes a simulated wazuh-authd connection. + - configure_environment: + type: fixture + brief: Configure a custom environment for testing. + - get_configuration: + type: fixture + brief: Get configurations from the module. + + assertions: + - Verify that the agent enrollment is successful. + + input_description: An external YAML file (wazuh_conf.yaml) includes configuration settings for the agent. + Two test cases are found in the test module and include parameters + for the environment setup using the TCP and UDP protocols. + + expected_output: + - r'Valid key received' + - r'Sending keep alive' + + tags: + - simulator + - ssl + - keys + ''' global remoted_server remoted_server = RemotedSimulator(protocol=get_configuration['metadata']['PROTOCOL'], mode='CONTROLLED_ACK', @@ -219,7 +302,6 @@ def test_agentd_reconection_enrollment_with_keys(configure_authd_server, configu # Wait until Agent is notifying Manager log_monitor.start(timeout=120, callback=wait_notify, error_message="Notify message from agent was never sent!") - # Start rejecting Agent remoted_server.set_mode('REJECT') # hearing on enrollment server @@ -228,13 +310,13 @@ def test_agentd_reconection_enrollment_with_keys(configure_authd_server, configu log_monitor.start(timeout=180, callback=wait_enrollment, error_message="Agent never enrolled after rejecting connection!") - # Start responding to Agent remoted_server.set_mode('CONTROLLED_ACK') # Wait until Agent is notifying Manager log_monitor.start(timeout=120, callback=wait_notify, error_message="Notify message from agent was never sent!") assert "aes" in remoted_server.last_message_ctx, "Incorrect Secure Message" + """ This test covers the scenario of Agent starting without client.keys file and an enrollment is sent to Authd to start communicating with Remoted @@ -242,18 +324,41 @@ def test_agentd_reconection_enrollment_with_keys(configure_authd_server, configu def test_agentd_reconection_enrollment_no_keys_file(configure_authd_server, configure_environment, get_configuration): - """Check how the agent behaves when losing communication with remoted and a new enrollment is sent to authd. - - In this case, the agent doesn't have client.keys file. - - Args: - configure_authd_server (fixture): Initialize a simulated authd connection. - start_authd (fixture): Enable authd to accept connections and perform enrollments. - set_authd_id (fixture): Set agent id to 101 in the authd simulated connection. - delete_keys (fixture): Remove the agent's client.keys file. - configure_environment (fixture): Configure a custom environment for testing. - get_configuration (fixture): Get configurations from the module. - """ + ''' + description: Check how the agent behaves when losing communication with + the 'wazuh-remoted' daemon and a new enrollment is sent to + the 'wazuh-authd' daemon. + In this case, the agent doesn't have the 'client.keys' file. + + wazuh_min_version: 4.2.0 + + parameters: + - configure_authd_server: + type: fixture + brief: Initializes a simulated 'wazuh-authd' connection. + - configure_environment: + type: fixture + brief: Configure a custom environment for testing. + - get_configuration: + type: fixture + brief: Get configurations from the module. + + assertions: + - Verify that the agent enrollment is successful. + + input_description: An external YAML file (wazuh_conf.yaml) includes configuration settings for the agent. + Two test cases are found in the test module and include parameters + for the environment setup using the TCP and UDP protocols. + + expected_output: + - r'Valid key received' + - r'Sending keep alive' + + tags: + - simulator + - ssl + - keys + ''' global remoted_server remoted_server = RemotedSimulator(protocol=get_configuration['metadata']['PROTOCOL'], mode='CONTROLLED_ACK', @@ -305,18 +410,41 @@ def test_agentd_reconection_enrollment_no_keys_file(configure_authd_server, conf def test_agentd_reconection_enrollment_no_keys(configure_authd_server, configure_environment, get_configuration): - """Check how the agent behaves when losing communication with remoted and a new enrollment is sent to authd. - - In this case, the agent has its client.keys file empty. - - Args: - configure_authd_server (fixture): Initialize a simulated authd connection. - start_authd (fixture): Enable authd to accept connections and perform enrollments. - set_authd_id (fixture): Set agent id to 101 in the authd simulated connection. - clean_keys (fixture): Clear the agent's client.keys file. - configure_environment (fixture): Configure a custom environment for testing. - get_configuration (fixture): Get configurations from the module. - """ + ''' + description: Check how the agent behaves when losing communication with + the 'wazuh-remoted' daemon and a new enrollment is sent to + the 'wazuh-authd' daemon. + In this case, the agent has its 'client.keys' file empty. + + wazuh_min_version: 4.2.0 + + parameters: + - configure_authd_server: + type: fixture + brief: Initializes a simulated 'wazuh-authd' connection. + - configure_environment: + type: fixture + brief: Configure a custom environment for testing. + - get_configuration: + type: fixture + brief: Get configurations from the module. + + assertions: + - Verify that the agent enrollment is successful. + + input_description: An external YAML file (wazuh_conf.yaml) includes configuration settings for the agent. + Two test cases are found in the test module and include parameters + for the environment setup using the TCP and UDP protocols. + + expected_output: + - r'Valid key received' + - r'Sending keep alive' + + tags: + - simulator + - ssl + - keys + ''' global remoted_server remoted_server = RemotedSimulator(protocol=get_configuration['metadata']['PROTOCOL'], mode='CONTROLLED_ACK', @@ -341,7 +469,7 @@ def test_agentd_reconection_enrollment_no_keys(configure_authd_server, configure # Wait until Agent asks keys for the first time log_monitor.start(timeout=120, callback=wait_enrollment, - error_message="Agent never enrolled for the first time rejecting connection!") + error_message="Agent never enrolled for the first time rejecting connection!") # Wait until Agent is notifying Manager log_monitor.start(timeout=120, callback=wait_notify, error_message="Notify message from agent was never sent!") @@ -369,19 +497,42 @@ def test_agentd_reconection_enrollment_no_keys(configure_authd_server, configure def test_agentd_initial_enrollment_retries(configure_authd_server, configure_environment, get_configuration): - """Check how the agent behaves when it makes multiple enrollment attempts before getting its key. - - For this, the agent starts without keys and perform multiple enrollment requests - to authd before getting the new key to communicate with remoted. - - Args: - configure_authd_server (fixture): Initialize a simulated authd connection. - stop_authd (fixture): Disable authd to accept connections and perform enrollments. - set_authd_id (fixture): Set agent id to 101 in the authd simulated connection. - clean_keys (fixture): Clear the agent's client.keys file. - configure_environment (fixture): Configure a custom environment for testing. - get_configuration (fixture): Get configurations from the module. - """ + ''' + description: Check how the agent behaves when it makes multiple enrollment attempts + before getting its key. For this, the agent starts without keys and + performs multiple enrollment requests to the 'wazuh-authd' daemon before + getting the new key to communicate with the 'wazuh-remoted' daemon. + + wazuh_min_version: 4.2.0 + + parameters: + - configure_authd_server: + type: fixture + brief: Initializes a simulated 'wazuh-authd' connection. + - configure_environment: + type: fixture + brief: Configure a custom environment for testing. + - get_configuration: + type: fixture + brief: Get configurations from the module. + + assertions: + - Verify that the agent enrollment is successful. + + input_description: An external YAML file (wazuh_conf.yaml) includes configuration settings for the agent. + Two test cases are found in the test module and include parameters + for the environment setup using the 'TCP' and 'UDP' protocols. + + expected_output: + - r'Requesting a key' + - r'Valid key received' + - r'Sending keep alive' + + tags: + - simulator + - ssl + - keys + ''' global remoted_server remoted_server = RemotedSimulator(protocol=get_configuration['metadata']['PROTOCOL'], mode='CONTROLLED_ACK', @@ -430,6 +581,7 @@ def test_agentd_initial_enrollment_retries(configure_authd_server, configure_env if "Unable to access queue:" in line: raise AssertionError("A Wazuh module stopped because of Agentd initialization!") + """ This test covers and check the scenario of Agent starting with keys but Remoted is not reachable during some seconds and multiple connection retries are required prior to requesting a new enrollment @@ -437,18 +589,40 @@ def test_agentd_initial_enrollment_retries(configure_authd_server, configure_env def test_agentd_connection_retries_pre_enrollment(configure_authd_server, configure_environment, get_configuration): - """Check how the agent behaves when Remoted is not available and performs multiple connection attempts to it. - - For this, the agent starts with keys but Remoted is not available for several seconds, - then the agent performs multiple connection retries before requesting a new enrollment. - - Args: - configure_authd_server (fixture): Initialize a simulated authd connection. - stop_authd (fixture): Disable authd to accept connections and perform enrollments. - set_keys (fixture): Write to client.keys file the agent's enrollment details. - configure_environment (fixture): Configure a custom environment for testing. - get_configuration (fixture): Get configurations from the module. - """ + ''' + description: Check how the agent behaves when the 'wazuh-remoted' daemon is not available + and performs multiple connection attempts to it. For this, the agent starts + with keys but the 'wazuh-remoted' daemon is not available for several seconds, + then the agent performs multiple connection retries before requesting a new enrollment. + + wazuh_min_version: 4.2.0 + + parameters: + - configure_authd_server: + type: fixture + brief: Initializes a simulated 'wazuh-authd' connection. + - configure_environment: + type: fixture + brief: Configure a custom environment for testing. + - get_configuration: + type: fixture + brief: Get configurations from the module. + + assertions: + - Verify that the agent enrollment is successful. + + input_description: An external YAML file (wazuh_conf.yaml) includes configuration settings for the agent. + Two test cases are found in the test module and include parameters + for the environment setup using the TCP and UDP protocols. + + expected_output: + - r'Sending keep alive' + + tags: + - simulator + - ssl + - keys + ''' global remoted_server REMOTED_KEYS_SYNC_TIME = 10 diff --git a/tests/integration/test_agentd/test_agentd_state.py b/tests/integration/test_agentd/test_agentd_state.py index 54e66f74f8..df2787daec 100644 --- a/tests/integration/test_agentd/test_agentd_state.py +++ b/tests/integration/test_agentd/test_agentd_state.py @@ -1,7 +1,65 @@ -# 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 - +''' +copyright: 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 + +type: integration + +brief: The 'wazuh-agentd' program is the client-side daemon that communicates with the server. + These tests will check if the content of the 'wazuh-agentd' daemon statistics file is valid. + The statistics files are documents that show real-time information about the Wazuh environment. + +tier: 0 + +modules: + - agentd + +components: + - agent + +daemons: + - wazuh-agentd + - wazuh-remoted + +os_platform: + - linux + - windows + +os_version: + - Arch Linux + - Amazon Linux 2 + - Amazon Linux 1 + - CentOS 8 + - CentOS 7 + - CentOS 6 + - Ubuntu Focal + - Ubuntu Bionic + - Ubuntu Xenial + - Ubuntu Trusty + - Debian Buster + - Debian Stretch + - Debian Jessie + - Debian Wheezy + - Red Hat 8 + - Red Hat 7 + - Red Hat 6 + - Windows 10 + - Windows 8 + - Windows 7 + - Windows Server 2019 + - Windows Server 2016 + - Windows Server 2012 + - Windows Server 2003 + - Windows XP + +references: + - https://documentation.wazuh.com/current/user-manual/reference/statistics-files/wazuh-agentd-state.html + +tags: + - stats_file +''' import json import os import sys @@ -79,6 +137,33 @@ def add_custom_key(): [test_case['test_case'] for test_case in test_cases], ids=[test_case['name'] for test_case in test_cases]) def test_agentd_state(configure_environment, test_case: list): + ''' + description: Check that the statistics file 'wazuh-agentd.state' is created automatically + and verify that the content of its fields is correct. + + wazuh_min_version: 4.2.0 + + parameters: + - configure_environment: + type: fixture + brief: Configure a custom environment for testing. + - test_case: + type: list + brief: List of tests to be performed. + + assertions: + - Verify that the 'wazuh-agentd.state' statistics file has been created. + - Verify that the information stored in the 'wazuh-agentd.state' statistics file + is consistent with the connection status to the 'wazuh-remoted' daemon. + + input_description: An external YAML file (wazuh_conf.yaml) includes configuration settings for the agent. + Different test cases that are contained in an external YAML file (wazuh_state_tests.yaml) + that includes the parameters and their expected responses. + + expected_output: + - r'pending' + - r'connected' + ''' global remoted_server if remoted_server is not None: remoted_server.stop() diff --git a/tests/integration/test_agentd/test_agentd_state_config.py b/tests/integration/test_agentd/test_agentd_state_config.py index ff5cdf08ce..64426c8fc2 100644 --- a/tests/integration/test_agentd/test_agentd_state_config.py +++ b/tests/integration/test_agentd/test_agentd_state_config.py @@ -1,7 +1,65 @@ -# 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 - +''' +copyright: 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 + +type: integration + +brief: The 'wazuh-agentd' program is the client-side daemon that communicates with the server. + These tests will check if the configuration options related to the statistics file of + the 'wazuh-agentd' daemon are working properly. The statistics files are documents that + show real-time information about the Wazuh environment. + +tier: 0 + +modules: + - agentd + +components: + - agent + +daemons: + - wazuh-agentd + +os_platform: + - linux + - windows + +os_version: + - Arch Linux + - Amazon Linux 2 + - Amazon Linux 1 + - CentOS 8 + - CentOS 7 + - CentOS 6 + - Ubuntu Focal + - Ubuntu Bionic + - Ubuntu Xenial + - Ubuntu Trusty + - Debian Buster + - Debian Stretch + - Debian Jessie + - Debian Wheezy + - Red Hat 8 + - Red Hat 7 + - Red Hat 6 + - Windows 10 + - Windows 8 + - Windows 7 + - Windows Server 2019 + - Windows Server 2016 + - Windows Server 2012 + - Windows Server 2003 + - Windows XP + +references: + - https://documentation.wazuh.com/current/user-manual/reference/statistics-files/wazuh-agentd-state.html + +tags: + - stats_file +''' import os import sys import time @@ -83,7 +141,34 @@ def get_configuration(request): ids=[test_case['name'] for test_case in test_cases]) @pytest.mark.skipif(sys.platform == 'win32', reason="It will be blocked by #1593 and wazuh/wazuh#8746.") def test_agentd_state_config(test_case, set_local_internal_options): - + ''' + description: Check that the 'wazuh-agentd.state' statistics file is created + automatically and verify that it is updated at the set intervals. + + wazuh_min_version: 4.2.0 + + parameters: + - configure_environment: + type: fixture + brief: Configure a custom environment for testing. + - test_case: + type: list + brief: List of tests to be performed. + + assertions: + - Verify that the 'wazuh-agentd.state' statistics file has been created. + - Verify that the 'wazuh-agentd.state' statistics file is updated at the specified intervals. + + input_description: An external YAML file (wazuh_conf.yaml) includes configuration settings for the agent. + Different test cases that are contained in an external YAML file (wazuh_state_config_tests.yaml) + that includes the parameters and their expected responses. + + expected_output: + - r'interval_not_found' + - r'interval_not_valid' + - r'file_enabled' + - r'file_not_enabled' + ''' control_service('stop', 'wazuh-agentd') # Truncate ossec.log in order to watch it correctly