mirror of https://github.com/MISP/PyMISP
new: Add test_obj_references_export
parent
b6322c0d0c
commit
6429ffd795
|
@ -9,7 +9,8 @@ import glob
|
||||||
import hashlib
|
import hashlib
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
|
|
||||||
from pymisp import MISPEvent, MISPSighting, MISPTag, MISPOrganisation
|
from pymisp import (MISPEvent, MISPSighting, MISPTag, MISPOrganisation,
|
||||||
|
MISPObject)
|
||||||
from pymisp.exceptions import InvalidMISPObject
|
from pymisp.exceptions import InvalidMISPObject
|
||||||
from pymisp.tools import GitVulnFinderObject
|
from pymisp.tools import GitVulnFinderObject
|
||||||
|
|
||||||
|
@ -201,6 +202,19 @@ class TestMISPEvent(unittest.TestCase):
|
||||||
del self.mispevent.uuid
|
del self.mispevent.uuid
|
||||||
self.assertEqual(self.mispevent.to_json(sort_keys=True, indent=2), json.dumps(ref_json, sort_keys=True, indent=2))
|
self.assertEqual(self.mispevent.to_json(sort_keys=True, indent=2), json.dumps(ref_json, sort_keys=True, indent=2))
|
||||||
|
|
||||||
|
def test_obj_references_export(self):
|
||||||
|
self.init_event()
|
||||||
|
obj1 = MISPObject(name="file")
|
||||||
|
obj2 = MISPObject(name="url", standalone=False)
|
||||||
|
obj1.add_reference(obj2, "downloads")
|
||||||
|
obj2.add_reference(obj1, "downloaded-by")
|
||||||
|
self.assertFalse("ObjectReference" in obj1.jsonable())
|
||||||
|
self.assertTrue("ObjectReference" in obj2.jsonable())
|
||||||
|
self.mispevent.add_object(obj1)
|
||||||
|
obj2.standalone = True
|
||||||
|
self.assertTrue("ObjectReference" in obj1.jsonable())
|
||||||
|
self.assertFalse("ObjectReference" in obj2.jsonable())
|
||||||
|
|
||||||
def test_event_not_edited(self):
|
def test_event_not_edited(self):
|
||||||
self.mispevent.load_file('tests/mispevent_testfiles/existing_event.json')
|
self.mispevent.load_file('tests/mispevent_testfiles/existing_event.json')
|
||||||
self.assertFalse(self.mispevent.edited)
|
self.assertFalse(self.mispevent.edited)
|
||||||
|
|
Loading…
Reference in New Issue