blob: 561f1099715e7025cbc445246efb89efeb6e8a27 [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
7
8
9class TemplateIpsecTunIfEsp(TemplateIpsec):
10 """ IPsec tunnel interface tests """
11
12 encryption_type = ESP
13
Klement Sekera31da2e32018-06-24 22:49:55 +020014 def setUp(self):
Neale Ranns8e4a89b2019-01-23 08:16:17 -080015 super(TemplateIpsecTunIfEsp, self).setUp()
16
17 self.tun_if = self.pg0
18
Klement Sekera611864f2018-09-26 11:19:00 +020019 p = self.ipv4_params
20 tun_if = VppIpsecTunInterface(self, self.pg0, p.vpp_tun_spi,
21 p.scapy_tun_spi, p.crypt_algo_vpp_id,
22 p.crypt_key, p.crypt_key,
23 p.auth_algo_vpp_id, p.auth_key,
24 p.auth_key)
25 tun_if.add_vpp_config()
26 tun_if.admin_up()
27 tun_if.config_ip4()
28 src4 = socket.inet_pton(socket.AF_INET, p.remote_tun_if_host)
29 self.vapi.ip_add_del_route(src4, 32, tun_if.remote_ip4n)
Klement Sekera31da2e32018-06-24 22:49:55 +020030
31 def tearDown(self):
32 if not self.vpp_dead:
33 self.vapi.cli("show hardware")
34 super(TemplateIpsecTunIfEsp, self).tearDown()
35
36
Klement Sekera611864f2018-09-26 11:19:00 +020037class TestIpsecTunIfEsp1(TemplateIpsecTunIfEsp, IpsecTun4Tests):
Klement Sekera31da2e32018-06-24 22:49:55 +020038 """ Ipsec ESP - TUN tests """
Klement Sekerab4d30532018-11-08 13:00:02 +010039 tun4_encrypt_node_name = "esp4-encrypt"
40 tun4_decrypt_node_name = "esp4-decrypt"
Klement Sekera31da2e32018-06-24 22:49:55 +020041
42
43class TestIpsecTunIfEsp2(TemplateIpsecTunIfEsp, IpsecTcpTests):
44 """ Ipsec ESP - TCP tests """
45 pass
46
47
48if __name__ == '__main__':
49 unittest.main(testRunner=VppTestRunner)