blob: 2734908e7a16f427dc5d28c01f98c2ae150de7ca [file] [log] [blame]
Klement Sekera31da2e32018-06-24 22:49:55 +02001import unittest
2import socket
3from scapy.layers.ipsec import ESP
4from framework import VppTestRunner
Klement Sekera611864f2018-09-26 11:19:00 +02005from template_ipsec import TemplateIpsec, IpsecTun4Tests, IpsecTcpTests
Klement Sekera31da2e32018-06-24 22:49:55 +02006from vpp_ipsec_tun_interface import VppIpsecTunInterface
Neale Ranns311124e2019-01-24 04:52:25 -08007from vpp_ip_route import VppIpRoute, VppRoutePath
Klement Sekera31da2e32018-06-24 22:49:55 +02008
9
10class TemplateIpsecTunIfEsp(TemplateIpsec):
11 """ IPsec tunnel interface tests """
12
13 encryption_type = ESP
14
Klement Sekera31da2e32018-06-24 22:49:55 +020015 def setUp(self):
Neale Ranns8e4a89b2019-01-23 08:16:17 -080016 super(TemplateIpsecTunIfEsp, self).setUp()
17
18 self.tun_if = self.pg0
19
Klement Sekera611864f2018-09-26 11:19:00 +020020 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()
Neale Ranns311124e2019-01-24 04:52:25 -080029
30 VppIpRoute(self, p.remote_tun_if_host, 32,
31 [VppRoutePath(tun_if.remote_ip4,
32 0xffffffff)]).add_vpp_config()
Klement Sekera31da2e32018-06-24 22:49:55 +020033
34 def tearDown(self):
35 if not self.vpp_dead:
36 self.vapi.cli("show hardware")
37 super(TemplateIpsecTunIfEsp, self).tearDown()
38
39
Klement Sekera611864f2018-09-26 11:19:00 +020040class TestIpsecTunIfEsp1(TemplateIpsecTunIfEsp, IpsecTun4Tests):
Klement Sekera31da2e32018-06-24 22:49:55 +020041 """ Ipsec ESP - TUN tests """
Klement Sekerab4d30532018-11-08 13:00:02 +010042 tun4_encrypt_node_name = "esp4-encrypt"
43 tun4_decrypt_node_name = "esp4-decrypt"
Klement Sekera31da2e32018-06-24 22:49:55 +020044
45
46class TestIpsecTunIfEsp2(TemplateIpsecTunIfEsp, IpsecTcpTests):
47 """ Ipsec ESP - TCP tests """
48 pass
49
50
51if __name__ == '__main__':
52 unittest.main(testRunner=VppTestRunner)