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:
@@ -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 @@ class InvalidCapabilityTest(unittest.TestCase):
|
||||
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()
|
||||
|
Reference in New Issue
Block a user