Beispiel #1
0
 def setUp(self):
     super(TestStatusModel, self).setUp()
     services = api_base.setup_config()
     self.policy_model = services['api']['api-policy']
     self.rule_model = services['api']['api-rule']
     self.status_model = services['api']['api-status']
     self.node = services['node']
     self.datasource = services['data']
Beispiel #2
0
    def setUp(self):
        super(BaseTestPolicyCongress, self).setUp()
        self.services = api_base.setup_config(with_fake_datasource=False)
        self.api = self.services['api']
        self.node = self.services['node']
        self.engine = self.services['engine']

        self.neutronv2 = self._create_neutron_mock('neutron')
Beispiel #3
0
 def setUp(self):
     super(TestRowModel, self).setUp()
     services = api_base.setup_config()
     self.policy_model = services['api']['api-policy']
     self.rule_model = services['api']['api-rule']
     self.row_model = services['api']['api-row']
     self.node = services['node']
     self.data = services['data']
Beispiel #4
0
    def setUp(self):
        """Setup tests that use multiple mock neutron instances."""
        super(TestCongress, self).setUp()
        self.services = api_base.setup_config(with_fake_datasource=False)
        self.api = self.services['api']
        self.node = self.services['node']
        self.engine = self.services['engine']

        self.neutronv2 = self._create_neutron_mock('neutron')
 def setUp(self):
     super(TestDatasourceModel, self).setUp()
     services = api_base.setup_config()
     self.datasource_model = services['api']['api-datasource']
     self.data = services['data']
     self.node = services['node']
     self.engine = services['engine']
     self.datasource = self._get_datasource_request()
     self.node.add_datasource(self.datasource)
Beispiel #6
0
    def setUp(self):
        super(TestPolicyModel, self).setUp()

        services = api_base.setup_config()
        self.policy_model = services['api']['api-policy']
        self.rule_api = services['api']['api-rule']
        self.node = services['node']
        self.engine = services['engine']
        self.initial_policies = set(self.engine.policy_names())
        self._add_test_policy()
 def setUp(self):
     super(TestDatasourceModel, self).setUp()
     self.datasource_model = datasource_model.DatasourceModel(
         'test_datasource', policy_engine='engine')
     self.config = api_base.setup_config([self.datasource_model])
     self.data = self.config['data']
     self.node = self.config['node']
     self.engine = self.config['engine']
     self.datasource = self._get_datasource_request()
     self.node.add_datasource(self.datasource)
Beispiel #8
0
 def setUp(self):
     super(TestRowModel, self).setUp()
     self.policy_model = policy_model.PolicyModel(
         'api-policy', policy_engine='engine')
     self.rule_model = rule_model.RuleModel('api-rule',
                                            policy_engine='engine')
     self.row_model = row_model.RowModel('api-row', policy_engine='engine')
     result = api_base.setup_config([self.policy_model, self.rule_model,
                                     self.row_model])
     self.node = result['node']
     self.data = result['data']
Beispiel #9
0
 def setUp(self):
     super(TestTableModel, self).setUp()
     services = api_base.setup_config()
     self.policy_model = services['api']['api-policy']
     self.table_model = services['api']['api-table']
     self.api_rule = services['api']['api-rule']
     self.node = services['node']
     self.engine = services['engine']
     self.data = services['data']
     # create test policy
     self._create_test_policy()
Beispiel #10
0
    def setUp(self):
        super(TestRuleModel, self).setUp()

        services = api_base.setup_config()
        self.policy_model = services['api']['api-policy']
        self.rule_model = services['api']['api-rule']
        self.node = services['node']

        self.action_policy = self.policy_model.get_item('action', {})
        self.context = {'policy_id': self.action_policy["name"]}
        self._add_test_rule()
 def setUp(self):
     super(TestStatusModel, self).setUp()
     self.policy_model = policy_model.PolicyModel('api-policy',
                                                  policy_engine='engine')
     self.rule_model = rule_model.RuleModel('api-rule',
                                            policy_engine='engine')
     self.status_model = status_model.StatusModel('api-status',
                                                  policy_engine='engine')
     result = api_base.setup_config([self.policy_model, self.rule_model,
                                     self.status_model])
     self.node = result['node']
     self.datasource = result['data']
Beispiel #12
0
    def setUp(self):
        super(TestRuleModel, self).setUp()

        self.rule_model = rule_model.RuleModel('api-rule',
                                               policy_engine='engine')
        self.policy_model = policy_model.PolicyModel('api-policy',
                                                     policy_engine='engine')
        result = api_base.setup_config([self.policy_model, self.rule_model])
        self.node = result['node']
        self.policy_model.add_item({'name': 'classification'}, {})
        self.action_policy = self._add_action_policy()
        self.context = {'policy_id': self.action_policy["name"]}
        self._add_test_rule()
    def setUp(self):
        super(TestPolicyModel, self).setUp()

        self.policy_model = policy_model.PolicyModel('api-policy',
                                                     policy_engine='engine')
        self.rule_api = rule_model.RuleModel('api-rule',
                                             policy_engine='engine')
        services = api_base.setup_config([self.policy_model, self.rule_api])
        self.node = services['node']
        self.engine = services['engine']
        self.initial_policies = set(self.engine.policy_names())
        # Add default policy
        self.policy_model.add_item({'name': 'classification'}, {})
        self._add_test_policy()
Beispiel #14
0
    def setUp(self):
        super(TestTableModel, self).setUp()
        # Here we load the fake driver
        cfg.CONF.set_override(
            'drivers',
            ['congress.tests.fake_datasource.FakeDataSource'])

        self.table_model = table_model.TableModel('api-table',
                                                  policy_engine='engine')
        self.api_rule = rule_model.RuleModel('api-rule',
                                             policy_engine='engine')
        self.policy_model = policy_model.PolicyModel('api-policy',
                                                     policy_engine='engine')
        result = api_base.setup_config([self.table_model, self.api_rule,
                                        self.policy_model])
        self.node = result['node']
        self.engine = result['engine']
        self.data = result['data']
        # create test policy
        self._create_test_policy()
    def test_enable_schema(self, patched_persisted_rules):
        class TestRule(object):
            def __init__(self, id, name, rule_str,
                         policy_name, comment=None):
                self.id = id
                self.name = name
                self.rule = rule_str
                self.policy_name = policy_name
                self.comment = comment

        persisted_rule = [
            TestRule('rule-id', 'rule-name',
                     "p(x):-nova:services(id=x)", 'classification'),
            ]
        patched_persisted_rules.return_value = persisted_rule

        services = api_base.setup_config()
        engine2 = services['engine']
        node = services['node']

        node.invoke_service_rpc = mock.MagicMock()
        node.invoke_service_rpc.return_value = [
            ['id1', 'name1', 'status1'],
            ['id2', 'name2', 'status2'],
            ]

        # loaded rule is disabled
        subscriptions = engine2.subscription_list()
        self.assertEqual([], subscriptions)

        nova_schema = {
            'services': [
                {'name': 'id', 'desc': 'id of the service'},
                {'name': 'name', 'desc': 'name of the service'},
                {'name': 'status', 'desc': 'status of the service'}]}

        engine2.initialize_datasource('nova', nova_schema)
        # loaded rule is enabled and subscribes the table
        subscriptions = engine2.subscription_list()
        self.assertEqual([('nova', 'services')], subscriptions)
Beispiel #16
0
 def setUp(self):
     super(TestActionModel, self).setUp()
     services = api_base.setup_config()
     self.action_model = services['api']['api-action']
     self.datasource = services['data']
 def setUp(self):
     super(TestSchemaModel, self).setUp()
     self.schema_model = schema_model.SchemaModel("test_schema", {})
     self.config = api_base.setup_config([self.schema_model])
     self.data = self.config['data']
Beispiel #18
0
 def setUp(self):
     super(TestSchemaModel, self).setUp()
     services = api_base.setup_config()
     self.schema_model = services['api']['api-schema']
     self.data = services['data']