CSIT-427: Honeycomb ietf-ACL tests - L2
[csit.git] / resources / libraries / robot / honeycomb / access_control_lists.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 *** Variables ***
14 #TODO: update based on resolution of bug https://jira.fd.io/browse/HONEYCOMB-119
15 | @{hc_table_ignore}= | memory_size
16
17 *** Settings ***
18 | Library | resources.libraries.python.Classify
19 | Library | resources.libraries.python.InterfaceUtil
20 | Library | resources.libraries.python.honeycomb.HcAPIKwACL.ACLKeywords
21 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
22 | ...     | WITH NAME | InterfaceAPI
23 | Documentation | Keywords used to manage ACLs.
24
25 *** Keywords ***
26 | Honeycomb creates ACL table
27 | | [Documentation] | Uses Honeycomb API to create an ACL table.
28 | | ...
29 | | ... | *Arguments:*
30 | | ... | - node - information about a DUT node. Type: dictionary
31 | | ... | - settings - ACL table settings. Type: dictionary
32 | | ...
33 | | ... | *Example:*
34 | | ...
35 | | ... | \| Honeycomb creates ACL table \| ${nodes['DUT1']} \
36 | | ... | \| ${settings} \|
37 | | [Arguments] | ${node} | ${settings}
38 | | Add classify table | ${node} | ${settings}
39
40 | Honeycomb removes ACL table
41 | | [Documentation] | Uses Honeycomb API to remove and existing ACL table.
42 | | ...
43 | | ... | *Arguments:*
44 | | ... | - node - information about a DUT node. Type: dictionary
45 | | ... | - table_name - name of an ACL table. Type: string
46 | | ...
47 | | ... | *Example:*
48 | | ...
49 | | ... | \| Honeycomb removes ACL table \| ${nodes['DUT1']} \| table0 \|
50 | | [Arguments] | ${node} | ${table_name}
51 | | Remove classify table | ${node} | ${table_name}
52
53 | Honeycomb adds ACL session
54 | | [Documentation] | Uses Honeycomb API to create an ACL session.
55 | | ...
56 | | ... | *Arguments:*
57 | | ... | - node - information about a DUT node. Type: dictionary
58 | | ... | - table_name - name of an ACL table. Type: string
59 | | ... | - settings - ACL session settings. Type: dictionary
60 | | ...
61 | | ... | *Example:*
62 | | ...
63 | | ... | \| Honeycomb adds ACL session \| ${nodes['DUT1']} \
64 | | ... | \| table0 \| ${settings} \|
65 | | [Arguments] | ${node} | ${table_name} | ${settings}
66 | | Add classify session | ${node} | ${table_name} | ${settings}
67
68 | Honeycomb removes ACL session
69 | | [Documentation] | Uses Honeycomb API to remove an ACL session.
70 | | ...
71 | | ... | *Arguments:*
72 | | ... | - node - information about a DUT node. Type: dictionary
73 | | ... | - table_name - name of an ACL table. Type: string
74 | | ... | - match - ACL session match setting. Type: string
75 | | ...
76 | | ... | *Example:*
77 | | ...
78 | | ... | \| Honeycomb removes ACL session \| ${nodes['DUT1']} \
79 | | ... | \| table0 \| 00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00 \|
80 | | [Arguments] | ${node} | ${table_name} | ${match}
81 | | Remove classify session | ${node} | ${table_name} | ${match}
82
83 | Honeycomb enables ACL on interface
84 | | [Documentation] | Uses Honeycomb API to enable ACL on an interface.
85 | | ...
86 | | ... | *Arguments:*
87 | | ... | - node - information about a DUT node. Type: dictionary
88 | | ... | - interface - name of an interface on the specified node. Type: string
89 | | ... | - table_name - name of an ACL table. Type: string
90 | | ...
91 | | ... | *Example:*
92 | | ...
93 | | ... | \| Honeycomb enables ACL on interface \| ${nodes['DUT1']} \
94 | | ... | \| GigabithEthernet0/8/0 \| table0 \|
95 | | [Arguments] | ${node} | ${interface} | ${table_name}
96 | | InterfaceAPI.Enable ACL on interface
97 | | ... | ${node} | ${interface} | ${table_name}
98
99 | Honeycomb disables ACL on interface
100 | | [Documentation] | Uses Honeycomb API to disable ACL on an interface.
101 | | ...
102 | | ... | *Arguments:*
103 | | ... | - node - information about a DUT node. Type: dictionary
104 | | ... | - interface - name of an interface on the specified node. Type: string
105 | | ...
106 | | ... | *Example:*
107 | | ...
108 | | ... | \| Honeycomb disables ACL on interface \| ${nodes['DUT1']} \
109 | | ... | \| GigabithEthernet0/8/0 \|
110 | | [Arguments] | ${node} | ${interface}
111 | | InterfaceAPI.Disable ACL on interface | ${node} | ${interface}
112
113 | ACL table from Honeycomb should be
114 | | [Documentation] | Retrieves ACL table information from Honeycomb\
115 | | ... | and compares with expected settings.
116 | | ...
117 | | ... | *Arguments:*
118 | | ... | - node - information about a DUT node. Type: dictionary
119 | | ... | - settings - expected ACL table settings. Type: dictionary
120 | | ...
121 | | ... | *Example:*
122 | | ...
123 | | ... | \| ACL table from Honeycomb should be \| ${nodes['DUT1']} \
124 | | ... | \| ${settings} \|
125 | | [Arguments] | ${node} | ${settings}
126 | | ${data}= | Get classify table oper data | ${node} | ${settings['name']}
127 | | Compare data structures | ${data} | ${settings} | ignore=${hc_table_ignore}
128
129 | ACL table from VAT should be
130 | | [Documentation] | Retrieves ACL table information from VAT\
131 | | ... | and compares with expected settings.
132 | | ...
133 | | ... | *Arguments:*
134 | | ... | - node - information about a DUT node. Type: dictionary
135 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
136 | | ... | - settings - expected ACL table settings. Type: dictionary
137 | | ...
138 | | ... | *Example:*
139 | | ...
140 | | ... | \| ACL session from VAT should be \| ${nodes['DUT1']} \
141 | | ... | \| ${0} \| ${settings} \|
142 | | [Arguments] | ${node} | ${table_index} | ${settings}
143 | | ${data}= | Get classify table data | ${node} | ${table_index}
144 | | Compare data structures | ${data} | ${settings}
145
146 | ACL table from Honeycomb should not exist
147 | | [Documentation] | Retrieves ACL table information from Honeycomb\
148 | | ... | and expects to fail.
149 | | ...
150 | | ... | *Arguments:*
151 | | ... | - node - information about a DUT node. Type: dictionary
152 | | ... | - table_name - name of an ACL table. Type: string
153 | | ...
154 | | ... | *Example:*
155 | | ...
156 | | ... | \| ACL table from Honeycomb should not exist \| ${nodes['DUT1']} \
157 | | ... | \| table0 \|
158 | | [Arguments] | ${node} | ${table_name}
159 | | Run keyword and expect error | ValueError: No JSON object could be decoded
160 | | ... | Get classify table oper data | ${node} | ${table_name}
161
162 | ACL table from VAT should not exist
163 | | [Documentation] | Retrieves ACL table information from VAT\
164 | | ... | and expects to fail.
165 | | ...
166 | | ... | *Arguments:*
167 | | ... | - node - information about a DUT node. Type: dictionary
168 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
169 | | ...
170 | | ... | *Example:*
171 | | ...
172 | | ... | \| ACL table from VAT should not exist \| ${nodes['DUT1']} \
173 | | ... | \| ${0} \|
174 | | [Arguments] | ${node} | ${table_index}
175 | | Run keyword and expect error | No JSON data.
176 | | ... | Get classify table data | ${node} | ${table_index}
177
178 | ACL session from Honeycomb should be
179 | | [Documentation] | Retrieves ACL session information from Honeycomb\
180 | | ... | and compares with expected settings.
181 | | ...
182 | | ... | *Arguments:*
183 | | ... | - node - information about a DUT node. Type: dictionary
184 | | ... | - table_name - name of an ACL table. Type: string
185 | | ... | - settings - expected ACL session settings. Type: dictionary
186 | | ...
187 | | ... | *Example:*
188 | | ...
189 | | ... | \| ACL session from Honeycomb should be \| ${nodes['DUT1']} \
190 | | ... | \| table0 \| ${settings} \|
191 | | [Arguments] | ${node} | ${table_name} | ${settings}
192 | | ${data}= | Get classify session oper data
193 | | ... | ${node} | ${table_name} | ${settings['match']}
194 | | Compare data structures | ${data} | ${settings}
195
196 | ACL session from VAT should be
197 | | [Documentation] | Retrieves ACL session information from VAT\
198 | | ... | and compares with expected settings.
199 | | ...
200 | | ... | *Arguments:*
201 | | ... | - node - information about a DUT node. Type: dictionary
202 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
203 | | ... | - session_index - VPP internal index of an ACL session. Type: integer
204 | | ... | - settings - expected ACL session settings. Type: dictionary
205 | | ...
206 | | ... | *Example:*
207 | | ...
208 | | ... | \| ACL session from VAT should be \| ${nodes['DUT1']} \
209 | | ... | \| ${0} \| ${0} \| ${settings} \|
210 | | [Arguments] | ${node} | ${table_index} | ${session_index} | ${settings}
211 | | ${data}= | Get classify session data
212 | | ... | ${node} | ${table_index} | ${session_index}
213 | | Compare data structures | ${data} | ${settings}
214
215 | ACL session from Honeycomb should not exist
216 | | [Documentation] | Retrieves ACL session information from Honeycomb\
217 | | ... | and expects to fail.
218 | | ...
219 | | ... | *Arguments:*
220 | | ... | - node - information about a DUT node. Type: dictionary
221 | | ... | - table_name - name of an ACL table. Type: string
222 | | ... | - session_match - ACL session match setting. Type: string
223 | | ...
224 | | ... | *Example:*
225 | | ...
226 | | ... | \| ACL session from Honeycomb should not exist \| ${nodes['DUT1']} \
227 | | ... | \| table0 \| 00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00 \|
228 | | [Arguments] | ${node} | ${table_name} | ${session_match}
229 | | Run keyword and expect error | *HoneycombError: *Status code: 404.
230 | | ... | Get classify session oper data
231 | | ... | ${node} | ${table_name} | ${session_match}
232
233 | ACL session from VAT should not exist
234 | | [Documentation] | Retrieves ACL session information from VAT\
235 | | ... | and compares with expected settings.
236 | | ...
237 | | ... | *Arguments:*
238 | | ... | - node - information about a DUT node. Type: dictionary
239 | | ... | - table_index - VPP internal index of an ACL table. Type: integer
240 | | ... | - session_index - VPP internal index of an ACL session. Type: integer
241 | | ...
242 | | ... | *Example:*
243 | | ...
244 | | ... | \| ACL session from VAT should not exist \| ${nodes['DUT1']} \
245 | | ... | \| ${0} \| ${0} \|
246 | | [Arguments] | ${node} | ${table_index} | ${session_index}
247 | | Run keyword if | ${session_index} == 0
248 | | ... | Run keyword and expect error
249 | | ... | ValueError: No JSON object could be decoded
250 | | ... | Get classify session data
251 | | ... | ${node} | ${table_index} | ${session_index}
252 | | Run keyword if | ${session_index} > 0
253 | | ... | Run keyword and expect error
254 | | ... | IndexError: list index out of range
255 | | ... | Get classify session data
256 | | ... | ${node} | ${table_index} | ${session_index}
257
258 | Interface ACL settings from Honeycomb should be
259 | | [Documentation] | Retrieves ACL interface settings from Honeycomb\
260 | | ... | and compares with expected settings.
261 | | ...
262 | | ... | *Arguments:*
263 | | ... | - node - information about a DUT node. Type: dictionary
264 | | ... | - interface - name of an interface on the specified node. Type: string
265 | | ... | - table_name - expected ACL table name. Type: string
266 | | ...
267 | | ... | *Example:*
268 | | ...
269 | | ... | \| Interface ACL settings from Honeycomb should be \
270 | | ... | \| ${nodes['DUT1']} \| GigabithEthernet0/8/0 \| table0 \|
271 | | [Arguments] | ${node} | ${interface} | ${table_name}
272 | | ${data}= | InterfaceAPI.Get interface oper data | ${node} | ${interface}
273 | | Should be equal
274 | | ... | ${table_name} | ${data['v3po:acl']['l2-acl']['classify-table']}
275
276 | Interface ACL settings 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 settings from VAT should be \| ${nodes['DUT1']} \
288 | | ... | \| GigabithEthernet0/8/0 \| ${0} \|
289 | | [Arguments] | ${node} | ${interface} | ${table_index}
290 | | ${data}= | Get interface classify table | ${node} | ${interface}
291 | | Should be equal | ${table_index} | ${data['l2_table_id']}
292 | | Should be equal | ${table_index} | ${data['ip4_table_id']}
293
294 | Interface ACL settings from Honeycomb should be empty
295 | | [Documentation] | Retrieves ACL interface settings from Honeycomb\
296 | | ... | and expects to fail.
297 | | ...
298 | | ... | *Arguments:*
299 | | ... | - node - information about a DUT node. Type: dictionary
300 | | ... | - interface - name of an interface on the specified node. Type: string
301 | | ...
302 | | ... | *Example:*
303 | | ...
304 | | ... | \| Interface ACL settings from Honeycomb should be empty \
305 | | ... | \| ${nodes['DUT1']} \| GigabithEthernet0/8/0 \|
306 | | [Arguments] | ${node} | ${interface}
307 | | ${data}= | InterfaceAPI.Get interface oper data | ${node} | ${interface}
308 | | Run keyword and expect error | *KeyError: 'v3po:acl'
309 | | ... | Set Variable | ${data['v3po:acl']['l2-acl']['classify-table']}
310
311 | Interface ACL settings from VAT should be empty
312 | | [Documentation] | Retrieves ACL interface settings from VAT\
313 | | ... | and expects to fail.
314 | | ...
315 | | ... | *Arguments:*
316 | | ... | - node - information about a DUT node. Type: dictionary
317 | | ... | - interface - name of an interface on the specified node. Type: string
318 | | ...
319 | | ... | *Example:*
320 | | ...
321 | | ... | \| Interface ACL settings from Honeycomb should be empty \
322 | | ... | \| ${nodes['DUT1']} \| GigabithEthernet0/8/0 \|
323 | | [Arguments] | ${node} | ${interface}
324 | | ${data}= | Get interface classify table | ${node} | ${interface}
325 | | Should be equal | ${data['l2_table_id']} | ${-1}
326 | | Should be equal | ${data['ip4_table_id']} | ${-1}
327
328 | Clear all ACL settings
329 | | [Documentation] | Removes all ACL sessions and tables from Honeycomb\
330 | | ... | configuration.
331 | | ...
332 | | ... | *Arguments:*
333 | | ... | - node - information about a DUT node. Type: dictionary
334 | | ...
335 | | ... | *Example:*
336 | | ...
337 | | ... | \| Clear all ACL settings \| ${nodes['DUT1']} \|
338 | | [Arguments] | ${node}
339 | | Remove all classify tables | ${node}
340
341 | Honeycomb creates ACL chain through IETF node
342 | | [Documentation] | Creates classify chain through the high-level\
343 | | ... | IETF-ACL node.
344 | | ...
345 | | ... | *Arguments:*
346 | | ... | - node - Information about a DUT node. Type: dictionary
347 | | ... | - acl_list_name - Name for the classify chain. Type: string
348 | | ... | - layer - Classification layer (L2, L3, L4, mixed). Type: string
349 | | ... | - acl_list_settings - classify rules. Type: dictionary
350 | | ...
351 | | ... | *Example:*
352 | | ...
353 | | ... | \| Honeycomb creates ACL chain through IETF node \
354 | | ... | \| ${nodes['DUT1']} \| acl_test \| ${settings} \|
355 | | [Arguments] | ${node} | ${acl_list_name} | ${layer} | ${acl_list_settings}
356 | | Create IETF classify chain
357 | | ... | ${node} | ${acl_list_name} | ${layer} | ${acl_list_settings}
358
359 | Honeycomb assigns IETF-ACL chain to interface
360 | | [Documentation] | Applies classification through the high-level\
361 | | ... | IETF-ACL node to an interface.
362 | | ...
363 | | ... | *Arguments:*
364 | | ... | - node - Information about a DUT node. Type: dictionary
365 | | ... | - interface - Interface to apply classifier to. | Type: string
366 | | ... | - layer - Classification layer (L2, L3, L4, mixed). Type: string
367 | | ... | - direction - Ingress or Egress ACL. Type: string
368 | | ... | - acl_list_name - Name of the classify chain to apply. Type: string
369 | | ... | - default_action - Default classify action: permit or deny.\
370 | | ... | Type: string
371 | | ...
372 | | ... | *Example:*
373 | | ...
374 | | ... | \| Honeycomb assigns IETF-ACL chain to interface \
375 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| L2 \| ingress \
376 | | ... | \| acl_test \| permit \|
377 | | [Arguments]
378 | | ... | ${node} | ${interface} | ${layer} | ${direction} | ${acl_list_name}
379 | | ... | ${default-action}
380 | | Set IETF interface ACL
381 | | ... | ${node} | ${interface} | ${layer} | ${direction} | ${acl_list_name}
382 | | ... | ${default-action}
383
384 | Clear IETF-ACL settings
385 | | [Documentation] | Removes ACl assignment from interface, then deletes\
386 | | ... | IETF-ACL chain.
387 | | ...
388 | | ... | *Arguments:*
389 | | ... | - node - Information about a DUT node. Type: dictionary
390 | | ... | - interface - Interface to clean classifiers from. | Type: string
391 | | ...
392 | | ... | *Example:*
393 | | ...
394 | | ... | Clear IETF-ACL settings | ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
395 | | [Arguments] | ${node} | ${interface}
396 | | Delete IETF interface ACLs | ${node} | ${interface}
397 | | Delete IETF classify chains | ${node}