mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 06:16:03 +00:00
Add profiles_in_file() to ProfileList
... and some tests for it.
This commit is contained in:
@@ -28,16 +28,19 @@ class TestAdd_profile(AATest):
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
self.assertEqual(self.pl.profile_names, {'foo': '/etc/apparmor.d/bin.foo'})
|
||||
self.assertEqual(self.pl.attachments, {'/bin/foo': '/etc/apparmor.d/bin.foo'})
|
||||
self.assertEqual(self.pl.profiles_in_file('/etc/apparmor.d/bin.foo'), ['foo'])
|
||||
|
||||
def testAdd_profile_2(self):
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', None, '/bin/foo')
|
||||
self.assertEqual(self.pl.profile_names, {})
|
||||
self.assertEqual(self.pl.attachments, {'/bin/foo': '/etc/apparmor.d/bin.foo'})
|
||||
self.assertEqual(self.pl.profiles_in_file('/etc/apparmor.d/bin.foo'), ['/bin/foo'])
|
||||
|
||||
def testAdd_profile_3(self):
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', None)
|
||||
self.assertEqual(self.pl.profile_names, {'foo': '/etc/apparmor.d/bin.foo'})
|
||||
self.assertEqual(self.pl.attachments, {})
|
||||
self.assertEqual(self.pl.profiles_in_file('/etc/apparmor.d/bin.foo'), ['foo'])
|
||||
|
||||
|
||||
def testAdd_profileError_1(self):
|
||||
@@ -48,6 +51,11 @@ class TestAdd_profile(AATest):
|
||||
with self.assertRaises(AppArmorBug):
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', None, None) # neither attachment or profile name
|
||||
|
||||
def testAdd_profileError_list_nonexisting_file(self):
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', None)
|
||||
with self.assertRaises(AppArmorBug):
|
||||
self.pl.profiles_in_file('/etc/apparmor.d/not.found') # different filename
|
||||
|
||||
def testAdd_profileError_twice_1(self):
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
with self.assertRaises(AppArmorException):
|
||||
|
Reference in New Issue
Block a user