chg: Add a few test cases

pull/604/head
Raphaël Vinot 2020-06-22 14:27:03 +02:00
parent 3177d05c5d
commit a127318a8e
1 changed files with 33 additions and 0 deletions

View File

@ -536,6 +536,26 @@ class TestComprehensive(unittest.TestCase):
# Delete event
self.admin_misp_connector.delete_event(first)
def test_delete_with_update(self):
try:
first = self.create_simple_event()
obj = MISPObject('file')
obj.add_attribute('filename', 'foo')
first.add_object(obj)
first = self.user_misp_connector.add_event(first)
first.attributes[0].deleted = True
deleted_attribute = self.user_misp_connector.update_attribute(first.attributes[0], pythonify=True)
self.assertTrue(deleted_attribute.deleted)
# FIXME: https://github.com/MISP/MISP/issues/6024
# first.objects[0].deleted = True
# deleted_object = self.user_misp_connector.update_object(first.objects[0], pythonify=True)
# self.assertTrue(deleted_object.deleted)
finally:
# Delete event
self.admin_misp_connector.delete_event(first)
def test_delete_by_uuid(self):
try:
first = self.create_simple_event()
@ -1822,6 +1842,10 @@ class TestComprehensive(unittest.TestCase):
first = self.create_simple_event()
o = first.add_object(name='file')
o.add_attribute('filename', value='foo2.exe')
second_object = MISPObject('file')
second_object.add_attribute("tlsh", value='92a4b4a3d342a21fe1147474c19c9ab6a01717713a0248a2bb15affce77c1c14a79b93',
category="Payload delivery", to_ids=True, distribution=4, sharing_group_id=sharing_group.id)
try:
first = self.user_misp_connector.add_event(first)
first = self.admin_misp_connector.change_sharing_group_on_entity(first, sharing_group.id, pythonify=True)
@ -1832,6 +1856,15 @@ class TestComprehensive(unittest.TestCase):
first_attribute = self.admin_misp_connector.change_sharing_group_on_entity(first.attributes[0], sharing_group.id, pythonify=True)
self.assertEqual(first_attribute.distribution, 4)
self.assertEqual(first_attribute.sharing_group_id, int(sharing_group.id))
# manual create
second_object = self.admin_misp_connector.add_object(first.id, second_object, pythonify=True)
self.assertEqual(second_object.attributes[0].sharing_group_id, int(sharing_group.id))
# manual update
# FIXME: https://github.com/MISP/MISP/issues/6025
# first_object.add_attribute("tlsh", value='92a4b4a3d342a21fe1147474c19c9ab6a01717713a0248a2bb15affce77c1c14a79b93',
# category="Payload delivery", to_ids=True, distribution=4, sharing_group_id=sharing_group.id)
# first_object = self.admin_misp_connector.update_object(first_object, pythonify=True)
# self.assertEqual(first_object.attributes[-1].sharing_group_id, sharing_group.id)
finally:
# Delete event
self.admin_misp_connector.delete_event(first)