def test_group_no_intersection_exists(self): """ test_list is a list of lists. Each sublist is the groups that use a technique. There aren't any groups in each of the subsets. """ GROUP = self.MockGroupID test_list = [[ GROUP(42), GROUP(1), GROUP(2), GROUP(3), GROUP(123), GROUP(122) ], [ GROUP(10), GROUP(11), GROUP(123), GROUP(122), GROUP(12), GROUP(42) ], [GROUP(20), GROUP(21), GROUP(22), GROUP(23), GROUP(42), GROUP(122)], [GROUP(123), GROUP(30), GROUP(31), GROUP(32)]] intersection = MitreAttackGroup.get_intersection_of_groups(test_list) assert len(intersection) == 0
def test_groups_done_have_mardown_links(self): """ Test that links are sanitized. """ data_mocker = MitreQueryMocker() with patch( "fn_mitre_integration.lib.mitre_attack.TAXIICollectionSource.query", data_mocker.query): groups = MitreAttackGroup.get_all(self.mitre_attack) dict_reps = [g.dict_form() for g in groups] # check for every technique's representation that all the field don't have the tag assert all([ (re.search("\[(.*?)\]\((.*?)\)", group["description"]) is None) for group in dict_reps ])
def test_group_multiple_intersection_exists(self): """ test_list is a list of lists. Each sublist is the groups that use a technique. Groupswith id 42 and 123 are in every sublist. """ GROUP = self.MockGroupID test_list = [[ GROUP(42), GROUP(1), GROUP(2), GROUP(3), GROUP(123), GROUP(122) ], [ GROUP(10), GROUP(11), GROUP(123), GROUP(122), GROUP(12), GROUP(42) ], [ GROUP(20), GROUP(21), GROUP(22), GROUP(23), GROUP(42), GROUP(123), GROUP(122) ], [GROUP(123), GROUP(30), GROUP(31), GROUP(32), GROUP(42)]] intersection = MitreAttackGroup.get_intersection_of_groups(test_list) assert len(intersection) == 2 assert 42 in intersection assert 123 in intersection