fix: Enable/disable feeds

pull/749/head
Raphaël Vinot 2021-04-20 15:36:11 +02:00
parent 67457bec53
commit b471633acb
2 changed files with 4 additions and 6 deletions

View File

@ -1564,9 +1564,9 @@ class PyMISP:
feed_id = get_uuid_or_id_from_abstract_misp(feed) # In case we have a UUID
f = MISPFeed()
f.id = feed_id
f.enabled = True
else:
f = feed
f.enabled = True
return self.update_feed(feed=f, pythonify=pythonify)
def disable_feed(self, feed: Union[MISPFeed, int, str, UUID], pythonify: bool = False) -> Union[Dict, MISPFeed]:
@ -1579,9 +1579,9 @@ class PyMISP:
feed_id = get_uuid_or_id_from_abstract_misp(feed) # In case we have a UUID
f = MISPFeed()
f.id = feed_id
f.enabled = False
else:
f = feed
f.enabled = False
return self.update_feed(feed=f, pythonify=pythonify)
def enable_feed_cache(self, feed: Union[MISPFeed, int, str, UUID], pythonify: bool = False) -> Union[Dict, MISPFeed]:
@ -1594,9 +1594,9 @@ class PyMISP:
feed_id = get_uuid_or_id_from_abstract_misp(feed) # In case we have a UUID
f = MISPFeed()
f.id = feed_id
f.caching_enabled = True
else:
f = feed
f.caching_enabled = True
return self.update_feed(feed=f, pythonify=pythonify)
def disable_feed_cache(self, feed: Union[MISPFeed, int, str, UUID], pythonify: bool = False) -> Union[Dict, MISPFeed]:
@ -1609,9 +1609,9 @@ class PyMISP:
feed_id = get_uuid_or_id_from_abstract_misp(feed) # In case we have a UUID
f = MISPFeed()
f.id = feed_id
f.caching_enabled = False
else:
f = feed
f.caching_enabled = False
return self.update_feed(feed=f, pythonify=pythonify)
def update_feed(self, feed: MISPFeed, feed_id: Optional[int] = None, pythonify: bool = False) -> Union[Dict, MISPFeed]:

View File

@ -2170,12 +2170,10 @@ class TestComprehensive(unittest.TestCase):
if feed.name == 'blockrules of rules.emergingthreats.net':
e_thread_csv_feed = feed
break
e_thread_csv_feed.enabled = True
updated_feed = self.admin_misp_connector.enable_feed(e_thread_csv_feed, pythonify=True)
self.assertTrue(updated_feed.enabled)
self.assertEqual(updated_feed.settings, e_thread_csv_feed.settings)
e_thread_csv_feed.enabled = False
updated_feed = self.admin_misp_connector.disable_feed(e_thread_csv_feed, pythonify=True)
self.assertFalse(updated_feed.enabled)
self.assertEqual(updated_feed.settings, e_thread_csv_feed.settings)