Skip to content

Commit c1c6c35

Browse files
committed
Add tests
1 parent 3dbeebf commit c1c6c35

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

intelmq/lib/upgrades.py

+3
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,9 @@ def v341_new_fields(configuration, harmonization, dry_run, **kwargs):
994994
"product.vulnerabilities",
995995
]:
996996
if field not in harmonization["event"]:
997+
if field not in builtin_harmonisation["event"]:
998+
# ensure forward-compatibility if we ever remove something from harmonisation
999+
continue
9971000
harmonization["event"][field] = builtin_harmonisation["event"][field]
9981001
changed = True
9991002
return changed, configuration, harmonization

intelmq/tests/lib/test_upgrades.py

+11
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,17 @@ def test_v340_twitter_collector(self):
856856
self.assertIn('twitter-collector', result[0])
857857
self.assertEqual(V340_TWITTER_COLLECTOR_IN, result[1])
858858

859+
def test_v341_new_fields(self):
860+
""" Test adding new harmonisation fields """
861+
result = upgrades.v341_new_fields({}, {"event": {"old-field": "must stay"}}, False)
862+
self.assertTrue(result[0])
863+
self.assertIn("old-field", result[2]["event"])
864+
self.assertIn("product.full_name", result[2]["event"])
865+
self.assertIn("product.name", result[2]["event"])
866+
self.assertIn("product.vendor", result[2]["event"])
867+
self.assertIn("product.version", result[2]["event"])
868+
self.assertIn("product.vulnerabilities", result[2]["event"])
869+
859870

860871
for name in upgrades.__all__:
861872
setattr(TestUpgradeLib, 'test_function_%s' % name,

0 commit comments

Comments
 (0)