Hello, test_parse_modifiers_invalid() uses a hand-broken ;-) regex to parse only the allow/deny/audit keywords. This test applies to all rule types and doesn't contain anything specific to capability or other rules, therefore it should live in test-baserule.py.
Moving that test also means to move the imports for parse_modifiers and re around (nothing else in test-capability.py needs them). For obvious reasons, this patch depends on 41-add-baserule-tests.diff ;-) [ 47-move-test_parse_modifiers_invalid-to-test-baserule.diff ] === modified file utils/test/test-baserule.py --- utils/test/test-baserule.py 2015-04-17 22:36:32.745686482 +0200 +++ utils/test/test-baserule.py 2015-04-19 23:28:35.648314110 +0200 @@ -13,7 +13,9 @@ from common_test import AATest, setup_all_loops from apparmor.common import AppArmorBug -from apparmor.rule import BaseRule +from apparmor.rule import BaseRule, parse_modifiers + +import re class TestBaserule(AATest): def test_abstract__parse(self): @@ -30,6 +32,14 @@ with self.assertRaises(AppArmorBug): obj.is_covered_localvars(None) + def test_parse_modifiers_invalid(self): + regex = re.compile('^\s*(?P<audit>audit\s+)?(?P<allow>allow\s+|deny\s+|invalid\s+)?') + matches = regex.search('audit invalid ') + + with self.assertRaises(AppArmorBug): + parse_modifiers(matches) + + setup_all_loops(__name__) if __name__ == '__main__': === modified file utils/test/test-capability.py --- utils/test/test-capability.py 2015-04-16 02:18:03.865500000 +0200 +++ utils/test/test-capability.py 2015-04-19 23:28:50.600457562 +0200 @@ -16,12 +16,10 @@ import unittest from apparmor.rule.capability import CapabilityRule, CapabilityRuleset -from apparmor.rule import BaseRule, parse_modifiers +from apparmor.rule import BaseRule from apparmor.common import AppArmorException, AppArmorBug, hasher from apparmor.logparser import ReadLog -import re - # --- tests for single CapabilityRule --- # class CapabilityTest(unittest.TestCase): @@ -230,13 +228,6 @@ def test_invalid_cap_non_CapabilityRule(self): self._check_invalid_rawrule('network,') # not a capability rule - def test_parse_modifiers_invalid(self): - regex = re.compile('^\s*(?P<audit>audit\s+)?(?P<allow>allow\s+|deny\s+|invalid\s+)?') - matches = regex.search('audit invalid ') - - with self.assertRaises(AppArmorBug): - parse_modifiers(matches) - def test_empty_cap_set(self): obj = CapabilityRule('chown') obj.capability.clear() Regards, Christian Boltz -- P.S.: Christian, ich bereite schonmal deine Antwort vor: [...] |Glaubst du mir jetzt, daß CVS Kommentare hilfreich sind *g* |[Liste der von Ratti vergessenen Änderungen, direkt mit sed awk grep |find echo erstellt aus irgendeiner ~/.cvs/.hidden/.cvs_obscure-Datei..] [Ratti in fontlinge-devel] -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor