2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-30 22:05:27 +00:00

*TestParseInvalid: move tests not matching regex into tests array

This commit is contained in:
Christian Boltz
2025-06-29 18:01:30 +02:00
parent 2a37040415
commit 66cb0af47c
12 changed files with 23 additions and 79 deletions

View File

@@ -128,20 +128,16 @@ class MountTestParseInvalid(AATest):
('priority=-1042 umount,', (AppArmorException, True)),
('mount fstype=({unclosed_regex),', (AppArmorException, True)), # invalid AARE
('mount fstype=({closed}twice}),', (AppArmorException, True)), # invalid AARE
('foo,', (AppArmorException, False)),
('priority=a mount,', (AppArmorException, False)),
('priority=a umount,', (AppArmorException, False)),
('priority=a unmount,', (AppArmorException, False)),
('priority=a remount,', (AppArmorException, False)),
)
def _run_test(self, rawrule, expected):
self.parseInvalidRule(MountRule, rawrule, expected)
def test_parse_fail(self):
with self.assertRaises(AppArmorException):
MountRule.create_instance('foo,')
def test_invalid_priority(self):
for keyword in ['mount', 'umount', 'unmount', 'remount']:
with self.assertRaises(AppArmorException):
MountRule.create_instance('priority=a %s,' % keyword)
def test_invalid_priority_1(self):
with self.assertRaises(TypeError):
MountRule('mount', MountRule.ALL, MountRule.ALL, MountRule.ALL, MountRule.ALL, priority=MountRule.ALL)