mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 14:25:52 +00:00
ProfileList: rename add() to add_profile()
This makes the syntax more clear, and is a preparation to allow adding some more things (like global includes and variable definitions)
This commit is contained in:
@@ -24,53 +24,53 @@ class TestAdd(AATest):
|
||||
self.assertEqual(self.pl.attachments, {})
|
||||
|
||||
def testAdd_1(self):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
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'})
|
||||
|
||||
def testAdd_2(self):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', None, '/bin/foo')
|
||||
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'})
|
||||
|
||||
def testAdd_3(self):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', None)
|
||||
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, {})
|
||||
|
||||
|
||||
def testAddError_1(self):
|
||||
with self.assertRaises(AppArmorBug):
|
||||
self.pl.add('', 'foo', '/bin/foo') # no filename
|
||||
self.pl.add_profile('', 'foo', '/bin/foo') # no filename
|
||||
|
||||
def testAddError_2(self):
|
||||
with self.assertRaises(AppArmorBug):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', None, None) # neither attachment or profile name
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', None, None) # neither attachment or profile name
|
||||
|
||||
def testAddError_twice_1(self):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
with self.assertRaises(AppArmorException):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
|
||||
def testAddError_twice_2(self):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
with self.assertRaises(AppArmorException):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', None)
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', None)
|
||||
|
||||
def testAddError_twice_3(self):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', None, '/bin/foo')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', None, '/bin/foo')
|
||||
with self.assertRaises(AppArmorException):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
|
||||
def testAddError_twice_4(self):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', None, '/bin/foo')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', None, '/bin/foo')
|
||||
with self.assertRaises(AppArmorException):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
|
||||
def testAddError_twice_5(self):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', None)
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', None)
|
||||
with self.assertRaises(AppArmorException):
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
|
||||
class TestFilename_from_profile_name(AATest):
|
||||
tests = [
|
||||
@@ -83,8 +83,8 @@ class TestFilename_from_profile_name(AATest):
|
||||
|
||||
def AASetup(self):
|
||||
self.pl = ProfileList()
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
self.pl.add('/etc/apparmor.d/usr.bin.wine', '/usr{,{/lib,/lib32,/lib64}/wine}/bin/wine{,-preloader,server}{,-staging-*,-vanilla-*}', '/usr{,{/lib,/lib32,/lib64}/wine}/bin/wine{,-preloader,server}{,-staging-*,-vanilla-*}')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
self.pl.add_profile('/etc/apparmor.d/usr.bin.wine', '/usr{,{/lib,/lib32,/lib64}/wine}/bin/wine{,-preloader,server}{,-staging-*,-vanilla-*}', '/usr{,{/lib,/lib32,/lib64}/wine}/bin/wine{,-preloader,server}{,-staging-*,-vanilla-*}')
|
||||
|
||||
def _run_test(self, params, expected):
|
||||
self.assertEqual(self.pl.filename_from_profile_name(params), expected)
|
||||
@@ -102,10 +102,10 @@ class TestFilename_from_attachment(AATest):
|
||||
|
||||
def AASetup(self):
|
||||
self.pl = ProfileList()
|
||||
self.pl.add('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
self.pl.add('/etc/apparmor.d/bin.baz', 'baz', '/bin/ba*')
|
||||
self.pl.add('/etc/apparmor.d/bin.foobar', 'foobar', '/bin/foo{bar,baz}')
|
||||
self.pl.add('/etc/apparmor.d/usr.bin.wine', '/usr{,{/lib,/lib32,/lib64}/wine}/bin/wine{,-preloader,server}{,-staging-*,-vanilla-*}', '/usr{,{/lib,/lib32,/lib64}/wine}/bin/wine{,-preloader,server}{,-staging-*,-vanilla-*}')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo', '/bin/foo')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.baz', 'baz', '/bin/ba*')
|
||||
self.pl.add_profile('/etc/apparmor.d/bin.foobar', 'foobar', '/bin/foo{bar,baz}')
|
||||
self.pl.add_profile('/etc/apparmor.d/usr.bin.wine', '/usr{,{/lib,/lib32,/lib64}/wine}/bin/wine{,-preloader,server}{,-staging-*,-vanilla-*}', '/usr{,{/lib,/lib32,/lib64}/wine}/bin/wine{,-preloader,server}{,-staging-*,-vanilla-*}')
|
||||
|
||||
def _run_test(self, params, expected):
|
||||
self.assertEqual(self.pl.filename_from_attachment(params), expected)
|
||||
|
Reference in New Issue
Block a user