2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-06 01:05:11 +00:00

Write test for aa_gettaskcon SWIG wrapper

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
(cherry picked from commit 53e3116350)
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
Ryan Lee
2024-10-03 17:22:58 -07:00
committed by John Johansen
parent e9429a9eaa
commit 82f815c587

View File

@@ -116,6 +116,16 @@ class AAPythonBindingsTests(unittest.TestCase):
# extern int aa_getprocattr(pid_t tid, const char *attr, char **label, char **mode);
# extern int aa_gettaskcon(pid_t target, char **label, char **mode);
@unittest.skipUnless(libapparmor.aa_is_enabled(), "AppArmor is not enabled")
def test_aa_gettaskcon(self):
# Our test harness should be running us as unconfined
# Get our own pid and this should be equivalent to aa_getcon
pid = os.getpid()
label, mode = libapparmor.aa_gettaskcon(pid)
self.assertEqual(label, "unconfined", "aa_gettaskcon label should be unconfined")
self.assertIsNone(mode, "aa_gettaskcon mode should be unconfined")
@unittest.skipUnless(libapparmor.aa_is_enabled(), "AppArmor is not enabled")
def test_aa_getcon(self):
# Our test harness should be running us as unconfined