HC Test: update URL paths for vpp-acl
[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 | ...     | WITH NAME | InterfaceAPI
22 | Documentation | Keywords used to manage ACLs.
23
24 *** Keywords ***
25 | Honeycomb creates ACL table
26 | | [Documentation] | Uses Honeycomb API to create an ACL table.
27 | | ...
28 | | ... | *Arguments:*
29 | | ... | - node - information about a DUT node. Type: dictionary
30 | | ... | - settings - ACL table settings. Type: dictionary
31 | | ...
32 | | ... | *Example:*
33 | | ...
34 | | ... | \| Honeycomb creates ACL table \| ${nodes['DUT1']} \
35 | | ... | \| ${settings} \|
36 | | [Arguments] | ${node} | ${settings}
37 | | Add classify table | ${node} | ${settings}
38
39 | Honeycomb removes ACL table
40 | | [Documentation] | Uses Honeycomb API to remove and existing ACL table.
41 | | ...
42 | | ... | *Arguments:*
43 | | ... | - node - information about a DUT node. Type: dictionary
44 | | ... | - table_name - name of an ACL table. Type: string
45 | | ...
46 | | ... | *Example:*
47 | | ...
48 | | ... | \| Honeycomb removes ACL table \| ${nodes['DUT1']} \| table0 \|
49 | | [Arguments] | ${node} | ${table_name}
50 | | Remove classify table | ${node} | ${table_name}
51
52 | Honeycomb adds ACL session
53 | | [Documentation] | Uses Honeycomb API to create an ACL session.
54 | | ...
55 | | ... | *Arguments:*
56 | | ... | - node - information about a DUT node. Type: dictionary
57 | | ... | - table_name - name of an ACL table. Type: string
58 | | ... | - settings - ACL session settings. Type: dictionary
59 | | ...
60 | | ... | *Example:*
61 | | ...
62 | | ... | \| Honeycomb adds ACL session \| ${nodes['DUT1']} \
63 | | ... | \| table0 \| ${settings} \|
64 | | [Arguments] | ${node} | ${table_name} | ${settings}
65 | | Add classify session | ${node} | ${table_name} | ${settings}
66
67 | Honeycomb removes ACL session
68 | | [Documentation] | Uses Honeycomb API to remove an ACL session.
69 | | ...
70 | | ... | *Arguments:*
71 | | ... | - node - information about a DUT node. Type: dictionary
72 | | ... | - table_name - name of an ACL table. Type: string
73 | | ... | - match - ACL session match setting. Type: string
74 | | ...
75 | | ... | *Example:*
76 | | ...
77 | | ... | \| Honeycomb removes ACL session \| ${nodes['DUT1']} \
78 | | ... | \| table0 \| 00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00 \|
79 | | [Arguments] | ${node} | ${table_name} | ${match}
80 | | Remove classify session | ${node} | ${table_name} | ${match}
81
82 | Honeycomb enables ACL on interface
83 | | [Documentation] | Uses Honeycomb API to enable ACL on an interface.
84 | | ...
85 | | ... | *Arguments:*
86 | | ... | - node - information about a DUT node. Type: dictionary
87 | | ... | - interface - name of an interface on the specified node. Type: string
88 | | ... | - table_name - name of an ACL table. Type: string
89 | | ...
90 | | ... | *Example:*
91 | | ...
92 | | ... | \| Honeycomb enables ACL on interface \| ${nodes['DUT1']} \
93 | | ... | \| GigabithEthernet0/8/0 \| table0 \|
94 | | [Arguments] | ${node} | ${interface} | ${table_name}
95 | | InterfaceAPI.Enable ACL on interface
96 | | ... | ${node} | ${interface} | ${table_name}
97
98 | Honeycomb disables ACL on interface
99 | | [Documentation] | Uses Honeycomb API to disable ACL on an interface.
100 | | ...
101 | | ... | *Arguments:*
102 | | ... | - node - information about a DUT node. Type: dictionary
103 | | ... | - interface - name of an interface on the specified node. Type: string
104 | | ...
105 | | ... | *Example:*
106 | | ...
107 | | ... | \| Honeycomb disables ACL on interface \| ${nodes['DUT1']} \
108 | | ... | \| GigabithEthernet0/8/0 \|
109 | | [Arguments] | ${node} | ${interface}
110 | | InterfaceAPI.Disable ACL on interface | ${node} | ${interface}
111
112 | ACL table from Honeycomb should be
113 | | [Documentation] | Retrieves ACL table information from Honeycomb\
114 | | ... | and compares with expected settings.
115 | | ...
116 | | ... | *Arguments:*
117 | | ... | - node - information about a DUT node. Type: dictionary
118 | | ... | - settings - expected ACL table settings. Type: dictionary
119 | | ...
120 | | ... | *Example:*
121 | | ...
122 | | ... | \| ACL table from Honeycomb should be \| ${nodes['DUT1']} \
123 | | ... | \| ${settings} \|
124 | | [Arguments] | ${node} | ${settings}
125 | | ${data}= | Get classify table oper data | ${node} | ${settings['name']}
126 | | Compare data structures | ${data} | ${settings}
127
128 | ACL table from VAT should be
129 | | [Documentation] | Retrieves ACL table information from VAT\
130 | | ... | and compares with expected settings.
131 | | ...
132 | | ... | *Arguments:*
133 | | ... | - node - information about a DUT node. Type: dictionary
134 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
135 | | ... | - settings - expected ACL table settings. Type: dictionary
136 | | ...
137 | | ... | *Example:*
138 | | ...
139 | | ... | \| ACL session from VAT should be \| ${nodes['DUT1']} \
140 | | ... | \| ${0} \| ${settings} \|
141 | | [Arguments] | ${node} | ${table_index} | ${settings}
142 | | ${data}= | Get classify table data | ${node} | ${table_index}
143 | | Compare data structures | ${data} | ${settings}
144
145 | ACL table from Honeycomb should not exist
146 | | [Documentation] | Retrieves ACL table information from Honeycomb\
147 | | ... | and expects to fail.
148 | | ...
149 | | ... | *Arguments:*
150 | | ... | - node - information about a DUT node. Type: dictionary
151 | | ... | - table_name - name of an ACL table. Type: string
152 | | ...
153 | | ... | *Example:*
154 | | ...
155 | | ... | \| ACL table from Honeycomb should not exist \| ${nodes['DUT1']} \
156 | | ... | \| table0 \|
157 | | [Arguments] | ${node} | ${table_name}
158 | | Run keyword and expect error | ValueError: No JSON object could be decoded
159 | | ... | Get classify table oper data | ${node} | ${table_name}
160
161 | ACL table from VAT should not exist
162 | | [Documentation] | Retrieves ACL table information from VAT\
163 | | ... | and expects to fail.
164 | | ...
165 | | ... | *Arguments:*
166 | | ... | - node - information about a DUT node. Type: dictionary
167 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
168 | | ...
169 | | ... | *Example:*
170 | | ...
171 | | ... | \| ACL table from VAT should not exist \| ${nodes['DUT1']} \
172 | | ... | \| ${0} \|
173 | | [Arguments] | ${node} | ${table_index}
174 | | Run keyword and expect error | VAT: no JSON data.
175 | | ... | Get classify table data | ${node} | ${table_index}
176
177 | ACL session from Honeycomb should be
178 | | [Documentation] | Retrieves ACL session information from Honeycomb\
179 | | ... | and compares with expected settings.
180 | | ...
181 | | ... | *Arguments:*
182 | | ... | - node - information about a DUT node. Type: dictionary
183 | | ... | - table_name - name of an ACL table. Type: string
184 | | ... | - settings - expected ACL session settings. Type: dictionary
185 | | ...
186 | | ... | *Example:*
187 | | ...
188 | | ... | \| ACL session from Honeycomb should be \| ${nodes['DUT1']} \
189 | | ... | \| table0 \| ${settings} \|
190 | | [Arguments] | ${node} | ${table_name} | ${settings}
191 | | ${data}= | Get classify session oper data
192 | | ... | ${node} | ${table_name} | ${settings['match']}
193 | | Compare data structures | ${data} | ${settings}
194
195 | ACL session from VAT should be
196 | | [Documentation] | Retrieves ACL session information from VAT\
197 | | ... | and compares with expected settings.
198 | | ...
199 | | ... | *Arguments:*
200 | | ... | - node - information about a DUT node. Type: dictionary
201 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
202 | | ... | - session_index - VPP internal index of an ACL session. Type: integer
203 | | ... | - settings - expected ACL session settings. Type: dictionary
204 | | ...
205 | | ... | *Example:*
206 | | ...
207 | | ... | \| ACL session from VAT should be \| ${nodes['DUT1']} \
208 | | ... | \| ${0} \| ${0} \| ${settings} \|
209 | | [Arguments] | ${node} | ${table_index} | ${session_index} | ${settings}
210 | | ${data}= | Get classify session data
211 | | ... | ${node} | ${table_index} | ${session_index}
212 | | Compare data structures | ${data} | ${settings}
213
214 | ACL session from Honeycomb should not exist
215 | | [Documentation] | Retrieves ACL session information from Honeycomb\
216 | | ... | and expects to fail.
217 | | ...
218 | | ... | *Arguments:*
219 | | ... | - node - information about a DUT node. Type: dictionary
220 | | ... | - table_name - name of an ACL table. Type: string
221 | | ... | - session_match - ACL session match setting. Type: string
222 | | ...
223 | | ... | *Example:*
224 | | ...
225 | | ... | \| ACL session from Honeycomb should not exist \| ${nodes['DUT1']} \
226 | | ... | \| table0 \| 00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00 \|
227 | | [Arguments] | ${node} | ${table_name} | ${session_match}
228 | | Run keyword and expect error | *HoneycombError: *Status code: 404.
229 | | ... | Get classify session oper data
230 | | ... | ${node} | ${table_name} | ${session_match}
231
232 | ACL session from VAT should not exist
233 | | [Documentation] | Retrieves ACL session information from VAT\
234 | | ... | and compares with expected settings.
235 | | ...
236 | | ... | *Arguments:*
237 | | ... | - node - information about a DUT node. Type: dictionary
238 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
239 | | ... | - session_index - VPP internal index of an ACL session. Type: integer
240 | | ...
241 | | ... | *Example:*
242 | | ...
243 | | ... | \| ACL session from VAT should not exist \| ${nodes['DUT1']} \
244 | | ... | \| ${0} \| ${0} \|
245 | | [Arguments] | ${node} | ${table_index} | ${session_index}
246 | | Run keyword if | ${session_index} == 0
247 | | ... | Run keyword and expect error
248 | | ... | ValueError: No JSON object could be decoded
249 | | ... | Get classify session data
250 | | ... | ${node} | ${table_index} | ${session_index}
251 | | Run keyword if | ${session_index} > 0
252 | | ... | Run keyword and expect error
253 | | ... | IndexError: list index out of range
254 | | ... | Get classify session data
255 | | ... | ${node} | ${table_index} | ${session_index}
256
257 | Interface ACL settings from Honeycomb should be
258 | | [Documentation] | Retrieves ACL interface settings from Honeycomb\
259 | | ... | and compares with expected settings.
260 | | ...
261 | | ... | *Arguments:*
262 | | ... | - node - information about a DUT node. Type: dictionary
263 | | ... | - interface - name of an interface on the specified node. Type: string
264 | | ... | - table_name - expected ACL table name. Type: string
265 | | ...
266 | | ... | *Example:*
267 | | ...
268 | | ... | \| Interface ACL settings from Honeycomb should be \
269 | | ... | \| ${nodes['DUT1']} \| GigabithEthernet0/8/0 \| table0 \|
270 | | [Arguments] | ${node} | ${interface} | ${table_name}
271 | | ${data}= | InterfaceAPI.Get interface oper data | ${node} | ${interface}
272 | | Should be equal
273 | | ... | ${table_name}
274 | | ... | ${data['vpp-interface-acl:acl']['ingress']['l2-acl']['classify-table']}
275 | | ... | ${data['vpp-interface-acl:acl']['ingress']['ip4-acl']['classify-table']}
276
277 | Interface ACL settings from VAT should be
278 | | [Documentation] | Retrieves ACL interface settings from VAT\
279 | | ... | and compares with expected settings.
280 | | ...
281 | | ... | *Arguments:*
282 | | ... | - node - information about a DUT node. Type: dictionary
283 | | ... | - interface - name of an interface on the specified node. Type: string
284 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
285 | | ...
286 | | ... | *Example:*
287 | | ...
288 | | ... | \| Interface ACL settings from VAT should be \| ${nodes['DUT1']} \
289 | | ... | \| GigabithEthernet0/8/0 \| ${0} \|
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 settings 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 settings from Honeycomb should be empty \
306 | | ... | \| ${nodes['DUT1']} \| GigabithEthernet0/8/0 \|
307 | | [Arguments] | ${node} | ${interface}
308 | | ${data}= | InterfaceAPI.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 settings 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 settings 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 settings
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 settings | ${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
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 \| ${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}