예제 #1
0
def test_DistributedAPI_check_wazuh_status_exception(node_info_mock, status_value):
    """Test exceptions from `check_wazuh_status` method from class DistributedAPI."""
    statuses = {process: status_value for process in sorted(get_manager_status())}
    with patch('wazuh.core.manager.get_manager_status',
               return_value=statuses):
        dapi = DistributedAPI(f=agent.get_agents_summary_status, logger=logger)
        try:
            dapi.check_wazuh_status()
        except WazuhError as e:
            assert e.code == 1017
            assert statuses
            assert e._extra_message['node_name'] == 'random_node'
            extra_message = ', '.join([f'{key}->{statuses[key]}' for key in dapi.basic_services if key in statuses])
            assert e._extra_message['not_ready_daemons'] == extra_message
예제 #2
0
def test_DistributedAPI_check_wazuh_status(status_mock, api_request):
    """Test `check_wazuh_status` method from class DistributedAPI."""
    dapi = DistributedAPI(f=api_request, logger=logger)
    data = dapi.check_wazuh_status()
    assert data is None