def test_temp_path(self): set_cwd(tempfile.mkdtemp()) cuckoo_create() gm_win = GuestManager("cuckoo1", "1.2.3.4", "windows", 1, None) gm_win.environ["TEMP"] = "C:\Users\user\AppData\Local\Temp" gm_lin = GuestManager("cuckoo1", "1.2.3.4", "linux", 1, None) assert gm_lin.determine_temp_path() == "/tmp" assert gm_win.determine_temp_path() == "C:\Users\user\AppData\Local\Temp"
def test_temp_path(self): set_cwd(tempfile.mkdtemp()) cuckoo_create() gm_win = GuestManager("cuckoo1", "1.2.3.4", "windows", 1, None) gm_win.environ["TEMP"] = "C:\\Users\\user\\AppData\\Local\\Temp" gm_lin = GuestManager("cuckoo1", "1.2.3.4", "linux", 1, None) assert gm_lin.determine_temp_path() == "/tmp" assert gm_win.determine_temp_path() == "C:\\Users\\user\\AppData\\Local\\Temp"
def test_start_analysis_nofile(self): set_cwd(tempfile.mkdtemp()) cuckoo_create() target = mock.MagicMock() target.is_file = False analysis = mock.MagicMock() analysis.status = "starting" gm = GuestManager( "cuckoo1", "1.2.3.4", "windows", 1, None, analysis, target ) gm.wait_available = mock.MagicMock() httpresponse = mock.MagicMock() httpresponse.status_code = 200 httpresponse.json.return_value = { "version": 0.8, "features": ["pinning", "execpy"] } gm.post = mock.MagicMock() gm.get = mock.MagicMock(return_value=httpresponse) gm.query_environ = mock.MagicMock() gm.upload_analyzer = mock.MagicMock() gm.add_config = mock.MagicMock() gm.determine_temp_path = mock.MagicMock(return_value="/tmp/sIYUbJJ") gm.analysis_manager = mock.MagicMock() gm.start_analysis({"timeout": 60, "file_name": "doge"}, None) assert gm.analysis.status == "starting" gm.get.assert_called_with("/pinning") gm.target.helper.get_filepointer.assert_not_called() gm.post.assert_called_once_with("/execpy", data=mock.ANY)