2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-03 15:55:46 +00:00

Add (abstract) get_clean() method to baserule

Also add a test to ensure it raises an AppArmorBug.


Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
This commit is contained in:
Christian Boltz
2015-10-28 22:52:07 +01:00
parent e700eb04d4
commit cc9cf967b2
2 changed files with 10 additions and 0 deletions

View File

@@ -81,6 +81,11 @@ class BaseRule(object):
required to be implemented by subclasses; raise exception if not''' required to be implemented by subclasses; raise exception if not'''
raise AppArmorBug("'%s' needs to implement _parse(), but didn't" % (str(cls))) raise AppArmorBug("'%s' needs to implement _parse(), but didn't" % (str(cls)))
# @abstractmethod FIXME - uncomment when python3 only
def get_clean(self, depth=0):
'''return clean rule (with default formatting, and leading whitespace as specified in the depth parameter)'''
raise AppArmorBug("'%s' needs to implement get_clean(), but didn't" % (str(self.__class__)))
def get_raw(self, depth=0): def get_raw(self, depth=0):
'''return raw rule (with original formatting, and leading whitespace in the depth parameter)''' '''return raw rule (with original formatting, and leading whitespace in the depth parameter)'''
if self.raw_rule: if self.raw_rule:

View File

@@ -35,6 +35,11 @@ class TestBaserule(AATest):
with self.assertRaises(AppArmorBug): with self.assertRaises(AppArmorBug):
BaseRule.match('foo') BaseRule.match('foo')
def test_abstract_get_clean(self):
obj = BaseRule()
with self.assertRaises(AppArmorBug):
obj.get_clean()
def test_is_equal_localvars(self): def test_is_equal_localvars(self):
obj = BaseRule() obj = BaseRule()
with self.assertRaises(AppArmorBug): with self.assertRaises(AppArmorBug):