mirror of https://github.com/MISP/PyMISP
chg: `get_taxonomy` supports namespace
parent
2ecfc24c14
commit
1746138eb3
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
Loading…
Reference in New Issue