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