mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-29 05:17:59 +00:00
test-mount: test invalid fstype via tests array
... instead of duplicating the logic
This commit is contained in:
parent
a606397417
commit
237b17329f
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# Copyright (C) 2024 Canonical, Ltd.
|
# Copyright (C) 2024 Canonical, Ltd.
|
||||||
|
# Copyright (C) 2025 Christian Boltz <apparmor@cboltz.de>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of version 2 of the GNU General Public
|
# modify it under the terms of version 2 of the GNU General Public
|
||||||
@ -123,6 +124,8 @@ class MountTestParseInvalid(AATest):
|
|||||||
('mount options=(),', AppArmorException),
|
('mount options=(),', AppArmorException),
|
||||||
('mount option=(invalid),', AppArmorException),
|
('mount option=(invalid),', AppArmorException),
|
||||||
('mount option=(ext3ext4),', AppArmorException),
|
('mount option=(ext3ext4),', AppArmorException),
|
||||||
|
('mount fstype=({unclosed_regex),', AppArmorException), # invalid AARE
|
||||||
|
('mount fstype=({closed}twice}),', AppArmorException), # invalid AARE
|
||||||
)
|
)
|
||||||
|
|
||||||
def _run_test(self, rawrule, expected):
|
def _run_test(self, rawrule, expected):
|
||||||
@ -144,16 +147,6 @@ class MountTestParseInvalid(AATest):
|
|||||||
with self.assertRaises(AppArmorBug):
|
with self.assertRaises(AppArmorBug):
|
||||||
MountRule('mount', ('ext3', 'ext4'), MountRule.ALL, MountRule.ALL, MountRule.ALL) # fstype[0] should be '=' or 'in'
|
MountRule('mount', ('ext3', 'ext4'), MountRule.ALL, MountRule.ALL, MountRule.ALL) # fstype[0] should be '=' or 'in'
|
||||||
|
|
||||||
def test_diff_invalid_fstype_aare(self):
|
|
||||||
tests = [
|
|
||||||
'mount fstype=({unclosed_regex),',
|
|
||||||
'mount fstype=({closed}twice}),',
|
|
||||||
]
|
|
||||||
|
|
||||||
for t in tests:
|
|
||||||
with self.assertRaises(AppArmorException):
|
|
||||||
MountRule.create_instance(t)
|
|
||||||
|
|
||||||
def test_diff_invalid_fstype_aare_2(self):
|
def test_diff_invalid_fstype_aare_2(self):
|
||||||
fslists = [
|
fslists = [
|
||||||
['invalid_{_regex'],
|
['invalid_{_regex'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user