From a3140f37739b4a8a63f9b224aaaa2209611a33fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 6 Aug 2019 16:50:09 +0200 Subject: [PATCH] new: Properly support attribute/add of multiple attributes (2.4.113+) --- pymisp/aping.py | 2 +- tests/testlive_comprehensive.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pymisp/aping.py b/pymisp/aping.py index 1c103fe..e3dd2f3 100644 --- a/pymisp/aping.py +++ b/pymisp/aping.py @@ -365,7 +365,7 @@ class ExpandedPyMISP(PyMISP): for new_attr in new_attribute['Attribute']: a = MISPAttribute() - a.from_dict(**attribute) + a.from_dict(**new_attr) to_return['attributes'].append(a) return to_return diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index d7f321f..81af9db 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -1351,12 +1351,13 @@ class TestComprehensive(unittest.TestCase): attr4.type = 'ip-dst' attr4.add_tag('tlp:amber___test') response = self.user_misp_connector.add_attribute(first.id, [attr1, attr2, attr3, attr4]) - # FIXME: https://github.com/MISP/MISP/issues/4959 - # self.assertEqual(response['attributes'][0].value, '1.2.3.5') - # self.assertEqual(response['attributes'][1].value, '1.2.3.6') - # self.assertEqual(response['attributes'][1].tags[0].name, 'tlp:amber___test') - # self.assertEqual(response['errors']['attribute_0']['value'][0], 'A similar attribute already exists for this event.') - # self.assertEqual(response['errors']['attribute_2']['value'][0], 'A similar attribute already exists for this event.') + if 'attributes' in response: + # FIXME: this if statement can be removed as soon as 2.4.113 is released: the format changed between 112 and 113, we test 113+ + self.assertEqual(response['attributes'][0].value, '1.2.3.5') + self.assertEqual(response['attributes'][1].value, '1.2.3.6') + self.assertEqual(response['attributes'][1].tags[0].name, 'tlp:amber___test') + self.assertEqual(response['errors']['attribute_0']['value'][0], 'A similar attribute already exists for this event.') + self.assertEqual(response['errors']['attribute_2']['value'][0], 'A similar attribute already exists for this event.') # Add attribute as proposal new_proposal = MISPAttribute()