chg: `get_taxonomy` supports namespace

pull/779/head
Jakub Onderka 2021-06-22 17:34:01 +02:00 committed by Raphaël Vinot
parent 2ecfc24c14
commit 1746138eb3
2 changed files with 10 additions and 1 deletions

View File

@ -1092,7 +1092,7 @@ class PyMISP:
return to_return
def get_taxonomy(self, taxonomy: Union[MISPTaxonomy, int, str, UUID], pythonify: bool = False) -> Union[Dict, MISPTaxonomy]:
"""Get a taxonomy by id from a MISP instance
"""Get a taxonomy by id or namespace from a MISP instance
:param taxonomy: taxonomy to get
:param pythonify: Returns a PyMISP Object instead of the plain json output

View File

@ -1576,6 +1576,8 @@ class TestComprehensive(unittest.TestCase):
# Get list
taxonomies = self.admin_misp_connector.taxonomies(pythonify=True)
self.assertTrue(isinstance(taxonomies, list))
# Test fetching taxonomy by ID
list_name_test = 'tlp'
for tax in taxonomies:
if tax.namespace == list_name_test:
@ -1583,10 +1585,17 @@ class TestComprehensive(unittest.TestCase):
r = self.admin_misp_connector.get_taxonomy(tax, pythonify=True)
self.assertEqual(r.namespace, list_name_test)
self.assertTrue('enabled' in r)
# Test fetching taxonomy by namespace
r = self.admin_misp_connector.get_taxonomy("tlp", pythonify=True)
self.assertEqual(r.namespace, "tlp")
r = self.admin_misp_connector.enable_taxonomy(tax)
self.assertEqual(r['message'], 'Taxonomy enabled')
r = self.admin_misp_connector.enable_taxonomy_tags(tax)
self.assertEqual(r['name'], 'The tag(s) has been saved.')
r = self.admin_misp_connector.disable_taxonomy(tax)
self.assertEqual(r['message'], 'Taxonomy disabled')