2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 06:16:03 +00:00

move splitting flags into profile_storage split_flags() function

... and change change_profile_flags() to use it instead of doing it
itsself

Also add some tests for split_flags()
This commit is contained in:
Christian Boltz
2018-07-25 20:33:52 +02:00
parent 9d78694b00
commit ce7ea062c5
3 changed files with 30 additions and 12 deletions

View File

@@ -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, var_transform
from apparmor.profile_storage import ProfileStorage, split_flags, var_transform
class TestUnknownKey(AATest):
def AASetup(self):
@@ -35,6 +35,22 @@ class TestUnknownKey(AATest):
with self.assertRaises(AppArmorBug):
self.storage['foo'] = 'bar'
class AaTest_split_flags(AATest):
tests = [
(None , [] ),
('' , [] ),
(' ' , [] ),
(' , ' , [] ),
('complain' , ['complain'] ),
(' complain attach_disconnected' , ['attach_disconnected', 'complain'] ),
(' complain , attach_disconnected' , ['attach_disconnected', 'complain'] ),
(' complain , , audit , , ' , ['audit', 'complain'] ),
]
def _run_test(self, params, expected):
split = split_flags(params)
self.assertEqual(split, expected)
class AaTest_var_transform(AATest):
tests = [
(['foo', ''], '"" foo' ),