Beispiel #1
0
 def test_file_search_hash(self):
     force = False
     probes = probe_list()
     scan_files(FILEPATHS, force, probes, blocking=True)
     for hash in HASHES:
         (_, res) = file_search(hash=hash)
         self.assertTrue(len(res) > 0)
         self.assertEqual(type(res[0]), IrmaResults)
Beispiel #2
0
 def test_file_search_name(self):
     force = False
     probes = probe_list()
     scan_files(FILEPATHS, force, probes, blocking=True)
     for name in FILENAMES:
         data = file_search(name=name)
         self.assertEqual(type(data), tuple)
         (total, res) = file_search(name, limit=1)
         self.assertEqual(type(res), list)
         self.assertEqual(type(res[0]), IrmaResults)
         self.assertEqual(len(res), 1)
         self.assertEqual(type(total), int)
Beispiel #3
0
 def test_scan_get(self):
     force = False
     probes = probe_list()
     scan = scan_files(FILEPATHS, force, probes)
     while not scan.is_finished():
         time.sleep(1)
         scan = scan_get(scan.id)
     self._check_scan(scan, scan.id, ["finished"],
                      FILENAMES, [scan.probes_total], [scan.probes_total],
                      scan.date, force, True, True)
Beispiel #4
0
 def test_zip(self):
     probelist = probe_list()
     probe = u"Unarchive"
     if probe not in probelist:
         raise unittest.SkipTest("Skipping %s not present" % probe)
     force = True
     sample = os.path.join(SAMPLES_DIR, ZIP_SAMPLE)
     scan = scan_files([sample], force, probe=[probe], blocking=True)
     self.assertEqual(len(scan.results), 2)
     self.assertEqual(scan.probes_finished, 1)
Beispiel #5
0
 def test_file_results_not_formatted(self):
     force = False
     probes = probe_list()
     scan = scan_files(FILEPATHS, force, probes, blocking=True)
     for get_result in scan.results:
         self.assertTrue(self._validate_uuid(str(get_result.result_id)))
         res = scan_proberesults(get_result.result_id, formatted=False)
         self.assertIn(res.name, FILENAMES)
         self.assertEqual(type(res.probe_results), list)
         self.assertEqual(type(res.probe_results[0]), IrmaProbeResult)
         self.assertEqual(len(res.probe_results), res.probes_finished)
Beispiel #6
0
 def test_utf8(self):
     force = False
     scan = scan_files(UTF8_PATHS, force, blocking=True)
     for get_result in scan.results:
         res = scan_proberesults(get_result.result_id)
         self.assertIn(res.name, UTF8_SAMPLES)
     for filename in UTF8_SAMPLES:
         (_, res) = file_search(filename, limit=1)
         self.assertEqual(type(res), list)
         self.assertEqual(len(res), 1)
         self.assertEqual(res[0].name, filename)
Beispiel #7
0
 def test_scan_files(self):
     force = True
     probes = probe_list()
     nb_jobs = len(FILENAMES) * len(probes)
     scan = scan_files(FILEPATHS, force, probe=probes)
     self._check_scan(scan, scan.id, ["ready", "uploaded", "launched"],
                      FILENAMES, range(nb_jobs), range(nb_jobs + 1),
                      scan.date, True, True, True)
     scan = scan_cancel(scan.id)
     self._check_scan(scan, scan.id, ["cancelled"],
                      FILENAMES, range(nb_jobs), range(nb_jobs + 1),
                      scan.date, True, True, True)
Beispiel #8
0
 def setUp(self):
     if self.taglist is None:
         self.taglist = tag_list()
     if len(self.taglist) == 0:
         raise unittest.SkipTest("Skipping No tag found (please add some)")
     # Insure file is present (Force=False)
     scan = scan_files([self.file_path], False, blocking=True)
     self.get_result = scan_proberesults(scan.results[0].result_id)
     # Insure file got no tags for test
     self.former_tag = [x.id for x in self.get_result.file_infos.tags]
     if len(self.former_tag) != 0:
         for tagid in self.former_tag:
             file_tag_remove(self.file_sha256, tagid)
         self.get_result = scan_proberesults(scan.results[0].result_id)
Beispiel #9
0
 def test_file_results_formatted(self):
     force = False
     probes = probe_list()
     scan = scan_files(FILEPATHS, force, probes)
     while not scan.is_finished():
         time.sleep(1)
         scan = scan_get(scan.id)
     for get_result in scan.results:
         self.assertTrue(self._validate_uuid(str(get_result.result_id)))
         res = scan_proberesults(get_result.result_id)
         self.assertIn(res.name, FILENAMES)
         self.assertEqual(type(res.probe_results), list)
         self.assertEqual(type(res.probe_results[0]), IrmaProbeResult)
         self.assertEqual(len(res.probe_results), res.probes_finished)
Beispiel #10
0
 def test_scan_files_timeout(self):
     force = True
     probes = probe_list()
     with self.assertRaises(IrmaError):
         scan_files(FILEPATHS, force, probe=[probes[0]], blocking=True,
                    blocking_timeout=0)
 def _make_scan(self, filelist):
     force = True
     scan = scan_files(filelist, force, blocking=True)
     return scan