blob: c260f03b63da71bdd9cb3d0ab736068a752686c7 [file] [log] [blame]
Klement Sekera31da2e32018-06-24 22:49:55 +02001import unittest
2import socket
3from scapy.layers.ipsec import ESP
4from framework import VppTestRunner
5from template_ipsec import TemplateIpsec, IpsecTunTests, IpsecTcpTests
6from vpp_ipsec_tun_interface import VppIpsecTunInterface
7
8
9class 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
41class TestIpsecTunIfEsp1(TemplateIpsecTunIfEsp, IpsecTunTests):
42 """ Ipsec ESP - TUN tests """
43 pass
44
45
46class TestIpsecTunIfEsp2(TemplateIpsecTunIfEsp, IpsecTcpTests):
47 """ Ipsec ESP - TCP tests """
48 pass
49
50
51if __name__ == '__main__':
52 unittest.main(testRunner=VppTestRunner)