def test_cfs_config_init_error(caplog): Global.load_config("./configs/default_config.ini") caplog.clear() with patch.object(Global.config, 'get') as mock_config: mock_config.side_effect = Exception("Mock Error") cfs_config = CfsConfig("cfs") assert cfs_config.get_error_count() > 0
def test_set_logger_options_from_config(): Global.load_config('./configs/default_config.ini') with patch('os.makedirs') as mock_makedir: with patch('time.localtime', MagicMock(return_value=time.gmtime(0))): logger.set_logger_options_from_config(Global.config) assert Global.CTF_log_dir == os.path.abspath('./CTF_Results') assert Global.test_log_dir == os.path.abspath('./CTF_Results/Run_01_01_1970_00_00_00') assert Global.CTF_log_dir_file == os.path.abspath('./CTF_Results/Run_01_01_1970_00_00_00/CTF_Log_File.log') mock_makedir.assert_called_with(Global.test_log_dir)
def test_ctf_global_load_config_invalid(): # trigger exit call if config files do not exist with patch('lib.ctf_global.sys.exit', side_effect=Exception('mock exit')): with pytest.raises(Exception): Global.load_config('') assert not Global.config
def test_ctf_global_load_config(): status = Global.load_config("configs/default_config.ini") assert status assert Global.config assert os.environ['workspace_dir'] == '~/sample_cfs_workspace'
def init_global(): Global.load_config("./configs/default_config.ini")
def init_global(): Global.load_config("./configs/default_config.ini") Global.set_time_manager(Mock())
def init_global(): Global.load_config("./configs/default_config.ini") # Global.plugin_manager is set by PluginManager constructor PluginManager(['plugins'])
def init_global(): Global.load_config('./configs/default_config.ini') time_mgr = MagicMock() time_mgr.exec_time = 1.0 Global.time_manager = time_mgr Global.current_script_log_dir = '.'
def test_cfs_config_init_invalid(caplog): Global.load_config("./configs/default_config.ini") caplog.clear() cfs_config = CfsConfig("invalid") assert cfs_config.get_error_count() == 1
def remote_cfs_config(): Global.load_config("./configs/example_configs/cfe_6_7_config_examples.ini") return RemoteCfsConfig("local_ssh")
def cfs_config(): Global.load_config("./configs/default_config.ini") return CfsConfig("cfs")
def init_global(): from lib.ctf_global import Global from lib.logger import set_logger_options_from_config Global.load_config("./configs/default_config.ini") with patch('os.makedirs'): set_logger_options_from_config(Global.config)
def init_global(): Global.load_config("./configs/default_config.ini") Global.time_manager = Mock() # Global.plugin_manager is set by PluginManager constructor : Global.plugin_manager = self PluginManager(['plugins'])