mirror of https://github.com/MISP/PyMISP
Merge pull request #760 from JakubOnderka/get-taxonomy-namespace
chg: `get_taxonomy` supports namespacepull/770/head
commit
4c003ca810
|
@ -1092,7 +1092,7 @@ class PyMISP:
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
def get_taxonomy(self, taxonomy: Union[MISPTaxonomy, int, str, UUID], pythonify: bool = False) -> Union[Dict, MISPTaxonomy]:
|
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 taxonomy: taxonomy to get
|
||||||
:param pythonify: Returns a PyMISP Object instead of the plain json output
|
:param pythonify: Returns a PyMISP Object instead of the plain json output
|
||||||
|
|
|
@ -1576,6 +1576,8 @@ class TestComprehensive(unittest.TestCase):
|
||||||
# Get list
|
# Get list
|
||||||
taxonomies = self.admin_misp_connector.taxonomies(pythonify=True)
|
taxonomies = self.admin_misp_connector.taxonomies(pythonify=True)
|
||||||
self.assertTrue(isinstance(taxonomies, list))
|
self.assertTrue(isinstance(taxonomies, list))
|
||||||
|
|
||||||
|
# Test fetching taxonomy by ID
|
||||||
list_name_test = 'tlp'
|
list_name_test = 'tlp'
|
||||||
for tax in taxonomies:
|
for tax in taxonomies:
|
||||||
if tax.namespace == list_name_test:
|
if tax.namespace == list_name_test:
|
||||||
|
@ -1583,10 +1585,17 @@ class TestComprehensive(unittest.TestCase):
|
||||||
r = self.admin_misp_connector.get_taxonomy(tax, pythonify=True)
|
r = self.admin_misp_connector.get_taxonomy(tax, pythonify=True)
|
||||||
self.assertEqual(r.namespace, list_name_test)
|
self.assertEqual(r.namespace, list_name_test)
|
||||||
self.assertTrue('enabled' in r)
|
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)
|
r = self.admin_misp_connector.enable_taxonomy(tax)
|
||||||
self.assertEqual(r['message'], 'Taxonomy enabled')
|
self.assertEqual(r['message'], 'Taxonomy enabled')
|
||||||
|
|
||||||
r = self.admin_misp_connector.enable_taxonomy_tags(tax)
|
r = self.admin_misp_connector.enable_taxonomy_tags(tax)
|
||||||
self.assertEqual(r['name'], 'The tag(s) has been saved.')
|
self.assertEqual(r['name'], 'The tag(s) has been saved.')
|
||||||
|
|
||||||
r = self.admin_misp_connector.disable_taxonomy(tax)
|
r = self.admin_misp_connector.disable_taxonomy(tax)
|
||||||
self.assertEqual(r['message'], 'Taxonomy disabled')
|
self.assertEqual(r['message'], 'Taxonomy disabled')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue