Esempio n. 1
0
def delete_list_file(filename):
    """Delete a CDB list file.

    Parameters
    ----------
    filename : list
        Destination path of the new file.

    Returns
    -------
    result : AffectedItemsWazuhResult
        Confirmation message.
    """
    result = AffectedItemsWazuhResult(all_msg='CDB list file was successfully deleted',
                                      none_msg='Could not delete CDB list file')
    full_path = join(common.user_lists_path, filename[0])

    try:
        delete_list(to_relative_path(full_path))
        result.affected_items.append(to_relative_path(full_path))
    except WazuhError as e:
        result.add_failed_item(id_=to_relative_path(full_path), error=e)
    result.total_affected_items = len(result.affected_items)

    return result
Esempio n. 2
0
def test_delete_list(mock_delete_wazuh_file, mock_remove):
    """Check that delete_list function uses expected params."""
    path = 'etc/list/test_list'
    delete_list(path)
    mock_delete_wazuh_file.assert_called_once_with(
        os.path.join(common.wazuh_path, path))
    mock_remove.assert_called_once_with(
        os.path.join(common.wazuh_path, path + '.cdb'))