ProfileList: add get_all_profiles()

... and a test for it
This commit is contained in:
Christian Boltz 2024-11-01 20:18:23 +01:00
parent c93d560f89
commit 531f47676d
Failed to generate hash of commit
2 changed files with 7 additions and 1 deletions

View file

@ -189,6 +189,9 @@ class ProfileList:
return deleted return deleted
def get_all_profiles(self):
return self.profiles
def get_profile_and_childs(self, profile_name): def get_profile_and_childs(self, profile_name):
found = {} found = {}
for prof in self.profiles: for prof in self.profiles:

View file

@ -508,9 +508,12 @@ class TestGet_profile_and_childs(AATest):
self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo//xy', '/bin/foo//xy', self.dummy_profile) self.pl.add_profile('/etc/apparmor.d/bin.foo', 'foo//xy', '/bin/foo//xy', self.dummy_profile)
expected = ['foo', 'foo//bar', 'foo//xy'] expected = ['foo', 'foo//bar', 'foo//xy']
self.assertEqual(list(self.pl.get_profile_and_childs('foo')), expected) self.assertEqual(list(self.pl.get_profile_and_childs('foo')), expected)
# while on it, also test get_all_profiles()
all_profiles = ['bafoo', 'foo', 'foobar', 'foo//bar', 'foo//xy']
self.assertEqual(list(self.pl.get_all_profiles()), all_profiles)
setup_aa(apparmor.aa) setup_aa(apparmor.aa)
setup_all_loops(__name__) setup_all_loops(__name__)