mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 06:16:03 +00:00
split off add_or_remove_flag() from change_profile_flags()
Also add some tests for add_or_remove_flag()
This commit is contained in:
@@ -13,7 +13,7 @@ import unittest
|
||||
from common_test import AATest, setup_all_loops
|
||||
|
||||
from apparmor.common import AppArmorBug
|
||||
from apparmor.profile_storage import ProfileStorage, split_flags, var_transform
|
||||
from apparmor.profile_storage import ProfileStorage, add_or_remove_flag, split_flags, var_transform
|
||||
|
||||
class TestUnknownKey(AATest):
|
||||
def AASetup(self):
|
||||
@@ -35,6 +35,23 @@ class TestUnknownKey(AATest):
|
||||
with self.assertRaises(AppArmorBug):
|
||||
self.storage['foo'] = 'bar'
|
||||
|
||||
class AaTest_add_or_remove_flag(AATest):
|
||||
tests = [
|
||||
# existing flag(s) flag to change add or remove? expected flags
|
||||
([ [], 'complain', True ], ['complain'] ),
|
||||
([ [], 'complain', False ], [] ),
|
||||
([ ['complain'], 'complain', True ], ['complain'] ),
|
||||
([ ['complain'], 'complain', False ], [] ),
|
||||
([ [], 'audit', True ], ['audit'] ),
|
||||
([ [], 'audit', False ], [] ),
|
||||
([ ['complain'], 'audit', True ], ['audit', 'complain'] ),
|
||||
([ ['complain'], 'audit', False ], ['complain'] ),
|
||||
]
|
||||
|
||||
def _run_test(self, params, expected):
|
||||
new_flags = add_or_remove_flag(params[0], params[1], params[2])
|
||||
self.assertEqual(new_flags, expected)
|
||||
|
||||
class AaTest_split_flags(AATest):
|
||||
tests = [
|
||||
(None , [] ),
|
||||
|
Reference in New Issue
Block a user