aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_acl_plugin.py
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2018-03-23 10:38:46 +0100
committerOle Trøan <otroan@employees.org>2018-03-23 11:06:02 +0000
commitde3682f510dd02055e124a2d7be831d203a7f402 (patch)
tree3f191c49827e3f7779f46f32c70bf2f2c81ee6b8 /test/test_acl_plugin.py
parent0e89dfc9167257b4e357222ea8fd176408577203 (diff)
acl-plugin: make test: add a test which deletes an interface with applied ACL
There was no test coverage for a scenario of an interface having an ACL and that interface being deleted. Add a basic sanity test which applies an ACL to an interface and then deletes that interface. Change-Id: Ib6462e02cf69f1173125ac2481c608f68eb389ac Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'test/test_acl_plugin.py')
-rw-r--r--test/test_acl_plugin.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/test_acl_plugin.py b/test/test_acl_plugin.py
index 5fcf09c5ee7..376c4d81b87 100644
--- a/test/test_acl_plugin.py
+++ b/test/test_acl_plugin.py
@@ -13,6 +13,8 @@ from scapy.layers.inet6 import IPv6ExtHdrFragment
from framework import VppTestCase, VppTestRunner
from util import Host, ppp
+from vpp_lo_interface import VppLoInterface
+
class TestACLplugin(VppTestCase):
""" ACL plugin Test Case """
@@ -247,6 +249,17 @@ class TestACLplugin(VppTestCase):
acls=[reply.acl_index])
return
+ def apply_rules_to(self, rules, tag='', sw_if_index=0xFFFFFFFF):
+ reply = self.vapi.acl_add_replace(acl_index=4294967295, r=rules,
+ tag=tag)
+ self.logger.info("Dumped ACL: " + str(
+ self.vapi.acl_dump(reply.acl_index)))
+ # Apply a ACL on the interface as inbound
+ self.vapi.acl_interface_set_acl_list(sw_if_index=sw_if_index,
+ n_input=1,
+ acls=[reply.acl_index])
+ return
+
def etype_whitelist(self, whitelist, n_input):
# Apply whitelists on all the interfaces
for i in self.pg_interfaces:
@@ -1393,5 +1406,31 @@ class TestACLplugin(VppTestCase):
self.logger.info("ACLP_TEST_FINISH_0305")
+ def test_0315_del_intf(self):
+ """ apply an acl and delete the interface
+ """
+ self.logger.info("ACLP_TEST_START_0315")
+
+ # Add an ACL
+ rules = []
+ rules.append(self.create_rule(self.IPV4, self.DENY, self.PORTS_RANGE_2,
+ self.proto[self.IP][self.TCP]))
+ rules.append(self.create_rule(self.IPV4, self.PERMIT, self.PORTS_RANGE,
+ self.proto[self.IP][self.TCP]))
+ # deny ip any any in the end
+ rules.append(self.create_rule(self.IPV4, self.DENY, self.PORTS_ALL, 0))
+
+ # create an interface
+ intf = []
+ intf.append(VppLoInterface(self, 0))
+
+ # Apply rules
+ self.apply_rules_to(rules, "permit ipv4 tcp", intf[0].sw_if_index)
+
+ # Remove the interface
+ intf[0].remove_vpp_config()
+
+ self.logger.info("ACLP_TEST_FINISH_0315")
+
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)