[apparmor] [patch 3/2] update test-aa.py to match parse_profile_start() and get_profile_flags() changes
Christian Boltz
apparmor at cboltz.de
Wed Mar 4 22:37:54 UTC 2015
Hallo,
the 1/2 patch slightly changed the behaviour of parse_profile_start()
and get_profile_flags() - they raise AppArmorBug instead of
AppArmorException when specifying a line that is not the start of a
profile and therefore doesn't match RE_PROFILE_START_2.
This patch updates test-aa.py to expect the correct exceptions, and
adds another test with quoted profile name to ensure that stripping the
quotes works as expected.
[ update-test-aa-for-parse_profile_start.diff ]
--- utils/test/test-aa.py 2015-03-02 20:37:31.573856341 +0100
+++ utils/test/test-aa.py 2015-03-03 23:02:49.987054727 +0100
@@ -16,7 +16,7 @@ import tempfile
from common_test import write_file
from apparmor.aa import check_for_apparmor, get_profile_flags, is_skippable_file, parse_profile_start
-from apparmor.common import AppArmorException
+from apparmor.common import AppArmorException, AppArmorBug
class AaTestWithTempdir(unittest.TestCase):
def setUp(self):
@@ -91,10 +91,10 @@ class AaTest_get_profile_flags(AaTestWit
self._test_get_flags('/foo flags=(complain, audit)', 'complain, audit')
def test_get_flags_invalid_01(self):
- with self.assertRaises(AppArmorException):
+ with self.assertRaises(AppArmorBug):
self._test_get_flags('/foo ()', None)
def test_get_flags_invalid_02(self):
- with self.assertRaises(AppArmorException):
+ with self.assertRaises(AppArmorBug):
self._test_get_flags('/foo flags=()', None)
def test_get_flags_invalid_03(self):
with self.assertRaises(AppArmorException):
@@ -177,13 +177,18 @@ class AaTest_parse_profile_start(unittes
expected = ('/foo', 'bar', None, False, False, True)
self.assertEqual(result, expected)
+ def test_parse_profile_start_06(self):
+ result = self._parse('profile "/foo" (complain) {', None, None)
+ expected = ('/foo', '/foo', 'complain', False, False, False)
+ self.assertEqual(result, expected)
+
def test_parse_profile_start_invalid_01(self):
with self.assertRaises(AppArmorException):
self._parse('/foo {', '/bar', '/bar') # child profile without profile keyword
def test_parse_profile_start_invalid_02(self):
- with self.assertRaises(AttributeError): # XXX does this need error handling in parse_profile_start?
+ with self.assertRaises(AppArmorBug):
self._parse('xy', '/bar', '/bar') # not a profile start
Regards,
Christian Boltz
--
Das 42te Gebot des Usernetzes besagt: "Du sollst nicht süchtig siggen
eines Süchtigen Signatur. Auf das du selber nicht siggsüchtig werdest."
Wahrscheinlich wird das jetzt wieder gesiggt. [WoKo in dag°]
More information about the AppArmor
mailing list