diff --git a/deployability/modules/testing/tests/helpers/agent.py b/deployability/modules/testing/tests/helpers/agent.py index 953c6feb5d..dba94e1ac0 100644 --- a/deployability/modules/testing/tests/helpers/agent.py +++ b/deployability/modules/testing/tests/helpers/agent.py @@ -144,7 +144,7 @@ def uninstall_agent(inventory_path, wazuh_version=None, wazuh_revision=None) -> "/usr/bin/dscl . -delete '/Groups/wazuh'", "/usr/sbin/pkgutil --forget com.wazuh.pkg.wazuh-agent" ]) - print(commands) + Executor.execute_commands(inventory_path, commands) @@ -165,8 +165,10 @@ def get_agents_information(wazuh_api: WazuhAPI) -> list: List: Information about agents. """ response = requests.get(f"{wazuh_api.api_url}/agents", headers=wazuh_api.headers, verify=False) + return eval(response.text)['data']['affected_items'] + def get_agent_status(wazuh_api: WazuhAPI, agent_name) -> str: """ Function to get the status of an agent given its name. @@ -182,6 +184,7 @@ def get_agent_status(wazuh_api: WazuhAPI, agent_name) -> str: for agent in eval(response.text)['data']['affected_items']: if agent.get('name') == agent_name: return agent.get('status') + return None @@ -198,7 +201,9 @@ def get_agent_ip_status_and_name_by_id(wazuh_api: WazuhAPI, identifier): agents_information = wazuh_api.get_agents_information() for element in agents_information: if element['id'] == identifier: + return [element['ip'], element['name'], element['status']] + return [None, None, None] @@ -214,6 +219,7 @@ def add_agent_to_manager(wazuh_api: WazuhAPI, name, ip) -> str: str: Response text. """ response = requests.post(f"{wazuh_api.api_url}/agents", json={"name": name ,"ip": ip}, headers=wazuh_api.headers, verify=False) + return response.text @@ -225,6 +231,7 @@ def restart_agents(wazuh_api: WazuhAPI) -> str: str: Response text. """ response = requests.put(f"{wazuh_api.api_url}/agents/restart", headers=wazuh_api.headers, verify=False) + return response.text @@ -236,4 +243,5 @@ def agent_status_report(wazuh_api: WazuhAPI) -> dict: Dict: Agent status report. """ response = requests.get(f"{wazuh_api.api_url}/agents/summary/status", headers=wazuh_api.headers, verify=False) + return eval(response.text)['data']