-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
47 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,13 @@ | |
# Created by Wazuh, Inc. <[email protected]>. | ||
# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
import pytest | ||
import re | ||
import pytest | ||
|
||
from modules.testing.utils import logger | ||
from ..helpers.agent import WazuhAgent, WazuhAPI | ||
from ..helpers.constants import WAZUH_ROOT, WINDOWS_ROOT_DIR, MACOS_ROOT_DIR | ||
from ..helpers.generic import HostInformation, GeneralComponentActions, Waits | ||
from modules.testing.utils import logger | ||
from ..helpers.manager import WazuhManager | ||
from ..helpers.utils import Utils | ||
|
||
|
||
|
@@ -95,10 +94,10 @@ def test_wazuh_os_version(wazuh_params): | |
assert os_name in WazuhAgent.get_agent_os_name_by_name(wazuh_api, agent_names).replace(' ', ''), logger.error('There is a mismatch between the OS name and the OS name of the installed agent') | ||
|
||
def test_wazuh_version(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
assert wazuh_params['wazuh_version'] in GeneralComponentActions.get_component_version(agent_params), logger.error(f"The version {HostInformation.get_os_name_and_version_from_inventory(agent_params)} is not {wazuh_params['wazuh_version']} by command") | ||
|
||
|
||
def test_wazuh_revision(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
assert wazuh_params['wazuh_revision'] in GeneralComponentActions.get_component_revision(agent_params), logger.error(f"The revision {HostInformation.get_os_name_and_version_from_inventory(agent_params)} is not {wazuh_params['wazuh_revision']} by command") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
# Created by Wazuh, Inc. <[email protected]>. | ||
# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
import pytest | ||
import re | ||
import pytest | ||
|
||
from modules.testing.utils import logger | ||
from ..helpers.agent import WazuhAgent, WazuhAPI | ||
from ..helpers.generic import HostInformation, GeneralComponentActions, Waits | ||
from ..helpers.manager import WazuhManager, WazuhAPI | ||
from modules.testing.utils import logger | ||
from ..helpers.utils import Utils | ||
|
||
|
||
|
@@ -74,7 +74,8 @@ def test_connection(wazuh_params): | |
def test_status(wazuh_params): | ||
for agent in wazuh_params['agents'].values(): | ||
status = GeneralComponentActions.get_component_status(agent, 'wazuh-agent') | ||
assert 'active' in status or 'connected' in status or "Running" in status or "is running" in status, logger.error(f'The {HostInformation.get_os_name_and_version_from_inventory(agent)} is not active') | ||
valid_statuses = ['active', 'connected', 'Running', 'is running'] | ||
assert any(valid_status in status for valid_status in valid_statuses), logger.error(f'The {HostInformation.get_os_name_and_version_from_inventory(agent)} is not active') | ||
|
||
|
||
def test_service(wazuh_params): | ||
|
@@ -92,10 +93,10 @@ def test_clientKeys(wazuh_params): | |
|
||
|
||
def test_port(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
assert WazuhAgent.isAgent_port_open(agent_params), logger.error('Port is closed') | ||
|
||
|
||
def test_processes(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
assert WazuhAgent.areAgent_processes_active(agent_params), logger.error('Agent processes are not active') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
# Created by Wazuh, Inc. <[email protected]>. | ||
# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
import pytest | ||
import re | ||
import pytest | ||
|
||
from modules.testing.utils import logger | ||
from ..helpers.agent import WazuhAgent | ||
from ..helpers.constants import WAZUH_ROOT, WINDOWS_ROOT_DIR, MACOS_ROOT_DIR | ||
from ..helpers.generic import HostConfiguration, HostInformation, GeneralComponentActions | ||
from modules.testing.utils import logger | ||
from ..helpers.manager import WazuhManager | ||
from ..helpers.utils import Utils | ||
|
||
|
@@ -64,7 +64,7 @@ def setup_test_environment(wazuh_params): | |
|
||
def test_installation(wazuh_params): | ||
# Checking connection | ||
for manager_name, manager_params in wazuh_params['managers'].items(): | ||
for _, manager_params in wazuh_params['managers'].items(): | ||
Utils.check_inventory_connection(manager_params) | ||
|
||
# Certs creation, firewall management and Manager installation | ||
|
@@ -99,4 +99,5 @@ def test_installation(wazuh_params): | |
def test_status(wazuh_params): | ||
for agent in wazuh_params['agents'].values(): | ||
agent_status = GeneralComponentActions.get_component_status(agent, 'wazuh-agent') | ||
assert 'loaded' in agent_status or 'Stopped' in agent_status or 'not running' in agent_status, logger.error(f'The {HostInformation.get_os_name_and_version_from_inventory(agent)} status is not loaded') | ||
valid_statuses = ['loaded', 'Stopped', 'not running'] | ||
assert any(valid_status in agent_status for valid_status in valid_statuses), logger.error(f'The {HostInformation.get_os_name_and_version_from_inventory(agent)} status is not loaded') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
# Created by Wazuh, Inc. <[email protected]>. | ||
# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
import pytest | ||
import re | ||
import pytest | ||
|
||
from modules.testing.utils import logger | ||
from ..helpers.agent import WazuhAgent, WazuhAPI | ||
from ..helpers.generic import HostInformation, GeneralComponentActions, Waits | ||
from ..helpers.manager import WazuhManager, WazuhAPI | ||
from modules.testing.utils import logger | ||
from ..helpers.utils import Utils | ||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
|
@@ -65,7 +65,7 @@ def setup_test_environment(wazuh_params): | |
|
||
|
||
def test_status(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
WazuhAgent.register_agent(agent_params, wazuh_params['master']) | ||
for agent in wazuh_params['agents'].values(): | ||
status = GeneralComponentActions.get_component_status(agent, 'wazuh-agent') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,12 @@ | |
# Created by Wazuh, Inc. <[email protected]>. | ||
# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
import pytest | ||
import re | ||
import pytest | ||
|
||
from modules.testing.utils import logger | ||
from ..helpers.agent import WazuhAgent | ||
from ..helpers.generic import GeneralComponentActions, HostInformation | ||
from modules.testing.utils import logger | ||
from ..helpers.manager import WazuhManager | ||
from ..helpers.utils import Utils | ||
|
||
|
@@ -63,14 +63,15 @@ def setup_test_environment(wazuh_params): | |
wazuh_params['agents'] = updated_agents | ||
|
||
def test_restart(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
GeneralComponentActions.component_restart(agent_params, 'wazuh-agent') | ||
|
||
|
||
def test_status(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
status = GeneralComponentActions.get_component_status(agent_params, 'wazuh-agent') | ||
assert 'active' in status or 'Running' in status or 'is running' in status, logger.error(f'{agent_names} is not active by command') | ||
valid_statuses = ['active', 'Running', 'is running'] | ||
assert any(valid_status in status for valid_status in valid_statuses), logger.error(f'{agent_names} is not active by command') | ||
|
||
def test_connection(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
|
@@ -88,10 +89,10 @@ def test_clientKeys(wazuh_params): | |
|
||
|
||
def test_port(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
assert WazuhAgent.isAgent_port_open(agent_params), logger.error('Port is closed') | ||
|
||
|
||
def test_processes(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
assert WazuhAgent.areAgent_processes_active(agent_params), logger.error('Agent processes are not active') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,12 @@ | |
# Created by Wazuh, Inc. <[email protected]>. | ||
# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
import pytest | ||
import re | ||
import pytest | ||
|
||
from modules.testing.utils import logger | ||
from ..helpers.agent import WazuhAgent, WazuhAPI | ||
from ..helpers.generic import GeneralComponentActions, Waits, HostInformation | ||
from modules.testing.utils import logger | ||
from ..helpers.utils import Utils | ||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
|
@@ -72,17 +72,18 @@ def test_service(wazuh_params): | |
|
||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
status = GeneralComponentActions.get_component_status(agent_params, 'wazuh-agent') | ||
assert 'inactive' in status or 'Stopped' in status or 'StopPending' in status or 'not running' in status, logger.error(f'{agent_names} is still active by command') | ||
valid_statuses = ['inactive', 'Stopped', 'StopPending', 'not running'] | ||
assert any(valid_status in status for valid_status in valid_statuses), logger.error(f'{agent_names} is still active by command') | ||
|
||
expected_condition_func = lambda: 'disconnected' == WazuhAgent.get_agent_status(wazuh_api, agent_names) | ||
Waits.dynamic_wait(expected_condition_func, cycles=20, waiting_time=30) | ||
|
||
|
||
def test_port(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
assert not WazuhAgent.isAgent_port_open(agent_params), logger.error('Port is still opened') | ||
|
||
|
||
def test_processes(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
assert not WazuhAgent.areAgent_processes_active(agent_params), logger.error('Agent processes are still active') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,14 @@ | |
# Created by Wazuh, Inc. <[email protected]>. | ||
# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
import pytest | ||
import re | ||
import pytest | ||
|
||
from modules.testing.utils import logger | ||
from ..helpers.agent import WazuhAgent | ||
from ..helpers.constants import WAZUH_ROOT, WINDOWS_CONFIGURATIONS_DIR, WINDOWS_ROOT_DIR, MACOS_ROOT_DIR, MACOS_CONFIGURATIONS_DIR | ||
from ..helpers.generic import HostInformation, GeneralComponentActions, Waits | ||
from ..helpers.manager import WazuhManager, WazuhAPI | ||
from modules.testing.utils import logger | ||
from ..helpers.utils import Utils | ||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
|
@@ -109,10 +109,10 @@ def test_service(wazuh_params): | |
|
||
|
||
def test_port(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
assert not WazuhAgent.isAgent_port_open(agent_params), logger.error('Port is still opened') | ||
|
||
|
||
def test_processes(wazuh_params): | ||
for agent_names, agent_params in wazuh_params['agents'].items(): | ||
for _, agent_params in wazuh_params['agents'].items(): | ||
assert not WazuhAgent.areAgent_processes_active(agent_params), logger.error('Agent processes are still active') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters