mirror of https://github.com/MISP/PyMISP
chg: [tests] Remove travis exceptions.
parent
55c2bff26b
commit
1ec7ec37d9
|
@ -33,13 +33,11 @@ except ImportError:
|
||||||
try:
|
try:
|
||||||
from keys import url, key
|
from keys import url, key
|
||||||
verifycert = False
|
verifycert = False
|
||||||
travis_run = True
|
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print(e)
|
print(e)
|
||||||
url = 'https://localhost:8443'
|
url = 'https://localhost:8443'
|
||||||
key = 'K5yV0CcxdnklzDfCKlnPniIxrMX41utQ2dG13zZ3'
|
key = 'K5yV0CcxdnklzDfCKlnPniIxrMX41utQ2dG13zZ3'
|
||||||
verifycert = False
|
verifycert = False
|
||||||
travis_run = False
|
|
||||||
|
|
||||||
|
|
||||||
urllib3.disable_warnings()
|
urllib3.disable_warnings()
|
||||||
|
@ -479,8 +477,6 @@ class TestComprehensive(unittest.TestCase):
|
||||||
|
|
||||||
def test_default_distribution(self):
|
def test_default_distribution(self):
|
||||||
'''The default distributions on the VM are This community only for the events and Inherit from event for attr/obj)'''
|
'''The default distributions on the VM are This community only for the events and Inherit from event for attr/obj)'''
|
||||||
if travis_run:
|
|
||||||
return
|
|
||||||
first = self.create_simple_event()
|
first = self.create_simple_event()
|
||||||
del first.distribution
|
del first.distribution
|
||||||
o = first.add_object(name='file')
|
o = first.add_object(name='file')
|
||||||
|
@ -670,14 +666,12 @@ class TestComprehensive(unittest.TestCase):
|
||||||
self.assertEqual(events[0].id, second.id)
|
self.assertEqual(events[0].id, second.id)
|
||||||
self.assertEqual(len(events[0].attributes), 5)
|
self.assertEqual(len(events[0].attributes), 5)
|
||||||
|
|
||||||
if not travis_run:
|
events = self.user_misp_connector.search(eventid=second.id, enforce_warninglist=True, pythonify=True)
|
||||||
# FIXME: This is failing on travis for no discernable reason...
|
self.assertEqual(len(events), 1)
|
||||||
events = self.user_misp_connector.search(eventid=second.id, enforce_warninglist=True, pythonify=True)
|
self.assertEqual(events[0].id, second.id)
|
||||||
self.assertEqual(len(events), 1)
|
self.assertEqual(len(events[0].attributes), 3)
|
||||||
self.assertEqual(events[0].id, second.id)
|
response = self.admin_misp_connector.toggle_warninglist(warninglist_name='%dns resolv%') # disable ipv4 DNS.
|
||||||
self.assertEqual(len(events[0].attributes), 3)
|
self.assertDictEqual(response, {'saved': True, 'success': '3 warninglist(s) toggled'})
|
||||||
response = self.admin_misp_connector.toggle_warninglist(warninglist_name='%dns resolv%') # disable ipv4 DNS.
|
|
||||||
self.assertDictEqual(response, {'saved': True, 'success': '3 warninglist(s) toggled'})
|
|
||||||
|
|
||||||
# Page / limit
|
# Page / limit
|
||||||
attributes = self.user_misp_connector.search(controller='attributes', eventid=second.id, page=1, limit=3, pythonify=True)
|
attributes = self.user_misp_connector.search(controller='attributes', eventid=second.id, page=1, limit=3, pythonify=True)
|
||||||
|
@ -893,13 +887,12 @@ class TestComprehensive(unittest.TestCase):
|
||||||
first.add_attribute('ip-src', '8.8.8.8')
|
first.add_attribute('ip-src', '8.8.8.8')
|
||||||
try:
|
try:
|
||||||
first = self.user_misp_connector.add_event(first)
|
first = self.user_misp_connector.add_event(first)
|
||||||
if not travis_run:
|
stix = self.user_misp_connector.search(return_format='stix', eventid=first.id)
|
||||||
stix = self.user_misp_connector.search(return_format='stix', eventid=first.id)
|
found = re.findall('8.8.8.8', stix)
|
||||||
found = re.findall('8.8.8.8', stix)
|
self.assertTrue(found)
|
||||||
self.assertTrue(found)
|
stix2 = self.user_misp_connector.search(return_format='stix2', eventid=first.id)
|
||||||
stix2 = self.user_misp_connector.search(return_format='stix2', eventid=first.id)
|
json.dumps(stix2, indent=2)
|
||||||
json.dumps(stix2, indent=2)
|
self.assertEqual(stix2['objects'][-1]['pattern'], "[network-traffic:src_ref.type = 'ipv4-addr' AND network-traffic:src_ref.value = '8.8.8.8']")
|
||||||
self.assertEqual(stix2['objects'][-1]['pattern'], "[network-traffic:src_ref.type = 'ipv4-addr' AND network-traffic:src_ref.value = '8.8.8.8']")
|
|
||||||
finally:
|
finally:
|
||||||
# Delete event
|
# Delete event
|
||||||
self.admin_misp_connector.delete_event(first.id)
|
self.admin_misp_connector.delete_event(first.id)
|
||||||
|
@ -1129,10 +1122,9 @@ class TestComprehensive(unittest.TestCase):
|
||||||
for tax in taxonomies:
|
for tax in taxonomies:
|
||||||
if tax.namespace == list_name_test:
|
if tax.namespace == list_name_test:
|
||||||
break
|
break
|
||||||
if not travis_run:
|
r = self.admin_misp_connector.get_taxonomy(tax.id, pythonify=True)
|
||||||
r = self.admin_misp_connector.get_taxonomy(tax.id, pythonify=True)
|
self.assertEqual(r.namespace, list_name_test)
|
||||||
self.assertEqual(r.namespace, list_name_test)
|
self.assertTrue('enabled' in r)
|
||||||
self.assertTrue('enabled' in r)
|
|
||||||
r = self.admin_misp_connector.enable_taxonomy(tax.id)
|
r = self.admin_misp_connector.enable_taxonomy(tax.id)
|
||||||
self.assertEqual(r['message'], 'Taxonomy enabled')
|
self.assertEqual(r['message'], 'Taxonomy enabled')
|
||||||
r = self.admin_misp_connector.enable_taxonomy_tags(tax.id)
|
r = self.admin_misp_connector.enable_taxonomy_tags(tax.id)
|
||||||
|
@ -1192,29 +1184,27 @@ class TestComprehensive(unittest.TestCase):
|
||||||
self.assertFalse(r['Noticelist']['enabled'], r)
|
self.assertFalse(r['Noticelist']['enabled'], r)
|
||||||
|
|
||||||
def test_galaxies(self):
|
def test_galaxies(self):
|
||||||
if not travis_run:
|
# Make sure we're up-to-date
|
||||||
# Make sure we're up-to-date
|
r = self.admin_misp_connector.update_galaxies()
|
||||||
r = self.admin_misp_connector.update_galaxies()
|
self.assertEqual(r['name'], 'Galaxies updated.')
|
||||||
self.assertEqual(r['name'], 'Galaxies updated.')
|
# Get list
|
||||||
# Get list
|
galaxies = self.admin_misp_connector.galaxies(pythonify=True)
|
||||||
galaxies = self.admin_misp_connector.galaxies(pythonify=True)
|
self.assertTrue(isinstance(galaxies, list))
|
||||||
self.assertTrue(isinstance(galaxies, list))
|
list_name_test = 'Mobile Attack - Attack Pattern'
|
||||||
list_name_test = 'Mobile Attack - Attack Pattern'
|
for galaxy in galaxies:
|
||||||
for galaxy in galaxies:
|
if galaxy.name == list_name_test:
|
||||||
if galaxy.name == list_name_test:
|
break
|
||||||
break
|
r = self.admin_misp_connector.get_galaxy(galaxy.id, pythonify=True)
|
||||||
r = self.admin_misp_connector.get_galaxy(galaxy.id, pythonify=True)
|
self.assertEqual(r.name, list_name_test)
|
||||||
self.assertEqual(r.name, list_name_test)
|
# FIXME: Fails due to https://github.com/MISP/MISP/issues/4855
|
||||||
# FIXME: Fails due to https://github.com/MISP/MISP/issues/4855
|
# self.assertTrue('GalaxyCluster' in r)
|
||||||
# self.assertTrue('GalaxyCluster' in r)
|
|
||||||
|
|
||||||
def test_zmq(self):
|
def test_zmq(self):
|
||||||
first = self.create_simple_event()
|
first = self.create_simple_event()
|
||||||
try:
|
try:
|
||||||
first = self.user_misp_connector.add_event(first)
|
first = self.user_misp_connector.add_event(first)
|
||||||
if not travis_run:
|
r = self.admin_misp_connector.push_event_to_ZMQ(first.id)
|
||||||
r = self.admin_misp_connector.push_event_to_ZMQ(first.id)
|
self.assertEqual(r['message'], 'Event published to ZMQ')
|
||||||
self.assertEqual(r['message'], 'Event published to ZMQ')
|
|
||||||
finally:
|
finally:
|
||||||
# Delete event
|
# Delete event
|
||||||
self.admin_misp_connector.delete_event(first.id)
|
self.admin_misp_connector.delete_event(first.id)
|
||||||
|
|
Loading…
Reference in New Issue