def init_db(schema, test_data_path): with patch('wazuh.core.common.wazuh_uid'), patch('wazuh.core.common.wazuh_gid'): with patch('sqlalchemy.create_engine', return_value=create_engine("sqlite://")): with patch('shutil.chown'), patch('os.chmod'): with patch('api.constants.SECURITY_PATH', new=test_data_path): import wazuh.rbac.orm as orm reload(orm) try: create_memory_db(schema, orm._Session(), test_data_path) except OperationalError: pass
def db_setup(): with patch('wazuh.core.common.wazuh_uid'), patch('wazuh.core.common.wazuh_gid'): with patch('sqlalchemy.create_engine', return_value=create_engine("sqlite://")): with patch('shutil.chown'), patch('os.chmod'): with patch('api.constants.SECURITY_PATH', new=test_data_path): import wazuh.rbac.orm as orm reload(orm) import wazuh.rbac.decorators as decorators from wazuh.tests.util import RBAC_bypasser decorators.expose_resources = RBAC_bypasser from wazuh import security from wazuh.core.results import WazuhResult from wazuh.core import security as core_security try: create_memory_db('schema_security_test.sql', orm._Session()) except OperationalError: pass yield security, WazuhResult, core_security