Skip to content

Commit

Permalink
fix(#5229): Fixing to snake_case
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-akim committed May 2, 2024
1 parent 4f0dbde commit d24b525
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
10 changes: 5 additions & 5 deletions deployability/modules/testing/tests/helpers/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def areAgent_processes_active(agent_params):
return False


def isAgent_port_open(inventory_path):
def is_agent_port_open(inventory_path):
"""
Check if agent port is open
Expand All @@ -430,23 +430,23 @@ def isAgent_port_open(inventory_path):
Returns:
str: Os name.
"""
os_type = HostInformation.get_os_type(agent_params)
os_type = HostInformation.get_os_type(inventory_path)
if os_type == 'linux':
result = ConnectionManager.execute_commands(agent_params, 'ss -t -a -n | grep ":1514" | grep ESTAB')
result = ConnectionManager.execute_commands(inventory_path, 'ss -t -a -n | grep ":1514" | grep ESTAB')
if result.get('success'):
return 'ESTAB' in result.get('output')
else:
return False

elif os_type == 'windows':
result = ConnectionManager.execute_commands(agent_params, 'netstat -ano | Select-String -Pattern "TCP" | Select-String -Pattern "ESTABLISHED" | Select-String -Pattern ":1514"')
result = ConnectionManager.execute_commands(inventory_path, 'netstat -ano | Select-String -Pattern "TCP" | Select-String -Pattern "ESTABLISHED" | Select-String -Pattern ":1514"')
if result.get('success'):
return 'ESTABLISHED' in result.get('output')
else:
return False

elif os_type == 'macos':
result = ConnectionManager.execute_commands(agent_params, 'netstat -an | grep ".1514 " | grep ESTABLISHED')
result = ConnectionManager.execute_commands(inventory_path, 'netstat -an | grep ".1514 " | grep ESTABLISHED')
if result.get('success'):
return 'ESTABLISHED' in result.get('output')
else:
Expand Down
6 changes: 3 additions & 3 deletions deployability/modules/testing/tests/helpers/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def disable_firewall(inventory_path) -> None:

if os_type == 'linux':
commands = ["sudo systemctl stop firewalld", "sudo systemctl disable firewalld"]
if GeneralComponentActions.isComponentActive(inventory_path, 'firewalld'):
if GeneralComponentActions.is_component_active(inventory_path, 'firewalld'):
ConnectionManager.execute_commands(inventory_path, commands)

logger.info(f'Firewall disabled on {HostInformation.get_os_name_and_version_from_inventory(inventory_path)}')
Expand Down Expand Up @@ -801,7 +801,7 @@ def get_component_revision(inventory_path) -> str:
return ConnectionManager.execute_commands(inventory_path, f'{MACOS_WAZUH_CONTROL} info -r').get('output')

@staticmethod
def hasAgentClientKeys(inventory_path) -> bool:
def has_agent_client_keys(inventory_path) -> bool:
"""
Returns the True of False depending if in the component Client.keys exists
Expand All @@ -825,7 +825,7 @@ def hasAgentClientKeys(inventory_path) -> bool:
return HostInformation.file_exists(inventory_path, f'{MACOS_CLIENT_KEYS}')

@staticmethod
def isComponentActive(inventory_path, host_role) -> bool:
def is_component_active(inventory_path, host_role) -> bool:
"""
Returns the True of False depending if the component is Active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def setup_test_environment(wazuh_params):
updated_agents = {}
for agent_name, agent_params in wazuh_params['agents'].items():
Utils.check_inventory_connection(agent_params)
if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params):
if GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent') and GeneralComponentActions.has_agent_client_keys(agent_params):
if HostInformation.get_client_keys(agent_params) != []:
client_name = HostInformation.get_client_keys(agent_params)[0]['name']
updated_agents[client_name] = agent_params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def setup_test_environment(wazuh_params):
updated_agents = {}
for agent_name, agent_params in wazuh_params['agents'].items():
Utils.check_inventory_connection(agent_params)
if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params):
if GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent') and GeneralComponentActions.has_agent_client_keys(agent_params):
if HostInformation.get_client_keys(agent_params) != []:
client_name = HostInformation.get_client_keys(agent_params)[0]['name']
updated_agents[client_name] = agent_params
Expand Down Expand Up @@ -81,20 +81,20 @@ def test_status(wazuh_params):
def test_service(wazuh_params):
wazuh_api = WazuhAPI(wazuh_params['master'])
for agent_names, agent_params in wazuh_params['agents'].items():
assert GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not active by API')
assert GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not active by API')

expected_condition_func = lambda: 'active' == WazuhAgent.get_agent_status(wazuh_api, agent_names)
Waits.dynamic_wait(expected_condition_func, cycles=20, waiting_time=30)


def test_clientKeys(wazuh_params):
for agent_names, agent_params in wazuh_params['agents'].items():
assert GeneralComponentActions.hasAgentClientKeys(agent_params), logger.error(f'{agent_names} has not ClientKeys file')
assert GeneralComponentActions.has_agent_client_keys(agent_params), logger.error(f'{agent_names} has not ClientKeys file')


def test_port(wazuh_params):
for _, agent_params in wazuh_params['agents'].items():
assert WazuhAgent.isAgent_port_open(agent_params), logger.error('Port is closed')
assert WazuhAgent.is_agent_port_open(agent_params), logger.error('Port is closed')


def test_processes(wazuh_params):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def setup_test_environment(wazuh_params):
updated_agents = {}
for agent_name, agent_params in wazuh_params['agents'].items():
Utils.check_inventory_connection(agent_params)
if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params):
if GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent') and GeneralComponentActions.has_agent_client_keys(agent_params):
if HostInformation.get_client_keys(agent_params) != []:
client_name = HostInformation.get_client_keys(agent_params)[0]['name']
updated_agents[client_name] = agent_params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def setup_test_environment(wazuh_params):
updated_agents = {}
for agent_name, agent_params in wazuh_params['agents'].items():
Utils.check_inventory_connection(agent_params)
if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params):
if GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent') and GeneralComponentActions.has_agent_client_keys(agent_params):
if HostInformation.get_client_keys(agent_params) != []:
client_name = HostInformation.get_client_keys(agent_params)[0]['name']
updated_agents[client_name] = agent_params
Expand All @@ -75,7 +75,7 @@ def test_status(wazuh_params):
def test_service(wazuh_params):
wazuh_api = WazuhAPI(wazuh_params['master'])
for agent_names, agent_params in wazuh_params['agents'].items():
assert GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not active by command')
assert GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not active by command')

expected_condition_func = lambda: 'active' == WazuhAgent.get_agent_status(wazuh_api, agent_names)
Waits.dynamic_wait(expected_condition_func, cycles=20, waiting_time=30)
Expand All @@ -89,4 +89,4 @@ def test_connection(wazuh_params):

def test_clientKeys(wazuh_params):
for agent_names, agent_params in wazuh_params['agents'].items():
assert GeneralComponentActions.hasAgentClientKeys(agent_params), logger.error(f'{agent_names} has not ClientKeys file')
assert GeneralComponentActions.has_agent_client_keys(agent_params), logger.error(f'{agent_names} has not ClientKeys file')
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def setup_test_environment(wazuh_params):
updated_agents = {}
for agent_name, agent_params in wazuh_params['agents'].items():
Utils.check_inventory_connection(agent_params)
if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params):
if GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent') and GeneralComponentActions.has_agent_client_keys(agent_params):
if HostInformation.get_client_keys(agent_params) != []:
client_name = HostInformation.get_client_keys(agent_params)[0]['name']
updated_agents[client_name] = agent_params
Expand Down Expand Up @@ -81,17 +81,17 @@ def test_connection(wazuh_params):

def test_isActive(wazuh_params):
for agent_names, agent_params in wazuh_params['agents'].items():
assert GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not active by command')
assert GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not active by command')


def test_clientKeys(wazuh_params):
for agent_names, agent_params in wazuh_params['agents'].items():
assert GeneralComponentActions.hasAgentClientKeys(agent_params), logger.error(f'{agent_names} has not ClientKeys file')
assert GeneralComponentActions.has_agent_client_keys(agent_params), logger.error(f'{agent_names} has not ClientKeys file')


def test_port(wazuh_params):
for _, agent_params in wazuh_params['agents'].items():
assert WazuhAgent.isAgent_port_open(agent_params), logger.error('Port is closed')
assert WazuhAgent.is_agent_port_open(agent_params), logger.error('Port is closed')


def test_processes(wazuh_params):
Expand Down
4 changes: 2 additions & 2 deletions deployability/modules/testing/tests/test_agent/test_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def setup_test_environment(wazuh_params):
updated_agents = {}
for agent_name, agent_params in wazuh_params['agents'].items():
Utils.check_inventory_connection(agent_params)
if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params):
if GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent') and GeneralComponentActions.has_agent_client_keys(agent_params):
if HostInformation.get_client_keys(agent_params) != []:
client_name = HostInformation.get_client_keys(agent_params)[0]['name']
updated_agents[client_name] = agent_params
Expand All @@ -82,7 +82,7 @@ def test_service(wazuh_params):

def test_port(wazuh_params):
for _, agent_params in wazuh_params['agents'].items():
assert not WazuhAgent.isAgent_port_open(agent_params), logger.error('Port is still opened')
assert not WazuhAgent.is_agent_port_open(agent_params), logger.error('Port is still opened')


def test_processes(wazuh_params):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def setup_test_environment(wazuh_params):
updated_agents = {}
for agent_name, agent_params in wazuh_params['agents'].items():
Utils.check_inventory_connection(agent_params)
if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params):
if GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent') and GeneralComponentActions.has_agent_client_keys(agent_params):
if HostInformation.get_client_keys(agent_params) != []:
client_name = HostInformation.get_client_keys(agent_params)[0]['name']
updated_agents[client_name] = agent_params
Expand All @@ -65,7 +65,7 @@ def setup_test_environment(wazuh_params):

def test_uninstall(wazuh_params):
for agent_names, agent_params in wazuh_params['agents'].items():
assert GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not Active before the installation')
assert GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not Active before the installation')

os_type = HostInformation.get_os_type(agent_params)
if os_type == 'linux':
Expand Down Expand Up @@ -103,15 +103,15 @@ def test_agent_uninstalled_directory(wazuh_params):
def test_service(wazuh_params):
wazuh_api = WazuhAPI(wazuh_params['master'])
for agent_names, agent_params in wazuh_params['agents'].items():
assert not GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not inactive by command')
assert not GeneralComponentActions.is_component_active(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not inactive 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_params in wazuh_params['agents'].items():
assert not WazuhAgent.isAgent_port_open(agent_params), logger.error('Port is still opened')
assert not WazuhAgent.is_agent_port_open(agent_params), logger.error('Port is still opened')


def test_processes(wazuh_params):
Expand Down

0 comments on commit d24b525

Please sign in to comment.