new Add test for ASNObject

pull/382/head
Raphaël Vinot 2019-04-11 09:47:57 +02:00
parent c37eabdaed
commit e8334be9ca
1 changed files with 14 additions and 1 deletions

View File

@ -21,7 +21,7 @@ logging.disable(logging.CRITICAL)
try: try:
from pymisp import ExpandedPyMISP, MISPEvent, MISPOrganisation, MISPUser, Distribution, ThreatLevel, Analysis, MISPObject from pymisp import ExpandedPyMISP, MISPEvent, MISPOrganisation, MISPUser, Distribution, ThreatLevel, Analysis, MISPObject
from pymisp.tools import CSVLoader, DomainIPObject from pymisp.tools import CSVLoader, DomainIPObject, ASNObject
except ImportError: except ImportError:
if sys.version_info < (3, 6): if sys.version_info < (3, 6):
print('This test suite requires Python 3.6+, breaking.') print('This test suite requires Python 3.6+, breaking.')
@ -957,6 +957,19 @@ class TestComprehensive(unittest.TestCase):
# Delete event # Delete event
self.admin_misp_connector.delete_event(first.id) self.admin_misp_connector.delete_event(first.id)
def test_asn_object(self):
first = self.create_simple_event()
try:
dom_ip_obj = ASNObject({'asn': '12345',
'first-seen': '20190101',
'last-seen': '2019-02-03'})
first.add_object(dom_ip_obj)
first = self.user_misp_connector.add_event(first)
self.assertEqual(len(first.objects[0].attributes), 3)
finally:
# Delete event
self.admin_misp_connector.delete_event(first.id)
def test_object_template(self): def test_object_template(self):
r = self.admin_misp_connector.update_object_templates() r = self.admin_misp_connector.update_object_templates()
self.assertEqual(type(r), list) self.assertEqual(type(r), list)