def test_empty_ruleset(self): ruleset = SignalRuleset() ruleset_2 = SignalRuleset() self.assertEqual([], ruleset.get_raw(2)) self.assertEqual([], ruleset.get_clean(2)) self.assertEqual([], ruleset_2.get_raw(2)) self.assertEqual([], ruleset_2.get_clean(2))
class SignalGlobTestAATest(AATest): def setUp(self): self.maxDiff = None self.ruleset = SignalRuleset() def test_glob_1(self): self.assertEqual(self.ruleset.get_glob('signal send,'), 'signal,') # not supported or used yet # def test_glob_2(self): # self.assertEqual(self.ruleset.get_glob('signal send raw,'), 'signal send,') def test_glob_ext(self): with self.assertRaises(NotImplementedError): # get_glob_ext is not available for signal rules self.ruleset.get_glob_ext('signal send set=int,')
def test_ruleset_2(self): ruleset = SignalRuleset() rules = [ 'signal send set=int,', 'allow signal send,', 'deny signal set=quit, # example comment', ] expected_raw = [ ' signal send set=int,', ' allow signal send,', ' deny signal set=quit, # example comment', '', ] expected_clean = [ ' deny signal set=quit, # example comment', '', ' allow signal send,', ' signal send set=int,', '', ] for rule in rules: ruleset.add(SignalRule.parse(rule)) self.assertEqual(expected_raw, ruleset.get_raw(1)) self.assertEqual(expected_clean, ruleset.get_clean(1))
def test_ruleset_1(self): ruleset = SignalRuleset() rules = [ 'signal set=int,', 'signal send,', ] expected_raw = [ 'signal set=int,', 'signal send,', '', ] expected_clean = [ 'signal send,', 'signal set=int,', '', ] for rule in rules: ruleset.add(SignalRule.parse(rule)) self.assertEqual(expected_raw, ruleset.get_raw()) self.assertEqual(expected_clean, ruleset.get_clean())
def setUp(self): self.maxDiff = None self.ruleset = SignalRuleset()