Beispiel #1
0
    def test_multi_items_in_rule_match(self):
        """Test no violations are found with multiple items in rule"""
        processed_rule = {
            'ancestor_resources': [Folder('456'), Organization('7890')]
        }

        rule = engine_module.Rule(rule_name='test_multi_items_in_rule_match',
                                  rule_index=0,
                                  rules=processed_rule)
        violation = rule.find_violation('*****@*****.**',
                                        self.TEST_ANCESTORS)
        self.assertIsNone(violation)
Beispiel #2
0
    def test_single_item_in_rule_match_with_wrong_user(self):
        """Test no violations are found with single item in rule with a user that doesn't match the rule"""
        processed_rule = {
            'ancestor_resources': [Organization('7890')],
            'users': ['*****@*****.**']
        }

        rule = engine_module.Rule(rule_name='test_single_item_in_rule_match_with_wrong_user',
                                  rule_index=0,
                                  rules=processed_rule)
        violation = rule.find_violation('*****@*****.**',
                                        self.TEST_ANCESTORS)
        self.assertIsNotNone(violation)
Beispiel #3
0
    def test_multi_items_no_match(self):
        """Test violations are found with multiple items in rule"""
        processed_rule = {
            'ancestor_resources': [Folder('45'), Organization('789')]
        }

        rule = engine_module.Rule(rule_name='test_multi_items_no_match',
                                  rule_index=0,
                                  rules=processed_rule)
        violation = rule.find_violation('*****@*****.**',
                                        self.TEST_ANCESTORS)

        self.assertEqual(0, violation.rule_index)
        self.assertEqual('test_multi_items_no_match',
                         violation.rule_name)
        self.assertEqual('projects/123', violation.full_name)
        self.assertEqual('projects/123,folders/456,organizations/7890',
                         violation.resource_data)
Beispiel #4
0
    def test_single_item_no_match_with_wrong_user(self):
        """Test violations are found with single item in rule with user that doesn't match the rule"""
        processed_rule = {
            'ancestor_resources': [Organization('789')],
            'users': ['*****@*****.**']
        }

        rule = engine_module.Rule(rule_name='test_single_item_no_match_with_wrong_user',
                                  rule_index=0,
                                  rules=processed_rule)
        violation = rule.find_violation('*****@*****.**',
                                        self.TEST_ANCESTORS)

        self.assertEqual(0, violation.rule_index)
        self.assertEqual('test_single_item_no_match_with_wrong_user',
                         violation.rule_name)
        self.assertEqual('projects/123', violation.full_name)
        self.assertEqual('projects/123,folders/456,organizations/7890',
                         violation.resource_data)