From 28fed5c7788ffe38e12ba962303db93b0a5d2120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 26 Feb 2021 17:13:16 +0100 Subject: [PATCH] fix: support text search again Fix #705 --- pymisp/api.py | 2 +- tests/testlive_comprehensive.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pymisp/api.py b/pymisp/api.py index 7bc3329..fc2952f 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -2394,7 +2394,7 @@ class PyMISP: return self._csv_to_dict(normalized_response_text) # type: ignore else: return normalized_response_text - elif return_format == 'stix-xml': + elif return_format in ['stix-xml', 'text']: return self._check_response(response) normalized_response = self._check_json_response(response) diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index 92e97b5..366bfca 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -1152,6 +1152,19 @@ class TestComprehensive(unittest.TestCase): self.admin_misp_connector.delete_event(first) self.admin_misp_connector.delete_event(second) + def test_search_text(self): + first = self.create_simple_event() + first.add_attribute('ip-src', '8.8.8.8') + first.publish() + try: + first = self.user_misp_connector.add_event(first) + self.admin_misp_connector.publish(first) + text = self.user_misp_connector.search(return_format='text', eventid=first.id) + self.assertEqual('8.8.8.8', text.strip()) + finally: + # Delete event + self.admin_misp_connector.delete_event(first) + def test_search_stix(self): first = self.create_simple_event() first.add_attribute('ip-src', '8.8.8.8')