Esempio n. 1
0
 def test034_launch_asynchronous_ftp_error(self,
                                           m_session_transaction,
                                           m_Scan,
                                           m_ftp_ctrl,
                                           m_add_empty_result):
     m_scan, m_session = MagicMock(), MagicMock()
     fw1, fw2 = MagicMock(), MagicMock()
     file1, file2 = MagicMock(), MagicMock()
     pathf1, pathf2 = 'path-file1', 'path-file2'
     file1.path = pathf1
     file2.path = pathf2
     fw1.file.sha256 = "sha256file1"
     fw1.file.mimetype = "mimetypefile1"
     fw2.file.sha256 = "sha256file2"
     fw2.file.mimetype = "mimetypefile2"
     m_scan.files_web = [fw1, fw2]
     m_scan.files = [file1, file2]
     probe1, probe2 = "Probe1", "Probe2"
     probelist = [probe1, probe2]
     m_scan.get_probe_list.return_value = probelist
     m_add_empty_result.return_value = probelist
     m_session_transaction().__enter__.return_value = m_session
     m_scan.status = IrmaScanStatus.ready
     m_scan.mimetype_filtering = False
     m_Scan.load_from_ext_id.return_value = m_scan
     scanid = "scanid"
     m_ftp_ctrl.upload_scan.side_effect = IrmaFtpError()
     module.launch_asynchronous(scanid)
     expected = IrmaScanStatus.error_ftp_upload
     m_scan.set_status.assert_called_once_with(expected)
Esempio n. 2
0
 def test034_launch_asynchronous_ftp_error(self,
                                           m_session_transaction,
                                           m_Scan,
                                           m_ftp_ctrl,
                                           m_add_empty_result):
     m_scan, m_session = MagicMock(), MagicMock()
     fw1, fw2 = MagicMock(), MagicMock()
     file1, file2 = MagicMock(), MagicMock()
     pathf1, pathf2 = 'path-file1', 'path-file2'
     file1.path = pathf1
     file2.path = pathf2
     fw1.file.sha256 = "sha256file1"
     fw1.file.mimetype = "mimetypefile1"
     fw2.file.sha256 = "sha256file2"
     fw2.file.mimetype = "mimetypefile2"
     m_scan.files_web = [fw1, fw2]
     m_scan.files = [file1, file2]
     probe1, probe2 = "Probe1", "Probe2"
     probelist = [probe1, probe2]
     m_scan.get_probe_list.return_value = probelist
     m_add_empty_result.return_value = probelist
     m_session_transaction().__enter__.return_value = m_session
     m_scan.status = IrmaScanStatus.ready
     m_scan.mimetype_filtering = False
     m_Scan.load_from_ext_id.return_value = m_scan
     scanid = "scanid"
     m_ftp_ctrl.upload_scan.side_effect = IrmaFtpError()
     module.launch_asynchronous(scanid)
     expected = IrmaScanStatus.error_ftp_upload
     m_scan.set_status.assert_called_once_with(expected)
Esempio n. 3
0
def scan_launch(scanid):
    try:
        log.debug("scanid: %s", scanid)
        scan_ctrl.launch_asynchronous(scanid)
    except IrmaDatabaseError as e:
        log.exception(e)
        raise scan_launch.retry(countdown=2, max_retries=3, exc=e)
Esempio n. 4
0
def scan_launch(scanid):
    try:
        log.debug("scanid: %s", scanid)
        scan_ctrl.launch_asynchronous(scanid)
    except IrmaDatabaseError as e:
        log.exception(e)
        raise scan_launch.retry(countdown=2, max_retries=3, exc=e)
Esempio n. 5
0
 def test032_launch_asynchronous_nothing_to_do(self, m_session_transaction,
                                               m_Scan):
     m_session, m_scan = MagicMock(), MagicMock()
     m_session_transaction().__enter__.return_value = m_session
     m_scan.status = IrmaScanStatus.ready
     m_Scan.load_from_ext_id.return_value = m_scan
     module.launch_asynchronous("whatever")
     m_scan.set_status.assert_called_once_with(IrmaScanStatus.finished)
Esempio n. 6
0
 def test032_launch_asynchronous_nothing_to_do(self,
                                               m_session_transaction,
                                               m_Scan):
     m_session, m_scan = MagicMock(), MagicMock()
     m_session_transaction().__enter__.return_value = m_session
     m_scan.status = IrmaScanStatus.ready
     m_Scan.load_from_ext_id.return_value = m_scan
     module.launch_asynchronous("whatever")
     m_scan.set_status.assert_called_once_with(IrmaScanStatus.finished)
Esempio n. 7
0
def scan_launch(scanid):
    try:
        scan_ctrl.launch_asynchronous(scanid)
    except IrmaDatabaseError as e:
        print "Exception has occurred:{0}".format(e)
        raise scan_launch.retry(countdown=2, max_retries=3, exc=e)