CSIT-9: COP Whitelist/blacklist
[csit.git] / tests / suites / cop / cop_whitelist_blacklist.robot
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Library | resources.libraries.python.topology.Topology
16 | Library | resources.libraries.python.NodePath
17 | Library | resources.libraries.python.Trace
18 | Resource | resources/libraries/robot/default.robot
19 | Resource | resources/libraries/robot/interfaces.robot
20 | Resource | resources/libraries/robot/ipv4.robot
21 | Resource | resources/libraries/robot/traffic.robot
22 | Resource | resources/libraries/robot/cop.robot
23 | Resource | resources/libraries/robot/l2_xconnect.robot
24 | Variables  | resources/libraries/python/IPv4NodeAddress.py | ${nodes}
25 | Force Tags | HW_ENV | VM_ENV | 3_NODE_SINGLE_LINK_TOPO
26 | Suite Setup | Run Keywords | Setup all DUTs before test
27 | ...         | AND          | Setup all TGs before traffic script
28 | ...         | AND          | Update All Interface Data On All Nodes | ${nodes}
29 | Test Setup | Clear interface counters on all vpp nodes in topology | ${nodes}
30 | Test Teardown | Show packet trace on all DUTs | ${nodes}
31 | Documentation | *COP Blacklist and Whitelist Tests*
32 | ...
33 | ... | Test suite uses 3-node topology TG - DUT1 - DUT2 - TG
34 | ... | with one link between nodes where DUT2 has xconnect.
35 | ... | Test packets are sent only in one direction with COP set either as
36 | ... | whitelist or blacklist. Subsequently, packet's IP src/dst and
37 | ... | MAC addresses are checked.
38
39 *** Variables ***
40 | ${tg_node}= | ${nodes['TG']}
41 | ${dut1_node}= | ${nodes['DUT1']}
42 | ${dut2_node}= | ${nodes['DUT2']}
43
44 | ${dut1_if1_ip}= | 192.168.1.1
45 | ${dut1_if2_ip}= | 192.168.2.1
46 | ${dut1_if1_ip_GW}= | 192.168.1.2
47 | ${dut1_if2_ip_GW}= | 192.168.2.2
48
49 | ${test_dst_ip}= | 32.0.0.1
50 | ${test_src_ip}= | 16.0.0.1
51
52 | ${cop_dut_ip}= | 16.0.0.0
53
54 | ${ip_prefix}= | 24
55 | ${nodes_ipv4_addresses}= | ${nodes_ipv4_addr}
56
57 | ${fib_table_number}= | 1
58
59 *** Test Cases ***
60 | VPP permits packets based on IPv4 src addr
61 | | [Documentation] | COP Whitelist test with basic setup.
62 | | Given Setup Nodes And Variables | ${tg_node} | ${dut1_node} | ${dut2_node}
63 | | And L2 setup xconnect on DUT | ${dut2_node} | ${dut2_if1} | ${dut2_if2}
64 | | And Set Interface Address
65 | | ... | ${dut1_node} | ${dut1_if1} | ${dut1_if1_ip} | ${ip_prefix}
66 | | And Set Interface Address
67 | | ... | ${dut1_node} | ${dut1_if2} | ${dut1_if2_ip} | ${ip_prefix}
68 | | And Add Arp On Dut
69 | | ... | ${dut1_node} | ${dut1_if1} | ${dut1_if1_ip_GW} | ${tg_if1_mac}
70 | | And Add Arp On Dut
71 | | ... | ${dut1_node} | ${dut1_if2} | ${dut1_if2_ip_GW} | ${tg_if2_mac}
72 | | And Vpp Route Add | ${dut1_node}
73 | | ... | ${test_dst_ip} | ${ip_prefix} | ${dut1_if2_ip_GW} | ${dut1_if2}
74 | | And Add fib table | ${dut1_node}
75 | | ... | ${cop_dut_ip} | ${ip_prefix} | ${fib_table_number} | local
76 | | When COP Add whitelist Entry
77 | | ... | ${dut1_node} | ${dut1_if1} | ip4 | ${fib_table_number}
78 | | And COP interface enable or disable | ${dut1_node} | ${dut1_if1} | enable
79 | | Then Send Packet And Check Headers | ${tg_node} |
80 | | ... | ${test_src_ip} | ${test_dst_ip} | ${tg_if1} | ${tg_if1_mac} |
81 | | ... | ${dut1_if1_mac} | ${tg_if2} | ${dut1_if2_mac} | ${tg_if2_mac}
82
83
84 | VPP drops packets based on IPv4 src addr
85 | | [Documentation] | COP blacklist test with basic setup.
86 | | Given Setup Nodes And Variables | ${tg_node} | ${dut1_node} | ${dut2_node}
87 | | And L2 setup xconnect on DUT | ${dut2_node} | ${dut2_if1} | ${dut2_if2}
88 | | And Set Interface Address
89 | | ... | ${dut1_node} | ${dut1_if1} | ${dut1_if1_ip} | ${ip_prefix}
90 | | And Set Interface Address
91 | | ... | ${dut1_node} | ${dut1_if2} | ${dut1_if2_ip} | ${ip_prefix}
92 | | And Add Arp On Dut
93 | | ... | ${dut1_node} | ${dut1_if1} | ${dut1_if1_ip_GW} | ${tg_if1_mac}
94 | | And Add Arp On Dut
95 | | ... | ${dut1_node} | ${dut1_if2} | ${dut1_if2_ip_GW} | ${tg_if2_mac}
96 | | And Vpp Route Add | ${dut1_node}
97 | | ... | ${test_dst_ip} | ${ip_prefix} | ${dut1_if2_ip_GW} | ${dut1_if2}
98 | | And Add fib table | ${dut1_node}
99 | | ... | ${cop_dut_ip} | ${ip_prefix} | ${fib_table_number} | drop
100 | | When COP Add whitelist Entry
101 | | ... | ${dut1_node} | ${dut1_if1} | ip4 | ${fib_table_number}
102 | | And COP interface enable or disable | ${dut1_node} | ${dut1_if1} | enable
103 | | Then Send packet from Port to Port should failed | ${tg_node} |
104 | | ... | ${test_src_ip} | ${test_dst_ip} | ${tg_if1} | ${tg_if1_mac} |
105 | | ... | ${dut1_if1_mac} | ${tg_if2} | ${dut1_if2_mac} | ${tg_if2_mac}