HC Test: improve functional suite setup and teardown
[csit.git] / resources / libraries / robot / honeycomb / access_control_lists.robot
1 # Copyright (c) 2017 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 *** Variables ***
14 #TODO: update based on resolution of bug https://jira.fd.io/browse/HONEYCOMB-119
15
16 *** Settings ***
17 | Library | resources.libraries.python.Classify
18 | Library | resources.libraries.python.InterfaceUtil
19 | Library | resources.libraries.python.honeycomb.HcAPIKwACL.ACLKeywords
20 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
21 | Documentation | Keywords used to manage ACLs.
22
23 *** Keywords ***
24 | Honeycomb creates ACL table
25 | | [Documentation] | Uses Honeycomb API to create an ACL table.
26 | | ...
27 | | ... | *Arguments:*
28 | | ... | - node - information about a DUT node. Type: dictionary
29 | | ... | - settings - ACL table settings. Type: dictionary
30 | | ...
31 | | ... | *Example:*
32 | | ...
33 | | ... | \| Honeycomb creates ACL table \| ${nodes['DUT1']} \
34 | | ... | \| ${settings} \|
35 | | [Arguments] | ${node} | ${settings}
36 | | Add classify table | ${node} | ${settings}
37
38 | Honeycomb removes ACL table
39 | | [Documentation] | Uses Honeycomb API to remove and existing ACL table.
40 | | ...
41 | | ... | *Arguments:*
42 | | ... | - node - information about a DUT node. Type: dictionary
43 | | ... | - table_name - name of an ACL table. Type: string
44 | | ...
45 | | ... | *Example:*
46 | | ...
47 | | ... | \| Honeycomb removes ACL table \| ${nodes['DUT1']} \| table0 \|
48 | | [Arguments] | ${node} | ${table_name}
49 | | Remove classify table | ${node} | ${table_name}
50
51 | Honeycomb adds ACL session
52 | | [Documentation] | Uses Honeycomb API to create an ACL session.
53 | | ...
54 | | ... | *Arguments:*
55 | | ... | - node - information about a DUT node. Type: dictionary
56 | | ... | - table_name - name of an ACL table. Type: string
57 | | ... | - settings - ACL session settings. Type: dictionary
58 | | ...
59 | | ... | *Example:*
60 | | ...
61 | | ... | \| Honeycomb adds ACL session \| ${nodes['DUT1']} \
62 | | ... | \| table0 \| ${settings} \|
63 | | [Arguments] | ${node} | ${table_name} | ${settings}
64 | | Add classify session | ${node} | ${table_name} | ${settings}
65
66 | Honeycomb removes ACL session
67 | | [Documentation] | Uses Honeycomb API to remove an ACL session.
68 | | ...
69 | | ... | *Arguments:*
70 | | ... | - node - information about a DUT node. Type: dictionary
71 | | ... | - table_name - name of an ACL table. Type: string
72 | | ... | - match - ACL session match setting. Type: string
73 | | ...
74 | | ... | *Example:*
75 | | ...
76 | | ... | \| Honeycomb removes ACL session \| ${nodes['DUT1']} \
77 | | ... | \| table0 \| 00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00 \|
78 | | [Arguments] | ${node} | ${table_name} | ${match}
79 | | Remove classify session | ${node} | ${table_name} | ${match}
80
81 | Honeycomb enables ACL on interface
82 | | [Documentation] | Uses Honeycomb API to enable ACL on an interface.
83 | | ...
84 | | ... | *Arguments:*
85 | | ... | - node - information about a DUT node. Type: dictionary
86 | | ... | - interface - name of an interface on the specified node. Type: string
87 | | ... | - table_name - name of an ACL table. Type: string
88 | | ...
89 | | ... | *Example:*
90 | | ...
91 | | ... | \| Honeycomb enables ACL on interface \| ${nodes['DUT1']} \
92 | | ... | \| GigabithEthernet0/8/0 \| table0 \|
93 | | [Arguments] | ${node} | ${interface} | ${table_name}
94 | | Enable ACL on interface
95 | | ... | ${node} | ${interface} | ${table_name}
96
97 | Honeycomb disables ACL on interface
98 | | [Documentation] | Uses Honeycomb API to disable ACL on an interface.
99 | | ...
100 | | ... | *Arguments:*
101 | | ... | - node - information about a DUT node. Type: dictionary
102 | | ... | - interface - name of an interface on the specified node. Type: string
103 | | ...
104 | | ... | *Example:*
105 | | ...
106 | | ... | \| Honeycomb disables ACL on interface \| ${nodes['DUT1']} \
107 | | ... | \| GigabithEthernet0/8/0 \|
108 | | [Arguments] | ${node} | ${interface}
109 | | Disable ACL on interface | ${node} | ${interface}
110
111 | ACL table from Honeycomb should be
112 | | [Documentation] | Retrieves ACL table information from Honeycomb\
113 | | ... | and compares with expected settings.
114 | | ...
115 | | ... | *Arguments:*
116 | | ... | - node - information about a DUT node. Type: dictionary
117 | | ... | - settings - expected ACL table settings. Type: dictionary
118 | | ...
119 | | ... | *Example:*
120 | | ...
121 | | ... | \| ACL table from Honeycomb should be \| ${nodes['DUT1']} \
122 | | ... | \| ${settings} \|
123 | | [Arguments] | ${node} | ${settings}
124 | | ${data}= | Get classify table oper data | ${node} | ${settings['name']}
125 | | Compare data structures | ${data} | ${settings}
126
127 | ACL table from VAT should be
128 | | [Documentation] | Retrieves ACL table information from VAT\
129 | | ... | and compares with expected settings.
130 | | ...
131 | | ... | *Arguments:*
132 | | ... | - node - information about a DUT node. Type: dictionary
133 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
134 | | ... | - settings - expected ACL table settings. Type: dictionary
135 | | ...
136 | | ... | *Example:*
137 | | ...
138 | | ... | \| ACL session from VAT should be \| ${nodes['DUT1']} \
139 | | ... | \| ${0} \| ${settings} \|
140 | | [Arguments] | ${node} | ${table_index} | ${settings}
141 | | ${data}= | Get classify table data | ${node} | ${table_index}
142 | | Compare data structures | ${data} | ${settings}
143
144 | ACL table from Honeycomb should not exist
145 | | [Documentation] | Retrieves ACL table information from Honeycomb\
146 | | ... | and expects to fail.
147 | | ...
148 | | ... | *Arguments:*
149 | | ... | - node - information about a DUT node. Type: dictionary
150 | | ... | - table_name - name of an ACL table. Type: string
151 | | ...
152 | | ... | *Example:*
153 | | ...
154 | | ... | \| ACL table from Honeycomb should not exist \| ${nodes['DUT1']} \
155 | | ... | \| table0 \|
156 | | [Arguments] | ${node} | ${table_name}
157 | | Run keyword and expect error | *
158 | | ... | Get classify table oper data | ${node} | ${table_name}
159
160 | ACL table from VAT should not exist
161 | | [Documentation] | Retrieves ACL table information from VAT\
162 | | ... | and expects to fail.
163 | | ...
164 | | ... | *Arguments:*
165 | | ... | - node - information about a DUT node. Type: dictionary
166 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
167 | | ...
168 | | ... | *Example:*
169 | | ...
170 | | ... | \| ACL table from VAT should not exist \| ${nodes['DUT1']} \
171 | | ... | \| ${0} \|
172 | | [Arguments] | ${node} | ${table_index}
173 | | Run keyword and expect error | VAT: no JSON data.
174 | | ... | Get classify table data | ${node} | ${table_index}
175
176 | ACL session from Honeycomb should be
177 | | [Documentation] | Retrieves ACL session information from Honeycomb\
178 | | ... | and compares with expected settings.
179 | | ...
180 | | ... | *Arguments:*
181 | | ... | - node - information about a DUT node. Type: dictionary
182 | | ... | - table_name - name of an ACL table. Type: string
183 | | ... | - settings - expected ACL session settings. Type: dictionary
184 | | ...
185 | | ... | *Example:*
186 | | ...
187 | | ... | \| ACL session from Honeycomb should be \| ${nodes['DUT1']} \
188 | | ... | \| table0 \| ${settings} \|
189 | | [Arguments] | ${node} | ${table_name} | ${settings}
190 | | ${data}= | Get classify session oper data
191 | | ... | ${node} | ${table_name} | ${settings['match']}
192 | | Compare data structures | ${data} | ${settings}
193
194 | ACL session from VAT should be
195 | | [Documentation] | Retrieves ACL session information from VAT\
196 | | ... | and compares with expected settings.
197 | | ...
198 | | ... | *Arguments:*
199 | | ... | - node - information about a DUT node. Type: dictionary
200 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
201 | | ... | - session_index - VPP internal index of an ACL session. Type: integer
202 | | ... | - settings - expected ACL session settings. Type: dictionary
203 | | ...
204 | | ... | *Example:*
205 | | ...
206 | | ... | \| ACL session from VAT should be \| ${nodes['DUT1']} \
207 | | ... | \| ${0} \| ${0} \| ${settings} \|
208 | | [Arguments] | ${node} | ${table_index} | ${session_index} | ${settings}
209 | | ${data}= | Get classify session data
210 | | ... | ${node} | ${table_index} | ${session_index}
211 | | Compare data structures | ${data} | ${settings}
212
213 | ACL session from Honeycomb should not exist
214 | | [Documentation] | Retrieves ACL session information from Honeycomb\
215 | | ... | and expects to fail.
216 | | ...
217 | | ... | *Arguments:*
218 | | ... | - node - information about a DUT node. Type: dictionary
219 | | ... | - table_name - name of an ACL table. Type: string
220 | | ... | - session_match - ACL session match setting. Type: string
221 | | ...
222 | | ... | *Example:*
223 | | ...
224 | | ... | \| ACL session from Honeycomb should not exist \| ${nodes['DUT1']} \
225 | | ... | \| table0 \| 00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00 \|
226 | | [Arguments] | ${node} | ${table_name} | ${session_match}
227 | | Run keyword and expect error | *KeyError:*
228 | | ... | Get classify session oper data
229 | | ... | ${node} | ${table_name} | ${session_match}
230
231 | ACL session from VAT should not exist
232 | | [Documentation] | Retrieves ACL session information from VAT\
233 | | ... | and compares with expected settings.
234 | | ...
235 | | ... | *Arguments:*
236 | | ... | - node - information about a DUT node. Type: dictionary
237 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
238 | | ... | - session_index - VPP internal index of an ACL session. Type: integer
239 | | ...
240 | | ... | *Example:*
241 | | ...
242 | | ... | \| ACL session from VAT should not exist \| ${nodes['DUT1']} \
243 | | ... | \| ${0} \| ${0} \|
244 | | [Arguments] | ${node} | ${table_index} | ${session_index}
245 | | Run keyword if | ${session_index} == 0
246 | | ... | Run keyword and expect error
247 | | ... | ValueError: No JSON object could be decoded
248 | | ... | Get classify session data
249 | | ... | ${node} | ${table_index} | ${session_index}
250 | | Run keyword if | ${session_index} > 0
251 | | ... | Run keyword and expect error
252 | | ... | IndexError: list index out of range
253 | | ... | Get classify session data
254 | | ... | ${node} | ${table_index} | ${session_index}
255
256 | Interface ACL configuration from Honeycomb should be
257 | | [Documentation] | Retrieves ACL interface settings from Honeycomb\
258 | | ... | and compares with expected settings.
259 | | ...
260 | | ... | *Arguments:*
261 | | ... | - node - information about a DUT node. Type: dictionary
262 | | ... | - interface - name of an interface on the specified node. Type: string
263 | | ... | - table_name - expected ACL table name. Type: string
264 | | ...
265 | | ... | *Example:*
266 | | ...
267 | | ... | \| Interface ACL configuration from Honeycomb should be \
268 | | ... | \| ${nodes['DUT1']} \| GigabithEthernet0/8/0 \| table0 \|
269 | | [Arguments] | ${node} | ${interface} | ${table_name}
270 | | ${data}= | Get interface oper data | ${node} | ${interface}
271 | | Should be equal
272 | | ... | ${table_name}
273 | | ... | ${data['vpp-interface-acl:acl']['ingress']['l2-acl']['classify-table']}
274 | | ... | ${data['vpp-interface-acl:acl']['ingress']['ip4-acl']['classify-table']}
275
276 | Interface ACL configuration from VAT should be
277 | | [Documentation] | Retrieves ACL interface settings from VAT\
278 | | ... | and compares with expected settings.
279 | | ...
280 | | ... | *Arguments:*
281 | | ... | - node - information about a DUT node. Type: dictionary
282 | | ... | - interface - name of an interface on the specified node. Type: string
283 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
284 | | ...
285 | | ... | *Example:*
286 | | ...
287 | | ... | \| Interface ACL configuration from VAT should be \
288 | | ... | \| ${nodes['DUT1']} \| GigabithEthernet0/8/0 \| ${0} \|
289 | | ...
290 | | [Arguments] | ${node} | ${interface} | ${table_index}
291 | | ${data}= | Get interface classify table | ${node} | ${interface}
292 | | Should be equal | ${table_index} | ${data['l2_table_id']}
293 | | Should be equal | ${table_index} | ${data['ip4_table_id']}
294
295 | Interface ACL configuration from Honeycomb should be empty
296 | | [Documentation] | Retrieves ACL interface settings from Honeycomb\
297 | | ... | and expects to fail.
298 | | ...
299 | | ... | *Arguments:*
300 | | ... | - node - information about a DUT node. Type: dictionary
301 | | ... | - interface - name of an interface on the specified node. Type: string
302 | | ...
303 | | ... | *Example:*
304 | | ...
305 | | ... | \| Interface ACL configuration from Honeycomb should be empty \
306 | | ... | \| ${nodes['DUT1']} \| GigabithEthernet0/8/0 \|
307 | | [Arguments] | ${node} | ${interface}
308 | | ${data}= | Get interface oper data | ${node} | ${interface}
309 | | Run keyword and expect error | *KeyError: 'vpp-interface-acl:acl'
310 | | ... | Set Variable
311 | | ... | ${data['vpp-interface-acl:acl']['l2-acl']['classify-table']}
312
313 | Interface ACL configuration from VAT should be empty
314 | | [Documentation] | Retrieves ACL interface settings from VAT\
315 | | ... | and expects to fail.
316 | | ...
317 | | ... | *Arguments:*
318 | | ... | - node - information about a DUT node. Type: dictionary
319 | | ... | - interface - name of an interface on the specified node. Type: string
320 | | ...
321 | | ... | *Example:*
322 | | ...
323 | | ... | \| Interface ACL configuration from Honeycomb should be empty \
324 | | ... | \| ${nodes['DUT1']} \| GigabithEthernet0/8/0 \|
325 | | [Arguments] | ${node} | ${interface}
326 | | ${data}= | Get interface classify table | ${node} | ${interface}
327 | | Should be equal | ${data['l2_table_id']} | ${-1}
328 | | Should be equal | ${data['ip4_table_id']} | ${-1}
329
330 | Clear all ACL settings
331 | | [Documentation] | Removes all ACL sessions and tables from Honeycomb\
332 | | ... | configuration.
333 | | ...
334 | | ... | *Arguments:*
335 | | ... | - node - information about a DUT node. Type: dictionary
336 | | ...
337 | | ... | *Example:*
338 | | ...
339 | | ... | \| Clear all ACL settings \| ${nodes['DUT1']} \|
340 | | [Arguments] | ${node}
341 | | Remove all classify tables | ${node}
342
343 | Honeycomb creates ACL chain through ACL plugin
344 | | [Documentation] | Creates classify chain using the ACL plugin.
345 | | ...
346 | | ... | *Arguments:*
347 | | ... | - node - Information about a DUT node. Type: dictionary
348 | | ... | - acl_list_name - Name for the classify chain. Type: string
349 | | ... | - acl_list_settings - classify rules. Type: dictionary
350 | | ... | - macip - Use MAC+IP classifier. Optional. Type: boolean
351 | | ...
352 | | ... | *Example:*
353 | | ...
354 | | ... | \| Honeycomb creates ACL chain through ACL plugin \
355 | | ... | \| ${nodes['DUT1']} \| acl_test \| ${settings} \|
356 | | [Arguments] | ${node} | ${acl_list_name} | ${acl_list_settings}
357 | | ... | ${macip}=${False}
358 | | Create ACL plugin classify chain
359 | | ... | ${node} | ${acl_list_name} | ${acl_list_settings} | ${macip}
360
361 | Honeycomb assigns plugin-ACL chain to interface
362 | | [Documentation] | Applies classification through the high-level\
363 | | ... | IETF-ACL node to an interface.
364 | | ...
365 | | ... | *Arguments:*
366 | | ... | - node - Information about a DUT node. Type: dictionary
367 | | ... | - interface - Interface to assign classifier to. Type: string
368 | | ... | - acl_list_name - Name of the clasify chain. Type: string
369 | | ... | - direction - Classifier direction, ingress or egress. Type: string
370 | | ... | - macip - Use MAC+IP classifier. Optional. Type: boolean
371 | | ...
372 | | ... | *Example:*
373 | | ...
374 | | ... | \| Honeycomb assigns plugin-ACL chain to interface \
375 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| acl_test \| ingress \|
376 | | [Arguments]
377 | | ... | ${node} | ${interface} | ${acl_list_name} | ${direction}
378 | | ... | ${macip}=${False}
379 | | Set ACL plugin interface
380 | | ... | ${node} | ${interface} | ${acl_list_name} | ${direction} | ${macip}
381
382 | Clear plugin-ACL configuration
383 | | [Documentation] | Removes ACl assignment from interface, then deletes\
384 | | ... | IETF-ACL chain.
385 | | ...
386 | | ... | *Arguments:*
387 | | ... | - node - Information about a DUT node. Type: dictionary
388 | | ... | - interface - Interface to clean classifiers from. | Type: string
389 | | ...
390 | | ... | *Example:*
391 | | ...
392 | | ... | \| Clear plugin-ACL configuration | ${nodes['DUT1']} \
393 | | ... | \| GigabitEthernet0/8/0 \|
394 | | [Arguments] | ${node} | ${interface}
395 | | Delete interface plugin ACLs | ${node} | ${interface}
396 | | Delete ACL plugin classify chains | ${node}
397
398 | Read plugin-ACL configuration from VAT
399 | | [Documentation] | Obtains ACL-plugin configuration through VAT and logs\
400 | | ... | the reply.
401 | | ...
402 | | ... | *Arguments:*
403 | | ... | - node - Information about a DUT node. Type: dictionary
404 | | ...
405 | | ... | *Example:*
406 | | ...
407 | | ... | \| Read plugin-ACL configuration from VAT \| ${nodes['DUT1']} \|
408 | | [Arguments] | ${node}
409 | | VPP log plugin acl settings | ${node}
410 | | VPP log plugin acl interface assignment | ${node}
411
412 | Send ICMP packet with type and code and verify received packet
413 | | [Documentation] | Sends an ICMP packet with specified code and type.
414 | | ...
415 | | ... | *Arguments:*
416 | | ...
417 | | ... | _NOTE:_ Arguments are based on topology:
418 | | ... | TG(if1)->(if1)DUT(if2)->TG(if2)
419 | | ...
420 | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
421 | | ... | - src_ip - IP of source interface (TG-if1). Type: integer
422 | | ... | - dst_ip - IP of destination interface (TG-if2). Type: integer
423 | | ... | - tx_port - Source interface (TG-if1). Type: string
424 | | ... | - tx_mac - MAC address of source interface (TG-if1). Type: string
425 | | ... | - rx_port - Destionation interface (TG-if1). Type: string
426 | | ... | - rx_mac - MAC address of destination interface (TG-if1). Type: string
427 | | ... | - icmp_type - ICMP type to use. Type: int
428 | | ... | - icmp_code - ICMP code to use. Type: int
429 | | ...
430 | | ... | *Example:*
431 | | ...
432 | | ... | \| Send ICMP packet with type and code and verify received packet \| ${nodes['TG']} \
433 | | ... | \| 16.0.0.1 \| 32.0.0.1 \| eth2 \| 08:00:27:cc:4f:54 \
434 | | ... | \| eth4 \| 08:00:27:c9:6a:d5 \| ${1} \| ${1} \|
435 | | ...
436 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_port} |
437 | | ... | ${tx_mac} | ${rx_port} | ${rx_mac} | ${icmp_type} | ${icmp_code}
438 | | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_port}
439 | | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port}
440 | | ${args}= | Catenate | --src_mac | ${tx_mac}
441 | | ...                 | --dst_mac | ${rx_mac}
442 | | ...                 | --src_ip | ${src_ip}
443 | | ...                 | --dst_ip | ${dst_ip}
444 | | ...                 | --tx_if | ${tx_port_name}
445 | | ...                 | --rx_if | ${rx_port_name}
446 | | ...                 | --icmp_type | ${icmp_type}
447 | | ...                 | --icmp_code | ${icmp_code}
448 | | Run Traffic Script On Node | send_icmp_type_code.py
449 | | ... | ${tg_node} | ${args}