示例#1
0
    def test_load_multiple_rules_chain(self):
        """ Tests if chain data with multiple rules can be correctly loaded from
            the yaml file.
        """
        self._load_chain_data(self._multiple_rules_chain)

        rule = self._chain.get_rule(101)
        self.assertNotEqual(None, rule)
        self.assertEqual(101, rule.get_id())
        self.assertEqual(1, rule.get_chain_id())
        self.assertEqual('drop', rule.get_type())

        rule = self._chain.get_rule(102)
        self.assertNotEqual(None, rule)
        self.assertEqual(102, rule.get_id())
        self.assertEqual(1, rule.get_chain_id())
        self.assertEqual('accept', rule.get_type())

        self._mock_chain.tenant_id.assert_called_with('tenant_0')
        self._mock_chain.name.assert_called_with('in_filter_001')
        self._mock_chain.create.assert_called_with()
        self.assertEqual([call.chain_id('chain_0'),
                          call.position(1),
                          call.dl_type(0x86DD),
                          call.type('drop'),
                          call.create(),
                          call.chain_id('chain_0'),
                          call.position(2),
                          call.type('accept'),
                          call.create()], self._mock_rule.mock_calls)
示例#2
0
    def test_load_multiple_rules_chain(self):
        """ Tests if chain data with multiple rules can be correctly loaded from
            the yaml file.
        """
        self._load_chain_data(self._multiple_rules_chain)

        rule = self._chain.get_rule(101)
        self.assertNotEqual(None, rule)
        self.assertEqual(101, rule.get_id())
        self.assertEqual(1, rule.get_chain_id())
        self.assertEqual("drop", rule.get_type())

        rule = self._chain.get_rule(102)
        self.assertNotEqual(None, rule)
        self.assertEqual(102, rule.get_id())
        self.assertEqual(1, rule.get_chain_id())
        self.assertEqual("accept", rule.get_type())

        self._mock_chain.tenant_id.assert_called_with("tenant_0")
        self._mock_chain.name.assert_called_with("in_filter_001")
        self._mock_chain.create.assert_called_with()
        self.assertEqual(
            [
                call.chain_id("chain_0"),
                call.position(1),
                call.dl_type(0x86DD),
                call.type("drop"),
                call.create(),
                call.chain_id("chain_0"),
                call.position(2),
                call.type("accept"),
                call.create(),
            ],
            self._mock_rule.mock_calls,
        )
示例#3
0
    def test_load_rule_chain(self):
        """ Tests if rule chain data can be correctly loaded from the yaml
            file and corresponding resource creation / update operations are
            performed.
        """
        self._load_chain_data(self._simple_chain)

        rule = self._chain.get_rule(101)
        self.assertNotEqual(None, rule)
        self.assertEqual(101, rule.get_id())
        self.assertEqual(1, rule.get_chain_id())
        self.assertEqual("drop", rule.get_type())

        self._mock_chain.tenant_id.assert_called_with("tenant_0")
        self._mock_chain.name.assert_called_with("in_filter_001")
        self._mock_chain.create.assert_called_with()
        self.assertEqual(
            [call.chain_id("chain_0"), call.position(1), call.dl_type(0x86DD), call.type("drop"), call.create()],
            self._mock_rule.mock_calls,
        )
示例#4
0
    def test_load_rule_chain(self):
        """ Tests if rule chain data can be correctly loaded from the yaml
            file and corresponding resource creation / update operations are
            performed.
        """
        self._load_chain_data(self._simple_chain)

        rule = self._chain.get_rule(101)
        self.assertNotEqual(None, rule)
        self.assertEqual(101, rule.get_id())
        self.assertEqual(1, rule.get_chain_id())
        self.assertEqual('drop', rule.get_type())

        self._mock_chain.tenant_id.assert_called_with('tenant_0')
        self._mock_chain.name.assert_called_with('in_filter_001')
        self._mock_chain.create.assert_called_with()
        self.assertEqual([call.chain_id('chain_0'),
                          call.position(1),
                          call.dl_type(0x86DD),
                          call.type('drop'),
                          call.create()], self._mock_rule.mock_calls)