From 4ec01bb096a27b61a5b34085d3edc2e32b7c6adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Mon, 9 Aug 2021 09:15:37 +0200 Subject: [PATCH] chg: Add test for updating a objects from a custom template Related: #776 --- tests/testlive_comprehensive.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index 86dce87..7605afc 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -1307,6 +1307,17 @@ class TestComprehensive(unittest.TestCase): new_object.add_attribute('filename', 'foobar.exe') new_object = self.admin_misp_connector.update_object(new_object, pythonify=True) self.assertEqual(new_object.get_attributes_by_relation('filename')[1].value, 'foobar.exe', new_object) + + # Get existing custom object, modify it, update on MISP + existing_object = self.admin_misp_connector.get_object(new_object.uuid, pythonify=True) + # existing_object.force_misp_objects_path_custom('tests/mispevent_testfiles', 'overwrite_file') + # The existing_object is a overwrite_file object, unless we uncomment the line above, type= is required below. + existing_object.add_attribute('pattern-in-file', value='foo', type='text') + updated_existing_object = self.admin_misp_connector.update_object(existing_object, pythonify=True) + print(updated_existing_object.to_json(indent=2)) + print(updated_existing_object.get_attributes_by_relation('pattern-in-file')) + self.assertEqual(updated_existing_object.get_attributes_by_relation('pattern-in-file')[0].value, 'foo', updated_existing_object) + finally: # Delete event self.admin_misp_connector.delete_event(first)