コード例 #1
0
 def test_group_with_undefined_triggers(self):
     """Create the policy engine even when triggers are undefined"""
     config = {
         'groups': {
             'group1': {
                 'policies': {
                     'some_policy': {
                         'type': 'policy1',
                         'triggers': {
                             'some_trigger': {
                                 'type': 'nonexistent'
                             }
                         }
                     }
                 }
             },
         },
         'policy_types': {
             'policy1': {
                 'source': 'foo.clj'
             }
         },
         'policy_triggers': {
             'trigger1': {
                 'source': 'bar.clj'
             }
         }
     }
     self.assertTrue(_should_create_policy_engine_core(config))
コード例 #2
0
    def test_group_with_no_triggers(self):
        """Create the policy engine even if no policy declares any triggers

        A policy type could potentially run any code with side effects,
        so we need to make sure it runs even if there's no triggers for it.
        """
        config = {
            'groups': {
                'group1': {
                    'policies': {
                        'some_policy': {
                            'type': 'policy1',
                            'triggers': {}
                        }
                    }
                },
            },
            'policy_types': {
                'policy1': {
                    'source': 'foo.clj'
                }
            },
            'policy_triggers': {
                'trigger1': {
                    'source': 'bar.clj'
                }
            }
        }
        self.assertTrue(_should_create_policy_engine_core(config))
コード例 #3
0
 def test_group_with_defined_policies(self):
     "Run the policy engine when a group declares types and triggers"
     config = {
         'groups': {
             'group1': {
                 'policies': {
                     'some_policy': {
                         'type': 'policy1',
                         'triggers': {
                             'some_trigger': {
                                 'type': 'trigger1'
                             }
                         }
                     }
                 }
             },
         },
         'policy_types': {
             'policy1': {
                 'source': 'foo.clj'
             }
         },
         'policy_triggers': {
             'trigger1': {
                 'source': 'bar.clj'
             }
         }
     }
     self.assertTrue(_should_create_policy_engine_core(config))
コード例 #4
0
 def test_empty_group(self):
     "Policy engine is not needed when no group defines policies"
     config = {
         'groups': {'group1': {'policies': {}}},
         'policy_types': {'policy1': {'source': 'foo.clj'}},
         'policy_triggers': {'trigger1': {'source': 'bar.clj'}}
     }
     self.assertFalse(_should_create_policy_engine_core(config))
コード例 #5
0
 def test_no_groups(self):
     "Policy engine is not needed when there are no groups defined"
     config = {
         'groups': {},
         'policy_types': {'policy1': {'source': 'foo.clj'}},
         'policy_triggers': {'trigger1': {'source': 'bar.clj'}}
     }
     self.assertFalse(_should_create_policy_engine_core(config))
コード例 #6
0
 def test_group_with_undefined_policy_type(self):
     "Policy engine is not needed when the only declared group doesnt exist"
     config = {
         'groups': {
             'group1': {
                 'policies': {
                     'some_policy': {
                         'type': 'nonexistent'
                     }
                 }
             },
         },
         'policy_types': {'policy1': {'source': 'foo.clj'}},
         'policy_triggers': {'trigger1': {'source': 'bar.clj'}}
     }
     self.assertFalse(_should_create_policy_engine_core(config))