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 |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 5 | from template_ipsec import TemplateIpsec, IpsecTun4Tests, IpsecTcpTests |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 6 | from vpp_ipsec_tun_interface import VppIpsecTunInterface |
Neale Ranns | 311124e | 2019-01-24 04:52:25 -0800 | [diff] [blame] | 7 | from vpp_ip_route import VppIpRoute, VppRoutePath |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 8 | |
| 9 | |
| 10 | class TemplateIpsecTunIfEsp(TemplateIpsec): |
| 11 | """ IPsec tunnel interface tests """ |
| 12 | |
| 13 | encryption_type = ESP |
| 14 | |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 15 | def setUp(self): |
Neale Ranns | 8e4a89b | 2019-01-23 08:16:17 -0800 | [diff] [blame] | 16 | super(TemplateIpsecTunIfEsp, self).setUp() |
| 17 | |
| 18 | self.tun_if = self.pg0 |
| 19 | |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 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() |
Neale Ranns | 311124e | 2019-01-24 04:52:25 -0800 | [diff] [blame] | 29 | |
| 30 | VppIpRoute(self, p.remote_tun_if_host, 32, |
| 31 | [VppRoutePath(tun_if.remote_ip4, |
| 32 | 0xffffffff)]).add_vpp_config() |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 33 | |
| 34 | def tearDown(self): |
| 35 | if not self.vpp_dead: |
| 36 | self.vapi.cli("show hardware") |
| 37 | super(TemplateIpsecTunIfEsp, self).tearDown() |
| 38 | |
| 39 | |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 40 | class TestIpsecTunIfEsp1(TemplateIpsecTunIfEsp, IpsecTun4Tests): |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 41 | """ Ipsec ESP - TUN tests """ |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 42 | tun4_encrypt_node_name = "esp4-encrypt" |
| 43 | tun4_decrypt_node_name = "esp4-decrypt" |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 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) |