2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 06:16:03 +00:00

Make BaseRule a proper abstract base class

This commit is contained in:
Mark Grassi
2022-09-27 22:14:31 -04:00
parent 9107a0d891
commit 852169948f
15 changed files with 167 additions and 128 deletions

View File

@@ -18,7 +18,6 @@ import unittest
import apparmor.severity as severity
from apparmor.common import AppArmorBug, AppArmorException, hasher
from apparmor.logparser import ReadLog
from apparmor.rule import BaseRule
from apparmor.rule.capability import CapabilityRule, CapabilityRuleset
from apparmor.translations import init_translation
from common_test import AATest, setup_all_loops
@@ -393,10 +392,12 @@ class CapabilityCoveredTest(AATest):
self.assertFalse(self._is_covered(obj, 'deny capability,'))
def test_invalid_is_covered(self):
obj = CapabilityRule.create_instance('capability sys_admin,')
testobj = BaseRule() # different type
raw_rule = 'capability sys_admin,'
class SomeOtherClass(CapabilityRule):
pass
obj = CapabilityRule.create_instance(raw_rule)
testobj = SomeOtherClass.create_instance(raw_rule) # different type
with self.assertRaises(AppArmorBug):
obj.is_covered(testobj)
@@ -410,10 +411,12 @@ class CapabilityCoveredTest(AATest):
obj.is_covered(testobj)
def test_invalid_is_equal(self):
obj = CapabilityRule.create_instance('capability sys_admin,')
testobj = BaseRule() # different type
raw_rule = 'capability sys_admin,'
class SomeOtherClass(CapabilityRule):
pass
obj = CapabilityRule.create_instance(raw_rule)
testobj = SomeOtherClass.create_instance(raw_rule) # different type
with self.assertRaises(AppArmorBug):
obj.is_equal(testobj)