Commit 3a510652 authored by Steve Beattie's avatar Steve Beattie

utils tests: restructure signal parse tests

Convert the signal parse tests to use common AAParseTest super class in
Signed-off-by: Steve Beattie's avatarSteve Beattie <>
Acked-by: Christian Boltz's avatarChristian Boltz <>
parent b05cc0f3
......@@ -11,52 +11,28 @@
import apparmor.aa as aa
import unittest
class AAParseSignalTest(unittest.TestCase):
def _test_parse_signal_rule(self, rule):
signal = aa.parse_signal_rule(rule)
self.assertEqual(rule, signal.serialize(),
'signal object returned "%s", expected "%s"' % (signal.serialize(), rule))
def test_parse_plain_signal_rule(self):
def test_parse_receive_signal_rule(self):
self._test_parse_signal_rule('signal (receive),')
def test_parse_send_signal_rule(self):
self._test_parse_signal_rule('signal (send),')
def test_parse_send_receive_signal_rule(self):
self._test_parse_signal_rule('signal (send receive),')
def test_parse_r_signal_rule(self):
self._test_parse_signal_rule('signal r,')
def test_parse_w_signal_rule(self):
self._test_parse_signal_rule('signal w,')
def test_parse_rw_signal_rule(self):
self._test_parse_signal_rule('signal rw,')
def test_parse_set_1_signal_rule(self):
self._test_parse_signal_rule('signal send set=("hup"),')
def test_parse_set_2_signal_rule(self):
self._test_parse_signal_rule('signal (receive) set=kill,')
def test_parse_set_3_signal_rule(self):
self._test_parse_signal_rule('signal w set=(quit int),')
def test_parse_peer_1_signal_rule(self):
self._test_parse_signal_rule('signal receive peer=foo,')
def test_parse_peer_2_signal_rule(self):
self._test_parse_signal_rule('signal (send receive) peer=/usr/bin/bar,')
def test_parse_peer_3_signal_rule(self):
self._test_parse_signal_rule('signal wr set=(pipe, usr1) peer=/sbin/baz,')
from common_test import AAParseTest, setup_regex_tests
class AAParseSignalTest(AAParseTest):
def setUp(self):
self.parse_function = aa.parse_signal_rule
tests = [
('signal,', 'signal base keyword rule'),
('signal (receive),', 'signal receive rule'),
('signal (send),', 'signal send rule'),
('signal (send receive),', 'signal multiple perms rule'),
('signal r,', 'signal r rule'),
('signal w,', 'signal w rule'),
('signal rw,', 'signal rw rule'),
('signal send set=("hup"),', 'signal set rule 1'),
('signal (receive) set=kill,', 'signal set rule 2'),
('signal w set=(quit int),', 'signal set rule 3'),
('signal receive peer=foo,', 'signal peer rule 1'),
('signal (send receive) peer=/usr/bin/bar,', 'signal peer rule 2'),
('signal wr set=(pipe, usr1) peer=/sbin/baz,', 'signal peer rule 3'),
if __name__ == '__main__':
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment