From 3d6fa51a7aa8a3cf7847b735211107096bc0f535 Mon Sep 17 00:00:00 2001 From: Louis LCE Date: Wed, 24 Jan 2018 16:19:53 +0100 Subject: [PATCH] Add tag test --- tests/test_offline.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/test_offline.py b/tests/test_offline.py index 6a03b2f..acfe800 100644 --- a/tests/test_offline.py +++ b/tests/test_offline.py @@ -64,6 +64,8 @@ class TestOffline(unittest.TestCase): m.register_uri('POST', self.domain + 'attributes/downloadSample', json={}) m.register_uri('GET', self.domain + 'tags', json={'Tag': 'foo'}) m.register_uri('POST', self.domain + 'events/upload_sample/1', json={}) + m.register_uri('POST', self.domain + 'tags/attachTagToObject', json={}) + m.register_uri('POST', self.domain + 'tags/removeTagFromObject', json={}) def test_getEvent(self, m): self.initURI(m) @@ -440,18 +442,30 @@ class TestOffline(unittest.TestCase): pymisp = PyMISP(self.domain, self.key) self.assertEqual((False, None), pymisp.download_samples()) - def test_sample_upload(self, m): self.initURI(m) pymisp = PyMISP(self.domain, self.key) upload = pymisp.upload_sample("tmux", "tests/viper-test-files/test_files/tmux" , 1) - def test_get_all_tags(self, m): self.initURI(m) pymisp = PyMISP(self.domain, self.key) self.assertEqual({'Tag': 'foo'}, pymisp.get_all_tags()) + def test_tag_event(self, m): + self.initURI(m) + pymisp = PyMISP(self.domain, self.key) + uuid = self.event["Event"]["uuid"] + pymisp.tag(uuid, "foo") + + self.assertRaises(pm.PyMISPError, pymisp.tag, "test_uuid", "foo") + self.assertRaises(pm.PyMISPError, pymisp.tag, uuid.replace("a", "z"), "foo") + + def test_untag_event(self, m): + self.initURI(m) + pymisp = PyMISP(self.domain, self.key) + uuid = self.event["Event"]["uuid"] + pymisp.untag(uuid, "foo") if __name__ == '__main__': unittest.main()