예제 #1
0
    def _test_scan_eicar_file(self,
                              force=False,
                              probe=EICAR_RESULTS.keys(),
                              timeout=SCAN_TIMEOUT_SEC):
        self.scanid = _scan_new(DEBUG)
        self.assertIsNotNone(self.scanid)

        _scan_add(self.scanid, [self.filename], DEBUG)
        probelaunched = _scan_launch(self.scanid, force, probe, DEBUG)
        self.assertEquals(sorted(probelaunched), sorted(probe))
        start = time.time()
        while True:
            (status, _, total, _) = _scan_progress(self.scanid, DEBUG)
            if status == IrmaScanStatus.label[IrmaScanStatus.finished]:
                break
            if status == IrmaScanStatus.label[IrmaScanStatus.launched]:
                self.assertEquals(total, len(probelaunched))
            now = time.time()
            self.assertLessEqual(now, start + timeout, "Results Timeout")
            time.sleep(BEFORE_NEXT_PROGRESS)
        results = _scan_result(self.scanid, DEBUG)
        self.assertEquals(results.keys(), [EICAR_HASH])
        ref_keys = results[EICAR_HASH]['results'].keys()
        self.assertEquals(sorted(ref_keys), sorted(probelaunched))
        for p in probelaunched:
            res = results[EICAR_HASH]['results'][p]['result']
            self.assertEquals(res, EICAR_RESULTS[p]['result'])
        return
예제 #2
0
 def test_scan_add_after_launch(self):
     force = True
     probe = None
     timeout = SCAN_TIMEOUT_SEC
     self.scanid = _scan_new(DEBUG)
     _scan_add(self.scanid, [self.filename], DEBUG)
     _scan_launch(self.scanid, force, probe, DEBUG)
     start = time.time()
     while True:
         (status, _, _, _) = _scan_progress(self.scanid, DEBUG)
         if status == IrmaScanStatus.label[IrmaScanStatus.finished]:
             break
         if status == IrmaScanStatus.label[IrmaScanStatus.launched]:
             with self.assertRaises(IrmaError):
                 _scan_add(self.scanid, [self.filename], DEBUG)
         now = time.time()
         self.assertLessEqual(now, start + timeout, "Results Timeout")
         time.sleep(BEFORE_NEXT_PROGRESS)
     _scan_result(self.scanid, DEBUG)
     with self.assertRaises(IrmaError):
         _scan_add(self.scanid, [self.filename], DEBUG)
     return