From deaa692aa2793bf2bbece82f4bc5ef86dc768230 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Fri, 26 Sep 2014 22:03:14 +0200 Subject: [PATCH] test if aa-enforce removes force-complain symlinks Two weeks ago, I fixed various tests in minitools_test.py which also included disabling the test if aa-complain deletes the force-complain symlink because nothing (especially aa-complain) creates those symlinks. Seth didn't like the removal of that test too much. Therefore this patch "manually" creates the force-complain symlink and tests that it's removed by aa-enforce. Acked-by: Seth Arnold --- utils/test/minitools_test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/utils/test/minitools_test.py b/utils/test/minitools_test.py index 31e4027f1..577d4506f 100755 --- a/utils/test/minitools_test.py +++ b/utils/test/minitools_test.py @@ -47,8 +47,12 @@ class Test(unittest.TestCase): def test_complain(self): #Set ntpd profile to complain mode and check if it was correctly set subprocess.check_output('%s ./../aa-complain -d ./profiles %s'%(python_interpreter, test_path), shell=True) + + # "manually" create a force-complain symlink (will be deleted by aa-enforce later) + os.mkdir('./profiles/force-complain') + os.symlink(local_profilename, './profiles/force-complain/%s'%os.path.basename(local_profilename) ) -# self.assertEqual(os.path.islink('./profiles/force-complain/%s'%os.path.basename(local_profilename)), True, 'Failed to create a symlink for %s in force-complain'%local_profilename) + self.assertEqual(os.path.islink('./profiles/force-complain/%s'%os.path.basename(local_profilename)), True, 'Failed to create a symlink for %s in force-complain'%local_profilename) self.assertEqual(apparmor.get_profile_flags(local_profilename, test_path), 'complain', 'Complain flag could not be set in profile %s'%local_profilename) #Set ntpd profile to enforce mode and check if it was correctly set @@ -61,8 +65,10 @@ class Test(unittest.TestCase): # Set audit flag and then complain flag in a profile subprocess.check_output('%s ./../aa-audit -d ./profiles %s'%(python_interpreter, test_path), shell=True) subprocess.check_output('%s ./../aa-complain -d ./profiles %s'%(python_interpreter, test_path), shell=True) + # "manually" create a force-complain symlink (will be deleted by aa-enforce later) + os.symlink(local_profilename, './profiles/force-complain/%s'%os.path.basename(local_profilename) ) -# self.assertEqual(os.path.islink('./profiles/force-complain/%s'%os.path.basename(local_profilename)), True, 'Failed to create a symlink for %s in force-complain'%local_profilename) + self.assertEqual(os.path.islink('./profiles/force-complain/%s'%os.path.basename(local_profilename)), True, 'Failed to create a symlink for %s in force-complain'%local_profilename) self.assertEqual(apparmor.get_profile_flags(local_profilename, test_path), 'audit,complain', 'Complain flag could not be set in profile %s'%local_profilename) #Remove complain flag first i.e. set to enforce mode