From 531f47676d2c5341da520f4e7b29efc4adc99f52 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Fri, 1 Nov 2024 20:18:23 +0100 Subject: [PATCH] ProfileList: add get_all_profiles() ... and a test for it --- utils/apparmor/profile_list.py | 3 +++ utils/test/test-profile-list.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/apparmor/profile_list.py b/utils/apparmor/profile_list.py index 167bc72d0..feed5afc9 100644 --- a/utils/apparmor/profile_list.py +++ b/utils/apparmor/profile_list.py @@ -189,6 +189,9 @@ class ProfileList: return deleted + def get_all_profiles(self): + return self.profiles + def get_profile_and_childs(self, profile_name): found = {} for prof in self.profiles: diff --git a/utils/test/test-profile-list.py b/utils/test/test-profile-list.py index 4c9791fb1..0f81763fc 100644 --- a/utils/test/test-profile-list.py +++ b/utils/test/test-profile-list.py @@ -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) expected = ['foo', 'foo//bar', 'foo//xy'] - 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_all_loops(__name__)