From 3a92e343e5292f1bf5c4319b8b47831e6ab13f20 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Tue, 22 Jun 2021 17:34:01 +0200 Subject: [PATCH] chg: `get_taxonomy` supports namespace --- pymisp/api.py | 2 +- tests/testlive_comprehensive.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pymisp/api.py b/pymisp/api.py index 6f0b4bc..eb47245 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -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 diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index 633afed..d148e66 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -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')