mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Write a test for aa_splitcon's SWIG bindings
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
This commit is contained in:
parent
c471acbe44
commit
48901f2118
1 changed files with 25 additions and 0 deletions
|
@ -61,6 +61,31 @@ class AAPythonBindingsTests(unittest.TestCase):
|
|||
# REPORT ALL THE OUTPUT
|
||||
self.maxDiff = None
|
||||
|
||||
def test_aa_splitcon(self):
|
||||
AA_SPLITCON_EXPECT = [
|
||||
("unconfined", "unconfined", None),
|
||||
("unconfined\n", "unconfined", None),
|
||||
("/bin/ping (enforce)", "/bin/ping", "enforce"),
|
||||
("/bin/ping (enforce)\n", "/bin/ping", "enforce"),
|
||||
("/usr/sbin/rsyslog (complain)", "/usr/sbin/rsyslog", "complain"),
|
||||
]
|
||||
for context, expected_label, expected_mode in AA_SPLITCON_EXPECT:
|
||||
actual_label, actual_mode = libapparmor.aa_splitcon(context)
|
||||
if expected_label is None:
|
||||
self.assertIsNone(actual_label)
|
||||
else:
|
||||
self.assertIsInstance(actual_label, str)
|
||||
self.assertEqual(expected_label, actual_label)
|
||||
|
||||
if expected_mode is None:
|
||||
self.assertIsNone(actual_mode)
|
||||
else:
|
||||
self.assertIsInstance(actual_mode, str)
|
||||
self.assertEqual(expected_mode, actual_mode)
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
libapparmor.aa_splitcon("")
|
||||
|
||||
def test_enabled_and_find_mountpoint(self):
|
||||
aa_enabled = libapparmor.aa_is_enabled()
|
||||
self.assertIsInstance(aa_enabled, bool)
|
||||
|
|
Loading…
Add table
Reference in a new issue