1 from asfframework import VppTestRunner
2 from framework import VppTestCase
4 from config import config
7 @unittest.skipIf("snort" in config.excluded_plugins, "Exclude snort plugin test")
8 class TestSnort(VppTestCase):
9 """Simple Snort plugin test"""
13 super(TestSnort, cls).setUpClass()
15 cls.create_pg_interfaces(range(2))
16 for i in cls.pg_interfaces:
17 i.config_ip4().resolve_arp()
24 def tearDownClass(cls):
25 for i in cls.pg_interfaces:
28 super(TestSnort, cls).tearDownClass()
30 def test_snort_cli(self):
31 # TODO: add a test with packets
32 # { cli command : part of the expected reply }
34 "snort create-instance name snortTest queue-size 16 on-disconnect drop": "",
35 "snort create-instance name snortTest2 queue-size 16 on-disconnect pass": "",
36 "snort attach instance snortTest interface pg0 output": "",
37 "snort attach instance snortTest2 interface pg1 input": "",
38 "show snort instances": "snortTest",
39 "show snort interfaces": "pg0",
40 "show snort clients": "number of clients",
41 "show snort mode": "input mode: interrupt",
42 "snort mode polling": "",
43 "snort mode interrupt": "",
44 "snort detach interface pg0": "",
45 "snort detach interface pg1": "",
48 for command, reply in commands_replies.items():
49 actual_reply = self.vapi.cli(command)
50 self.assertIn(reply, actual_reply)
53 if __name__ == "__main__":
54 unittest.main(testRunner=VppTestRunner)