mirror of https://github.com/MISP/PyMISP
fix: Slight changes in new .change_disable_correlation method
parent
e73bdc765e
commit
ec6439ce34
|
@ -1032,10 +1032,11 @@ class PyMISP(object):
|
||||||
query = {"comment": comment}
|
query = {"comment": comment}
|
||||||
return self.__query('edit/{}'.format(attribute_uuid), query, controller='attributes')
|
return self.__query('edit/{}'.format(attribute_uuid), query, controller='attributes')
|
||||||
|
|
||||||
def change_disablecorrelation(self, attribute_uuid, disable_correlation):
|
def change_disable_correlation(self, attribute_uuid, disable_correlation):
|
||||||
"""Change the disable_correlation flag"""
|
"""Change the disable_correlation flag"""
|
||||||
if disable_correlation not in [0, 1]:
|
possible_values = [0, 1, False, True]
|
||||||
raise Exception('disable_correlation can only be 0 or 1')
|
if disable_correlation not in possible_values:
|
||||||
|
raise Exception('disable_correlation can only be in {}'.format(', '.join(possible_values)))
|
||||||
query = {"disable_correlation": disable_correlation}
|
query = {"disable_correlation": disable_correlation}
|
||||||
return self.__query('edit/{}'.format(attribute_uuid), query, controller='attributes')
|
return self.__query('edit/{}'.format(attribute_uuid), query, controller='attributes')
|
||||||
|
|
||||||
|
|
|
@ -409,20 +409,6 @@ class TestOffline(unittest.TestCase):
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_change_disablecorrelation(self, m):
|
|
||||||
self.initURI(m)
|
|
||||||
pymisp = PyMISP(self.domain, self.key)
|
|
||||||
self.assertEqual({}, pymisp.change_disablecorrelation(self.key, 1))
|
|
||||||
|
|
||||||
def test_change_disablecorrelation_invalid(self, m):
|
|
||||||
self.initURI(m)
|
|
||||||
pymisp = PyMISP(self.domain, self.key)
|
|
||||||
try:
|
|
||||||
pymisp.change_disablecorrelation(self.key, 42)
|
|
||||||
self.assertFalse('Exception required for off domain value')
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def test_proposal_view_default(self, m):
|
def test_proposal_view_default(self, m):
|
||||||
self.initURI(m)
|
self.initURI(m)
|
||||||
pymisp = PyMISP(self.domain, self.key)
|
pymisp = PyMISP(self.domain, self.key)
|
||||||
|
|
|
@ -703,6 +703,10 @@ class TestComprehensive(unittest.TestCase):
|
||||||
self.assertEqual(attribute.comment, 'This is the modified comment')
|
self.assertEqual(attribute.comment, 'This is the modified comment')
|
||||||
attribute = self.user_misp_connector.change_comment(first.attributes[0].uuid, 'This is the modified comment, again')
|
attribute = self.user_misp_connector.change_comment(first.attributes[0].uuid, 'This is the modified comment, again')
|
||||||
self.assertEqual(attribute['Attribute']['comment'], 'This is the modified comment, again')
|
self.assertEqual(attribute['Attribute']['comment'], 'This is the modified comment, again')
|
||||||
|
attribute = self.user_misp_connector.change_disable_correlation(first.attributes[0].uuid, True)
|
||||||
|
self.assertEqual(attribute['Attribute']['disable_correlation'], True)
|
||||||
|
attribute = self.user_misp_connector.change_disable_correlation(first.attributes[0].uuid, 0)
|
||||||
|
self.assertEqual(attribute['Attribute']['disable_correlation'], False)
|
||||||
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