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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 """Test variables for ietf-ACL test suite."""
17 def get_variables(test_case, name):
18 """Create and return a dictionary of test variables for the specified
21 :param test_case: Determines which test variables to return.
22 :param name: Name for the classify chain used in test.
26 :return: Dictionary of test variables - settings for Honeycomb's
27 ietf-acl node and packet fields to use in verification.
31 test_case = test_case.lower()
33 # Variables for control packet, should always pass through DUT
36 "dst_net": "16.0.1.0",
39 "src_mac": "01:02:03:04:05:06",
40 "dst_mac": "10:20:30:40:50:60"}
44 # MACs classified directly
45 "classify_src": "12:23:34:45:56:67",
46 "classify_dst": "89:9A:AB:BC:CD:DE",
47 # MACs classified through mask
48 "classify_src2": "01:02:03:04:56:67",
49 "classify_dst2": "89:9A:AB:BC:50:60",
50 "src_mask": "00:00:00:00:FF:FF",
51 "dst_mask": "FF:FF:FF:FF:00:00"
54 # IPs for DUT interface setup
55 "dut_to_tg_if1_ip": "16.0.0.2",
56 "dut_to_tg_if2_ip": "192.168.0.2",
57 "gateway": "192.168.0.1",
59 "classify_src_net": "16.0.2.0",
60 "classify_dst_net": "16.0.3.0",
61 # IPs in classified networks
62 "classify_src": "16.0.2.1",
63 "classify_dst": "16.0.3.1",
67 # Override control packet addresses with IPv6
71 # IPs for DUT interface setup
72 "dut_to_tg_if1_ip": "10::2",
73 "dut_to_tg_if2_ip": "20::2",
76 "classify_src_net": "12::",
77 "classify_dst_net": "13::",
78 # IPs in classified networks
79 "classify_src": "12::1",
80 "classify_dst": "13::1",
85 # ACL configuration for L2 tests
89 "ietf-access-control-list:eth-acl",
91 "access-list-entries": {"ace": [{
95 test_vars["l2"]["classify_src"],
96 "source-mac-address-mask":
97 test_vars["l2"]["src_mask"],
98 "destination-mac-address":
99 test_vars["l2"]["classify_dst"],
100 "destination-mac-address-mask":
101 test_vars["l2"]["dst_mask"]
109 # ACL configuration for L3 IPv4 tests
113 "ietf-access-control-list:ipv4-acl",
115 "access-list-entries": {"ace": [{
116 "rule-name": "rule1",
118 "source-ipv4-network":
120 test_vars["l3_ip4"]["classify_src_net"],
121 test_vars["l3_ip4"]["prefix_length"]),
122 "destination-ipv4-network":
124 test_vars["l3_ip4"]["classify_dst_net"],
125 test_vars["l3_ip4"]["prefix_length"]),
134 # ACL settings for L3 IPv6 tests
138 "ietf-access-control-list:ipv6-acl",
140 "access-list-entries": {"ace": [{
141 "rule-name": "rule1",
143 "source-ipv6-network":
145 test_vars["l3_ip6"]["classify_src_net"],
146 test_vars["l3_ip6"]["prefix_length"]),
147 "destination-ipv6-network":
149 test_vars["l3_ip6"]["classify_dst_net"],
150 test_vars["l3_ip6"]["prefix_length"]),
161 variables.update(test_vars[test_case])
163 {"acl_settings": acl_data[test_case]}
166 raise Exception("Unrecognized test case {0}."
167 " Valid options are: {1}".format(
168 test_case, acl_data.keys()))