Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 1 | import unittest |
| 2 | import socket |
| 3 | from scapy.layers.ipsec import ESP |
| 4 | from framework import VppTestRunner |
| 5 | from template_ipsec import TemplateIpsec, IpsecTunTests, IpsecTcpTests |
| 6 | from vpp_ipsec_tun_interface import VppIpsecTunInterface |
| 7 | |
| 8 | |
| 9 | class TemplateIpsecTunIfEsp(TemplateIpsec): |
| 10 | """ IPsec tunnel interface tests """ |
| 11 | |
| 12 | encryption_type = ESP |
| 13 | |
| 14 | @classmethod |
| 15 | def setUpClass(cls): |
| 16 | super(TemplateIpsecTunIfEsp, cls).setUpClass() |
| 17 | cls.tun_if = cls.pg0 |
| 18 | |
| 19 | def setUp(self): |
| 20 | self.ipsec_tun_if = VppIpsecTunInterface(self, self.pg0, |
| 21 | self.vpp_tun_spi, |
| 22 | self.scapy_tun_spi, |
| 23 | self.crypt_algo_vpp_id, |
| 24 | self.crypt_key, |
| 25 | self.crypt_key, |
| 26 | self.auth_algo_vpp_id, |
| 27 | self.auth_key, |
| 28 | self.auth_key) |
| 29 | self.ipsec_tun_if.add_vpp_config() |
| 30 | self.ipsec_tun_if.admin_up() |
| 31 | self.ipsec_tun_if.config_ip4() |
| 32 | src4 = socket.inet_pton(socket.AF_INET, self.remote_tun_if_host) |
| 33 | self.vapi.ip_add_del_route(src4, 32, self.ipsec_tun_if.remote_ip4n) |
| 34 | |
| 35 | def tearDown(self): |
| 36 | if not self.vpp_dead: |
| 37 | self.vapi.cli("show hardware") |
| 38 | super(TemplateIpsecTunIfEsp, self).tearDown() |
| 39 | |
| 40 | |
| 41 | class TestIpsecTunIfEsp1(TemplateIpsecTunIfEsp, IpsecTunTests): |
| 42 | """ Ipsec ESP - TUN tests """ |
| 43 | pass |
| 44 | |
| 45 | |
| 46 | class TestIpsecTunIfEsp2(TemplateIpsecTunIfEsp, IpsecTcpTests): |
| 47 | """ Ipsec ESP - TCP tests """ |
| 48 | pass |
| 49 | |
| 50 | |
| 51 | if __name__ == '__main__': |
| 52 | unittest.main(testRunner=VppTestRunner) |