Skip to content

Commit

Permalink
fix(#5229): Fixing basic_info validations
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-akim committed Apr 29, 2024
1 parent 7490c95 commit e07fb3f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion deployability/modules/testing/tests/helpers/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def register_agent(inventory_path, manager_path):
raise Exception(f'Error registering agent. Error executing: {commands} with error: {e}')

result = ConnectionManager.execute_commands(inventory_path, f'cat {WAZUH_CONF}')
assert host_ip in result.get('output'), logger.error(f'Error configuring the Manager IP ({host_ip}) in: {HostInformation.get_os_name_and_version_from_inventory(inventory_path)} agent')
assert host_ip in result, logger.error(f'Error configuring the Manager IP ({host_ip}) in: {HostInformation.get_os_name_and_version_from_inventory(inventory_path)} agent')

elif os_type == 'windows':
try:
Expand Down
22 changes: 8 additions & 14 deletions deployability/modules/testing/tests/helpers/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,14 @@ def get_os_name_and_version_from_inventory(inventory_path) -> tuple:
def get_os_version_from_inventory(inventory_path) -> str:
os_type = HostInformation.get_os_type(inventory_path)

if os_type == 'linux':
if 'manager' in inventory_path:
os_version = re.search(r".*?/manager-.*?-.*?-(.*?)-.*?/inventory.yaml", inventory_path).group(1)
elif 'agent' in inventory_path:
os_version = re.search(r".*?/agent-.*?-.*?-(.*?)-.*?/inventory.yaml", inventory_path).group(1)
return os_version
else:
return None
elif os_type == 'windows':
if 'agent' in inventory_path:
os_version = re.search(r".*?/agent-.*?-.*?-(.*?)-.*?/inventory.yaml", inventory_path)[1:3]
return os_version
else:
return None
if 'manager' in inventory_path:
os_version = re.search(r".*?/manager-.*?-.*?-(.*?)-.*?/inventory.yaml", inventory_path).group(1)
elif 'agent' in inventory_path:
os_version = re.search(r".*?/agent-.*?-.*?-(.*?)-.*?/inventory.yaml", inventory_path).group(1)
return os_version
else:
return None


@staticmethod
def get_current_dir(inventory_path) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ def test_wazuh_os_version(wazuh_params):
if not os_type == 'windows':
assert HostInformation.get_os_version_from_inventory(agent_params) in WazuhAgent.get_agent_os_version_by_name(wazuh_api, agent_names), logger.error('There is a mismatch between the OS version and the OS version of the installed agent')
if os_type == 'linux':
assert HostInformation.get_os_name_from_inventory(agent_params) 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')
os_name = HostInformation.get_os_name_from_inventory(agent_params)
elif os_type == 'macos':
assert 'macos' 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')
os_name = 'macos'
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():
Expand Down

0 comments on commit e07fb3f

Please sign in to comment.