ipsec: add missing ipv6 ah code & ipv6 tests
[vpp.git] / test / test_ipsec_tun_if_esp.py
1 import unittest
2 import socket
3 from scapy.layers.ipsec import ESP
4 from framework import VppTestRunner
5 from template_ipsec import TemplateIpsec, IpsecTun4Tests, 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         p = self.ipv4_params
21         tun_if = VppIpsecTunInterface(self, self.pg0, p.vpp_tun_spi,
22                                       p.scapy_tun_spi, p.crypt_algo_vpp_id,
23                                       p.crypt_key, p.crypt_key,
24                                       p.auth_algo_vpp_id, p.auth_key,
25                                       p.auth_key)
26         tun_if.add_vpp_config()
27         tun_if.admin_up()
28         tun_if.config_ip4()
29         src4 = socket.inet_pton(socket.AF_INET, p.remote_tun_if_host)
30         self.vapi.ip_add_del_route(src4, 32, tun_if.remote_ip4n)
31
32     def tearDown(self):
33         if not self.vpp_dead:
34             self.vapi.cli("show hardware")
35         super(TemplateIpsecTunIfEsp, self).tearDown()
36
37
38 class TestIpsecTunIfEsp1(TemplateIpsecTunIfEsp, IpsecTun4Tests):
39     """ Ipsec ESP - TUN tests """
40     pass
41
42
43 class TestIpsecTunIfEsp2(TemplateIpsecTunIfEsp, IpsecTcpTests):
44     """ Ipsec ESP - TCP tests """
45     pass
46
47
48 if __name__ == '__main__':
49     unittest.main(testRunner=VppTestRunner)