mirror of https://github.com/MISP/PyMISPGalaxies
new: Make sure the UUIDs are valid
parent
be5a1f2b39
commit
f951d9bbb1
|
@ -8,13 +8,14 @@ import os
|
||||||
import json
|
import json
|
||||||
from collections import Counter, defaultdict
|
from collections import Counter, defaultdict
|
||||||
import warnings
|
import warnings
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
|
||||||
class TestPyMISPGalaxies(unittest.TestCase):
|
class TestPyMISPGalaxies(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.galaxies = Galaxies()
|
self.galaxies = Galaxies()
|
||||||
self.clusters = Clusters(skip_duplicates=True)
|
self.clusters = Clusters(skip_duplicates=False)
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
|
|
||||||
def test_searchable(self):
|
def test_searchable(self):
|
||||||
|
@ -25,7 +26,7 @@ class TestPyMISPGalaxies(unittest.TestCase):
|
||||||
count = Counter(all_searchable)
|
count = Counter(all_searchable)
|
||||||
for k, v in count.items():
|
for k, v in count.items():
|
||||||
if v != 1:
|
if v != 1:
|
||||||
warnings.warn('Duplicate on {}: {}'.format(cluster.type, k))
|
warnings.warn('On search in {}: {} is present multiple times'.format(cluster.type, k))
|
||||||
|
|
||||||
def test_duplicates(self):
|
def test_duplicates(self):
|
||||||
has_duplicates = False
|
has_duplicates = False
|
||||||
|
@ -103,8 +104,16 @@ class TestPyMISPGalaxies(unittest.TestCase):
|
||||||
# Skip deprecated
|
# Skip deprecated
|
||||||
if self.galaxies[cluster.name].namespace == 'deprecated':
|
if self.galaxies[cluster.name].namespace == 'deprecated':
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
|
self.assertIsInstance(UUID(cluster.uuid), UUID, f'{cluster.name} - {cluster.uuid}')
|
||||||
|
except ValueError:
|
||||||
|
raise Exception(f'{cluster.name} - {cluster.uuid}')
|
||||||
all_uuids[cluster.uuid].append(cluster.name)
|
all_uuids[cluster.uuid].append(cluster.name)
|
||||||
for value in cluster.values():
|
for value in cluster.values():
|
||||||
|
try:
|
||||||
|
self.assertIsInstance(UUID(value.uuid), UUID, f'{cluster.name} - {value.value} - {value.uuid}')
|
||||||
|
except ValueError:
|
||||||
|
raise Exception(f'{cluster.name} - {value.value} - {value.uuid}')
|
||||||
all_uuids[value.uuid].append(f'{cluster.name}|{value.value}')
|
all_uuids[value.uuid].append(f'{cluster.name}|{value.value}')
|
||||||
|
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
Loading…
Reference in New Issue