mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 18:17:09 +00:00
ChangeProfileTestParseInvalid: allow tests that match the regex
(even if the existing tests all don't match it)
This commit is contained in:
parent
6d2a0f6ba7
commit
58f5c2b7e8
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# Copyright (C) 2015 Christian Boltz <apparmor@cboltz.de>
|
# Copyright (C) 2015-2025 Christian Boltz <apparmor@cboltz.de>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of version 2 of the GNU General Public
|
# modify it under the terms of version 2 of the GNU General Public
|
||||||
@ -84,15 +84,17 @@ class ChangeProfileTestParse(ChangeProfileTest):
|
|||||||
|
|
||||||
class ChangeProfileTestParseInvalid(ChangeProfileTest):
|
class ChangeProfileTestParseInvalid(ChangeProfileTest):
|
||||||
tests = (
|
tests = (
|
||||||
('change_profile -> ,', AppArmorException),
|
# rule exception, matches regex?
|
||||||
('change_profile foo -> ,', AppArmorException),
|
('change_profile -> ,', (AppArmorException, False)),
|
||||||
('change_profile notsafe,', AppArmorException),
|
('change_profile foo -> ,', (AppArmorException, False)),
|
||||||
('change_profile safety -> /bar,', AppArmorException),
|
('change_profile notsafe,', (AppArmorException, False)),
|
||||||
|
('change_profile safety -> /bar,', (AppArmorException, False)),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _run_test(self, rawrule, expected):
|
def _run_test(self, rawrule, expected):
|
||||||
self.assertFalse(ChangeProfileRule.match(rawrule))
|
exp_exception, matches_regex = expected
|
||||||
with self.assertRaises(expected):
|
self.assertEqual(matches_regex, ChangeProfileRule.match(rawrule)) # does the invalid rules still match the main regex?
|
||||||
|
with self.assertRaises(exp_exception):
|
||||||
ChangeProfileRule.create_instance(rawrule)
|
ChangeProfileRule.create_instance(rawrule)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user