mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 14:25:52 +00:00
Move test_parse_modifiers_invalid() to test-baserule.py
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). Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
This commit is contained in:
@@ -13,7 +13,9 @@ import unittest
|
||||
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 @@ class TestBaserule(AATest):
|
||||
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__':
|
||||
|
Reference in New Issue
Block a user