From 12c92ca83a678a0d0d97d6e6426801b49723cc5d Mon Sep 17 00:00:00 2001 From: Tom King Date: Wed, 13 Oct 2021 11:18:39 +0100 Subject: [PATCH] chg: Add in test case for get_sharing_group and validate orgs are present --- tests/testlive_comprehensive.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index f372ec7..4c33896 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -2177,6 +2177,30 @@ class TestComprehensive(unittest.TestCase): self.assertFalse(self.admin_misp_connector.sharing_group_exists(sharing_group.id)) self.assertFalse(self.admin_misp_connector.sharing_group_exists(sharing_group.uuid)) + def test_sharing_group(self): + # add + sg = MISPSharingGroup() + sg.name = 'Testcases SG' + sg.releasability = 'Testing' + sharing_group = self.admin_misp_connector.add_sharing_group(sg, pythonify=True) + # Add the org to the sharing group + self.admin_misp_connector.add_org_to_sharing_group( + sharing_group, + self.test_org, extend=True + ) + try: + # Get the sharing group once again + sharing_group = self.admin_misp_connector.get_sharing_group(sharing_group, pythonify=True) + + self.assertTrue(isinstance(sharing_group, MISPSharingGroup)) + self.assertEqual(sharing_group.name, 'Testcases SG') + + # Check we have the org field present and the first org is our org + self.assertTrue(isinstance(getattr(sharing_group, "orgs"), list)) + self.assertEqual(sharing_group.orgs[0].id, self.test_org.id) + finally: + self.admin_misp_connector.delete_sharing_group(sharing_group.id) + def test_feeds(self): # Add feed = MISPFeed()