def test002_probe_list_raise_core(self, m_sync_call):
     expected = "no probe available"
     m_sync_call.return_value = (IrmaReturnCode.success, list())
     with self.assertRaises(IrmaCoreError) as context:
         module.probe_list()
     self.assertEqual(str(context.exception), expected)
     m_sync_call.assert_called_once()
 def test002_probe_list_raise_core(self, m_sync_call):
     expected = "no probe available"
     m_sync_call.return_value = (IrmaReturnCode.success, list())
     with self.assertRaises(IrmaCoreError) as context:
         module.probe_list()
     self.assertEqual(str(context.exception), expected)
     m_sync_call.assert_called_once()
 def test001_probe_list_raise_task(self, m_sync_call):
     expected = "test"
     m_sync_call.return_value = (IrmaReturnCode.error, expected)
     with self.assertRaises(IrmaTaskError) as context:
         module.probe_list()
     self.assertEqual(str(context.exception), expected)
     m_sync_call.assert_called_once()
 def test001_probe_list_raise_task(self, m_sync_call):
     expected = "test"
     m_sync_call.return_value = (IrmaReturnCode.error, expected)
     with self.assertRaises(IrmaTaskError) as context:
         module.probe_list()
     self.assertEqual(str(context.exception), expected)
     m_sync_call.assert_called_once()
 def test002_probe_list_raise_core(self):
     expected = "no probe available"
     with patch("frontend.controllers.braintasks.sync_call") as mock:
         mock.return_value = (IrmaReturnCode.success, list())
         with self.assertRaises(IrmaCoreError) as context:
             module.probe_list()
     self.assertEqual(str(context.exception), expected)
 def test001_probe_list_raise_task(self):
     expected = "test"
     with patch("frontend.controllers.braintasks.sync_call") as mock:
         mock.return_value = (IrmaReturnCode.error, expected)
         with self.assertRaises(IrmaTaskError) as context:
             module.probe_list()
     self.assertEqual(str(context.exception), expected)
示例#7
0
def check_probe(scan, probelist, session):
    """ check_probe specified scan

    :param scanid: id returned by scan_new
    :rtype: dict of 'code': int, 'msg': str [, optional 'probe_list':list]
    :return:
        on success 'probe_list' is the list of probes used for the scan
        on error 'msg' gives reason message
    :raise: IrmaDataBaseError, IrmaValueError
    """
    IrmaScanStatus.filter_status(scan.status, IrmaScanStatus.ready,
                                 IrmaScanStatus.ready)
    all_probe_list = celery_brain.probe_list()

    if probelist is not None:
        unknown_probes = []
        for p in probelist:
            if p not in all_probe_list:
                unknown_probes.append(p)
        if len(unknown_probes) != 0:
            reason = "probe {0} unknown".format(", ".join(unknown_probes))
            raise IrmaValueError(reason)
    else:
        probelist = all_probe_list
    log.debug("scanid: %s probelist: %s", scan.external_id, probelist)
    scan.set_probelist(probelist)
    session.commit()
示例#8
0
def list():
    """ get active probe list. This list is used to launch a scan.
    """
    try:
        probelist = celery_brain.probe_list()
        log.debug("probe list: %s", "-".join(probelist))
        response.content_type = "application/json; charset=UTF-8"
        return {"total": len(probelist), "data": probelist}
    except Exception as e:
        log.exception(e)
        process_error(e)
示例#9
0
def list():
    """ get active probe list. This list is used to launch a scan.
    """
    try:
        probelist = celery_brain.probe_list()

        response.content_type = "application/json; charset=UTF-8"
        return {
            "total": len(probelist),
            "data": probelist
        }
    except Exception as e:
        process_error(e)
示例#10
0
 def test003_probe_list_ok(self, m_sync_call):
     expected = ["test"]
     m_sync_call.return_value = (IrmaReturnCode.success, expected)
     self.assertEqual(module.probe_list(), expected)
示例#11
0
 def test003_probe_list_ok(self, m_sync_call):
     expected = ["test"]
     m_sync_call.return_value = (IrmaReturnCode.success, expected)
     self.assertEqual(module.probe_list(), expected)
 def test003_probe_list_ok(self):
     expected = ["test"]
     with patch("frontend.controllers.braintasks.sync_call") as mock:
         mock.return_value = (IrmaReturnCode.success, expected)
         self.assertEqual(module.probe_list(), expected)