コード例 #1
0
ファイル: test-network.py プロジェクト: youngker/apparmor
 def test_empty_ruleset(self):
     ruleset = NetworkRuleset()
     ruleset_2 = NetworkRuleset()
     self.assertEqual([], ruleset.get_raw(2))
     self.assertEqual([], ruleset.get_clean(2))
     self.assertEqual([], ruleset_2.get_raw(2))
     self.assertEqual([], ruleset_2.get_clean(2))
コード例 #2
0
ファイル: test-network.py プロジェクト: crossbuild/apparmor
 def test_empty_ruleset(self):
     ruleset = NetworkRuleset()
     ruleset_2 = NetworkRuleset()
     self.assertEqual([], ruleset.get_raw(2))
     self.assertEqual([], ruleset.get_clean(2))
     self.assertEqual([], ruleset_2.get_raw(2))
     self.assertEqual([], ruleset_2.get_clean(2))
コード例 #3
0
    def test_ruleset_2(self):
        ruleset = NetworkRuleset()
        rules = [
            'network inet6 raw,',
            'allow network inet,',
            'deny network udp, # example comment',
        ]

        expected_raw = [
            '  network inet6 raw,',
            '  allow network inet,',
            '  deny network udp, # example comment',
            '',
        ]

        expected_clean = [
            '  deny network udp, # example comment',
            '',
            '  allow network inet,',
            '  network inet6 raw,',
            '',
        ]

        for rule in rules:
            ruleset.add(NetworkRule.parse(rule))

        self.assertEqual(expected_raw, ruleset.get_raw(1))
        self.assertEqual(expected_clean, ruleset.get_clean(1))
コード例 #4
0
ファイル: test-network.py プロジェクト: crossbuild/apparmor
    def test_ruleset_2(self):
        ruleset = NetworkRuleset()
        rules = [
            'network inet6 raw,',
            'allow network inet,',
            'deny network udp, # example comment',
        ]

        expected_raw = [
            '  network inet6 raw,',
            '  allow network inet,',
            '  deny network udp, # example comment',
            '',
        ]

        expected_clean = [
            '  deny network udp, # example comment',
            '',
            '  allow network inet,',
            '  network inet6 raw,',
            '',
        ]

        for rule in rules:
            ruleset.add(NetworkRule.parse(rule))

        self.assertEqual(expected_raw, ruleset.get_raw(1))
        self.assertEqual(expected_clean, ruleset.get_clean(1))
コード例 #5
0
    def test_ruleset_1(self):
        ruleset = NetworkRuleset()
        rules = [
            'network tcp,',
            'network inet,',
        ]

        expected_raw = [
            'network tcp,',
            'network inet,',
            '',
        ]

        expected_clean = [
            'network inet,',
            'network tcp,',
            '',
        ]

        for rule in rules:
            ruleset.add(NetworkRule.parse(rule))

        self.assertEqual(expected_raw, ruleset.get_raw())
        self.assertEqual(expected_clean, ruleset.get_clean())
コード例 #6
0
ファイル: test-network.py プロジェクト: crossbuild/apparmor
    def test_ruleset_1(self):
        ruleset = NetworkRuleset()
        rules = [
            'network tcp,',
            'network inet,',
        ]

        expected_raw = [
            'network tcp,',
            'network inet,',
            '',
        ]

        expected_clean = [
            'network inet,',
            'network tcp,',
            '',
        ]

        for rule in rules:
            ruleset.add(NetworkRule.parse(rule))

        self.assertEqual(expected_raw, ruleset.get_raw())
        self.assertEqual(expected_clean, ruleset.get_clean())