Skip to content

Commit

Permalink
feat(#3786): new fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Deblintrake09 committed Jul 3, 2023
1 parent 9c3c4c7 commit 2d00264
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from wazuh_testing.logcollector import create_file_structure, delete_file_structure
from wazuh_testing.tools import (PREFIX, LOG_FILE_PATH, WAZUH_CONF, get_service, ALERT_FILE_PATH,
WAZUH_LOCAL_INTERNAL_OPTIONS)
from wazuh_testing.tools.configuration import get_minimal_configuration, get_wazuh_conf, write_wazuh_conf
from wazuh_testing.tools.file import copy, recursive_directory_creation, remove_file, truncate_file, write_file
from wazuh_testing.tools.file import (truncate_file, recursive_directory_creation, remove_file, copy, write_file,
delete_path_recursively)
from wazuh_testing.tools.monitoring import FileMonitor, QueueMonitor, SocketController, close_sockets
from wazuh_testing.tools.services import check_daemon_status, control_service, delete_dbs
from wazuh_testing.tools.time import TimeMachine
Expand Down Expand Up @@ -1248,6 +1248,22 @@ def copy_file(source_path, destination_path):
remove_file(file)


@pytest.fixture()
def create_files_in_folder(folder_path, file_list):
"""Create a list of files, inside a given path. Deletes it at the end.
Args:
folder_path (str): folder path to create.
file_list (List): list of file names to create
"""
recursive_directory_creation(folder_path)
for file in file_list:
write_file(os.path.join(folder_path, file))

yield

delete_path_recursively(folder_path)


@pytest.fixture(scope='function')
def create_file(new_file_path):
"""Create an empty file.
Expand All @@ -1266,18 +1282,18 @@ def create_file(new_file_path):
def load_wazuh_basic_configuration():
"""Load a new basic configuration to the manager"""
# Load ossec.conf with all disabled settings
minimal_configuration = get_minimal_configuration()
minimal_configuration = conf.get_minimal_configuration()

# Make a backup from current configuration
backup_ossec_configuration = get_wazuh_conf()
backup_ossec_configuration = conf.get_wazuh_conf()

# Write new configuration
write_wazuh_conf(minimal_configuration)
conf.write_wazuh_conf(minimal_configuration)

yield

# Restore the ossec.conf backup
write_wazuh_conf(backup_ossec_configuration)
conf.write_wazuh_conf(backup_ossec_configuration)


@pytest.fixture(scope='function')
Expand Down

0 comments on commit 2d00264

Please sign in to comment.