2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 01:57:43 +00:00

utils: ProfileStorage - add tests with invalid type

Add tests with invalid type to ensure error handling works as expected.

Merge branch 'cboltz/cboltz-profile-storage-tests'

[Fixed conflict with prior change to utils/test/test-profile-storage.py]
Acked-by: Steve Beattie <steve@nxnw.org>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/735
This commit is contained in:
Steve Beattie 2021-04-11 16:54:43 -07:00
commit 94b7704e56
No known key found for this signature in database
GPG Key ID: 2F099E8D005E81F4

View File

@ -121,6 +121,23 @@ class AaTest_get_header_01(AATest):
result = prof_storage.get_header(depth, name, embedded_hat, write_flags)
self.assertEqual(result, [expected])
class TestSetInvalid(AATest):
tests = [
(('profile_keyword', None), AppArmorBug), # expects bool
(('profile_keyword', 'foo'), AppArmorBug),
(('attachment', False), AppArmorBug), # expects string
(('attachment', None), AppArmorBug),
(('filename', True), AppArmorBug), # expects string or None
(('allow', None), AppArmorBug), # doesn't allow overwriting at all
]
def _run_test(self, params, expected):
self.storage = ProfileStorage('/test/foo', 'hat', 'TEST')
with self.assertRaises(expected):
self.storage[params[0]] = params[1]
class AaTest_add_or_remove_flag(AATest):
tests = [
# existing flag(s) flag to change add or remove? expected flags