[apparmor] [patch 3/2] update test-aa.py to match parse_profile_start() and get_profile_flags() changes

Steve Beattie steve at nxnw.org
Tue Mar 31 10:30:55 UTC 2015


On Wed, Mar 04, 2015 at 11:37:54PM +0100, Christian Boltz wrote:
> 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 ]

Acked-by: Steve Beattie <steve at nxnw.org>. Thanks

> --- 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
>  
>  

-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150331/41bed86a/attachment-0001.pgp>


More information about the AppArmor mailing list