xref: /openbmc/openbmc-test-automation/ipmi/test_ipmi_payload.robot (revision 87dc442c6650dd0badacef4a71ac62667d20ab40)
1*** Settings ***
2Documentation       This suite tests IPMI Payload in OpenBMC.
3
4Resource            ../lib/ipmi_client.robot
5Resource            ../lib/openbmc_ffdc.robot
6Resource            ../lib/bmc_network_utils.robot
7Variables           ../data/ipmi_raw_cmd_table.py
8Library             ../lib/ipmi_utils.py
9
10Suite Setup         IPMI Payload Setup Execution
11Test Teardown       FFDC On Test Case Fail
12
13Force Tags          IPMI_Payload
14
15*** Variables ***
16
17${user_priv}                     2
18${operator_priv}                 3
19${admin_level_priv}              4
20${no_access_priv}                15
21${new_user_passwd}               0penBmc1
22${standard_payload_type_resp}    03 00
23${session_setup_payload_resp}    3f 00
24&{standard_payload_types}        ipmi_message=0  sol=1
25&{session_setup_payload_types}  RMCP+open_session_request=0x10
26                           ...  RMCP+open_session_response=0x11
27                           ...  RAKP_msg_1=0x12
28                           ...  RAKP_msg_2=0x13
29                           ...  RAKP_msg_3=0x14
30                           ...  RAKP_msg_4=0x15
31
32
33*** Test Cases ***
34
35Test Get Payload Activation Status
36    [Documentation]  Test get payload activation status.
37    [Tags]  Test_Get_Payload_Activation_Status
38
39    # SOL is the payload currently supported for payload status.
40    # Currently supports only one SOL session.
41    # Response Data
42    # 01   instance 1 is activated.
43    # 00   instance 1 is deactivated.
44    ${payload_status}=  Get Payload Activation Status
45    Should Contain Any  ${payload_status}  01  00
46
47
48Test Activate Payload
49    [Documentation]  Test activate payload via IPMI raw command.
50    [Tags]  Test_Activate_Payload
51
52    ${payload_status}=  Get Payload Activation Status
53    Run Keyword If  '${payload_status}' == '01'  Deactivate Payload
54
55    Activate Payload
56
57    ${payload_status}=  Get Payload Activation Status
58    Should Contain  ${payload_status}  01
59
60
61Test Deactivate Payload
62    [Documentation]  Test deactivate payload via IPMI raw command.
63    [Tags]  Test_Deactivate_Payload
64
65    ${payload_status}=  Get Payload Activation Status
66    Run Keyword If  '${payload_status}' == '00'  Activate Payload
67
68    Deactivate Payload
69
70    ${payload_status}=  Get Payload Activation Status
71    Should Contain  ${payload_status}  00
72
73
74Test Get Payload Instance Info
75    [Documentation]  Test Get Payload Instance via IPMI raw command.
76    [Tags]  Test_Get_Payload_Instance_Info
77
78    ${payload_status}=  Get Payload Activation Status
79    Run keyword If  '${payload_status}' == '01'
80    ...  Deactivate Payload
81
82    # First four bytes should be 00 if given instance is not activated.
83    ${resp}=  Run IPMI Command
84    ...  ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][0]}
85    Should Contain  ${resp}  ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][1]}
86    Activate Payload
87
88    # First four bytes should be session ID when payload is activated.
89    ${resp}=  Run IPMI Command
90    ...  ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][0]}
91    Should Not Contain  ${resp}  ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][1]}
92
93
94Verify Set User Access Payload For Standard Payload SOL
95    [Documentation]  Disable standard payload for SOL and verify IPMI sol activate command does not work.
96    [Tags]  Verify_Set_User_Access_Payload_For_Standard_Payload_SOL
97    [Teardown]  Run Keywords  Set User Access Payload For Given User  ${user_id_in_hex}
98    ...  AND  Delete Created User  ${userid}
99    ...  AND  FFDC On Test Case Fail
100
101    ${userid}  ${username}=  Create And Verify IPMI User
102    ${user_id_in_hex}=  Convert To Hex  ${userid}
103    ${userid_in_hex_format}=  Convert To Hex  ${userid}  prefix=0x  length=2
104
105    # Get default user access payload values.
106    ${default_user_access_payload}=  Get User Access Payload For Given Channel  ${userid_in_hex_format}
107
108    # Disable Standard payload 1 via set user access payload command.
109    Set User Access Payload For Given User  ${user_id_in_hex}  Disable
110
111    Verify Standard Payload  ${userid_in_hex_format}  ${username}  Disabled
112
113
114Verify Set User Access Payload For Operator Privileged User
115    [Documentation]  Try to set user access payload using operator privileged user and expect error.
116    [Tags]  Verify_Set_User_Access_Payload_For_Operator_Privileged_User
117    [Teardown]  Run Keywords  Delete Created User  ${userid}  AND  FFDC On Test Case Fail
118
119    ${userid}  ${username}=  Create And Verify IPMI User  ${operator_priv}  Operator
120
121    ${payload_raw_cmd}=  Catenate  ${IPMI_RAW_CMD['Payload']['Set_User_Access_Payload'][0]}
122    ...  ${CHANNEL_NUMBER} 0x${user_id} 0x02 0x00 0x00 0x00
123
124    Run Keyword and Expect Error  *Unable to establish IPMI*
125    ...  Run External IPMI Raw Command  ${payload_raw_cmd}  U=${userid}  P=${new_user_passwd}  L=Operator
126
127
128Verify Set User Access Payload For Invalid User
129    [Documentation]  Verify set user access payload IPMI command for invalid user.
130    [Tags]  Verify_Set_User_Access_Payload_For_Invalid_User
131
132    # Get Random invalid user ID.
133    ${invalid_userid}=  Get Invalid User ID
134
135    ${raw_cmd}=  Catenate   ${IPMI_RAW_CMD['Payload']['Set_User_Access_Payload'][0]}
136    ...  ${CHANNEL_NUMBER} ${invalid_userid} 0x02 0x00 0x00 0x00
137
138    Verify Invalid IPMI Command  ${raw_cmd}  0xcc
139
140
141Verify Set User Access Payload For Invalid Channel Number
142    [Documentation]  Verify set user access payload IPMI command for invalid channel number.
143    [Tags]  Verify_Set_User_Access_Payload_For_Invalid_Channel_Number
144    [Teardown]  Delete Created User  ${userid}
145
146    ${userid}  ${username}=  Create And Verify IPMI User
147
148    FOR  ${channel}  IN  @{inactive_channel_list}
149
150        Verify Set User Access Payload For Invalid Channel  ${userid}  ${channel}
151    END
152
153
154Verify Get User Access Payload For User Access privilege
155    [Documentation]   Verify get user access payload for user access(Read-only) privileged user.
156    [Tags]  Verify_Get_User_Access_Payload_For_User_Access_privilege
157    [Teardown]  Delete Created User  ${userid}
158
159    ${userid}  ${username}=  Create And Verify IPMI User  ${user_priv}  User
160
161    ${raw_command}=  Catenate  ${IPMI_RAW_CMD['Payload']['Get_User_Access_Payload'][0]}
162    ...  ${CHANNEL_NUMBER} ${user_id}
163
164    Run Keyword and Expect Error  *Unable to establish IPMI*
165    ...  Run External IPMI Raw Command  ${raw_command}  U=${userid}  P=${new_user_passwd}  L=User
166
167
168Verify Get User Access Payload For Invalid User
169    [Documentation]  Verify get user access payload IPMI command for invalid user.
170    [Tags]  Verify_Get_User_Access_Payload_For_Invalid_User
171
172    ${invalid_userid}=  Get Invalid User ID
173
174    Verify Get User Access Payload For Invalid User Or Channel  ${invalid_userid}  ${CHANNEL_NUMBER}
175
176
177Verify Get User Access Payload For Invalid Channel Number
178    [Documentation]  Verify get user access payload IPMI command for invalid channel number.
179    [Tags]  Verify_Get_User_Access_Payload_For_Invalid_Channel_Number
180    [Teardown]  Delete Created User  ${userid}
181
182    ${userid}  ${username}=  Create And Verify IPMI User
183    #${invalid_channels}=  Get Invalid Channel Number
184
185    FOR  ${channel}  IN  @{inactive_channel_list}
186        Verify Get User Access Payload For Invalid User Or Channel  ${userid}  ${channel}
187    END
188
189
190Verify Get Channel Payload Version
191    [Documentation]  Verify payload version for all supported payload type in
192                ...  all active channels.
193    [Tags]  Verify_Get_Channel_Payload_Version
194    [Template]  Verify Payload Version
195
196    FOR  ${channel}  IN  @{active_channel_list}
197        # Input Channel.
198        ${channel}
199    END
200
201Verify Get Channel Payload Version For Invalid Channel
202    [Documentation]  Verify get channel payload version IPMI command for invalid channel.
203    [Tags]  Verify_Get_Channel_Payload_Version_For_Invalid_Channel
204    [Template]  Verify Payload Version For Invalid Channel
205
206    FOR  ${invalid_channel_number}  IN  @{inactive_channel_list}
207        # channel number           payload types.
208        ${invalid_channel_number}   &{standard_payload_types}
209        ${invalid_channel_number}   &{session_setup_payload_types}
210    END
211
212
213Verify Get Channel Payload Support
214    [Documentation]  Verify get channel payload support IPMI command for active channels.
215    [Tags]  Verify_Get_Channel_Payload_Support
216    [Template]  Verify Payload Support
217
218    FOR  ${channel}  IN  @{active_channel_list}
219        # Input channel.
220        ${channel}
221    END
222
223Verify Get Channel Payload Support For Invalid Channel
224    [Documentation]  Verify get channel payload support IPMI command for invalid channels.
225    [Tags]  Verify_Get_Channel_Payload_Support_For_Invalid_Channel
226    [Template]  Verify Payload Support
227
228    FOR  ${channel}  IN  @{inactive_channel_list}
229       # Input channel.      Invalid channel intimation.
230       ${channel}            ${1}
231   END
232
233
234*** Keywords ***
235
236IPMI Payload Setup Execution
237    [Documentation]  Get active and inactive/invalid channels from channel_config.json file
238    ...              in list type and set it as suite variable.
239
240    # Get active channel list and set as a suite variable.
241    @{active_channel_list}=  Get Active Ethernet Channel List  current_channel=1
242    Set Suite Variable  @{active_channel_list}
243
244    # Get Inactive/Invalid channel list and set as a suite variable.
245    @{inactive_channel_list}=  Get Invalid Channel Number List
246    Set Suite Variable  @{inactive_channel_list}
247
248
249Get Payload Activation Status
250    [Documentation]  Get payload activation status.
251
252    ${resp}=  Run IPMI Command
253    ...  ${IPMI_RAW_CMD['Payload']['Get_Payload_Activation_Status'][0]}
254
255    @{resp}=  Split String  ${resp}
256
257    ${payload_status}=  Set Variable  ${resp[1]}
258
259    [return]  ${payload_status}
260
261
262Activate Payload
263    [Documentation]  Activate Payload.
264
265    ${resp}=  Run IPMI Command
266    ...  ${IPMI_RAW_CMD['Payload']['Activate_Payload'][0]}
267    Should Contain  ${resp}  ${IPMI_RAW_CMD['Payload']['Activate_Payload'][1]}
268
269
270Deactivate Payload
271    [Documentation]  Deactivate Payload.
272
273    ${resp}=  Run IPMI Command
274    ...  ${IPMI_RAW_CMD['Payload']['Deactivate_Payload'][0]}
275    Should Be Empty  ${resp}
276
277
278Get User Access Payload For Given Channel
279    [Documentation]  Execute get user access payload IPMI command for given channel
280    ...              and return response.
281    [Arguments]  ${user_id}  ${channel_number}=${CHANNEL_NUMBER}
282
283    # Description of argument(s):
284    # user_id         The user ID (e.g. "1", "2", etc.).
285    # channel_number  Input channel number(e.g. "1", "2").
286
287    ${raw_command}=  Catenate  ${IPMI_RAW_CMD['Payload']['Get_User_Access_Payload'][0]}
288    ...  ${channel_number} ${user_id}
289    ${resp}=  Run External IPMI Raw Command  ${raw_command}
290    [Return]  ${resp}
291
292
293Create And Verify IPMI User
294    [Documentation]  Create IPMI User, set password, set privilege and enable the user.
295    [Arguments]  ${user_privilege_level}=${admin_level_priv}   ${privilege}=Administrator
296
297    # Description of argument(s):
298    # user_privilege_level   User Privilege level in integer.
299    #                        (e.g. 4-Administrator, 3-Operator, 2-Readonly).
300    # privilege              User Privilege in Wordings.
301    #                        (e.g. "Administrator", "Operator", "ReadOnly").
302
303    ${random_user_id}  ${random_user_name}=  Create Random IPMI User
304    Set User Password  ${random_user_id}  ${new_user_passwd}  16
305    Set And Verify User Access Privilege  ${random_user_id}  ${user_privilege_level}
306    Verify Username And Password  ${random_user_name}  ${new_user_passwd}  L=${privilege}
307
308    [Return]  ${random_user_id}  ${random_user_name}
309
310
311Set User Password
312    [Documentation]  Set user password for given user ID.
313    [Arguments]  ${user_id}  ${password}  ${password_option}
314
315    # Description of argument(s):
316    # user_id          The user ID (e.g. "1", "2", etc.).
317    # password         The user password (e.g. "0penBmc", "0penBmc1", etc.).
318    # password_option  Password length option to be given in IPMI command (e.g. "16", "20").
319
320    Run IPMI Standard Command  user set password ${user_id} ${password} ${password_option}
321
322Set And Verify User Access Privilege
323    [Documentation]  Set User Access Privilege, enable and verify user for given user ID.
324    [Arguments]  ${user_id}  ${privilege_level}
325
326    # Description of argument(s):
327    # user_id           The user ID (e.g. "1", "2", etc.).
328    # privilege_level   User Privilege level in hex value.
329    #                   (e.g. 0x04-Administrator, 0x03-Operator, 0x02-Readonly).
330
331    Set Channel Access  ${_user_id}  ipmi=on privilege=${privilege_level}
332
333    # Delay added for user privilege to get set.
334    Sleep  5s
335
336    Enable IPMI User And Verify  ${user_id}
337
338
339Verify Username And Password
340    [Documentation]  Verify that newly created user is able to run IPMI command
341    ...  with given username and password.
342    [Arguments]  ${username}  ${password}  &{options}
343
344    # Description of argument(s):
345    # username    The user name (e.g. "root", "robert", etc.).
346    # password    The user password (e.g. "0penBmc", "0penBmc1", etc.).
347    # options     Additional ipmitool command options  (e.g "-L=Operator","-C=3").
348
349    Wait Until Keyword Succeeds  15 sec  5 sec  Run External IPMI Raw Command
350    ...  ${IPMI_RAW_CMD['Device GUID']['Get'][0]}  U=${username}  P=${password}  &{options}
351
352
353Verify Standard Payload
354    [Documentation]  Verify standard payload is disabled or enabled.
355    [Arguments]  ${user_id}  ${user_name}  ${standard_payload}=Enabled
356
357    # Description of argument(s):
358    # user_id            The user ID (e.g. "1", "2", etc.).
359    # username           The user name (e.g. "root", "robert", etc.).
360    # standard_payload   Enabled or Disabled.
361
362    # Verify the standard payload 1 (sol) is disabled.
363    ${get_user_access_payload}=  Get User Access Payload For Given Channel  ${user_id}
364    @{get_user_access_cmd_resp_list}=  Split String  ${get_user_access_payload}
365
366    Run Keyword If  '${standard_payload}' == 'Disabled'
367    ...  Should Be Equal  ${get_user_access_cmd_resp_list}[0]  00
368    ...  ELSE
369    ...  Should Be Equal  ${get_user_access_cmd_resp_list}[0]  02
370
371    Run Keyword If  '${standard_payload}' == 'Disabled'
372    ...  Verify Sol Activate Disabled  ${user_name}
373
374
375Verify Sol Activate Disabled
376    [Documentation]  Verify SOL activate IPMI command is not working.
377    [Arguments]  ${user_name}
378
379    # Description of argument(s):
380    # username    The user name (e.g. "root", "robert", etc.).
381
382    ${resp}=  Run External IPMI Standard Command
383    ...  sol activate  expected_rc=${1}  U=${username}  P=${new_user_passwd}
384
385    Should Contain  ${resp}  SOL payload disabled
386
387
388Set User Access Payload For Given User
389    [Documentation]  Set the user access payload on given user, channel and return response.
390    [Arguments]  ${user_id}  ${operation_mode}=Enable  ${oempayload_value}=0x00
391    ...          ${standard_payload_value}=0x02
392
393    # Description of argument(s):
394    # user_id                  The user ID (e.g. "1", "2", etc.).
395    # operation_mode          Enable or Disable payload type.
396    # oempayload_value        Oempayload in hex (e.g. "0x00", "0x01", "0x02", "0x04" etc).
397    # standard_payload_value  Standard payload type IPMI or SOL.
398    #                         (e.g.  0x01 - IPMI, 0x02- SOL).
399
400    # If operation mode is disable 2nd byte of raw command is 4${user_id}.
401    # (e.g) 2n byte will be 0x4a (if user_id is a).
402    # If operation mode is enable 2nd byte of raw command is 0${user_id}.
403    # (e.g.) 3rd byte will be 0x0a (if user_id is a).
404    # 0x02- standard payload for SOL, 0x01 standard payload for IPMI.
405    # 3rd byte represent standard payload enables 1 (SOL).
406    # 4th to 6th byte represent standard payload enables 2 and OEM payload 1 & 2 respectively.
407
408    ${operation_mode_value}=  Set Variable If  '${operation_mode}' == 'Enable'
409    ...  0  4
410    ${set_cmd}=  Catenate  ${IPMI_RAW_CMD['Payload']['Set_User_Access_Payload'][0]}
411    ...  ${CHANNEL_NUMBER} 0x${operation_mode_value}${user_id} ${standard_payload_value} 0x00 ${oempayload_value} 0x00
412
413    ${resp}=  Run IPMI Command  ${set_cmd}
414
415    [Return]  ${resp}
416
417
418Get Invalid User ID
419    [Documentation]  Get random invalid user ID using "channel getaccess" IPMI standard command.
420
421    # Python module:  get_user_info(userid, channel_number=1)
422    ${user_info}=  Get User Info  ${EMPTY}  ${CHANNEL_NUMBER}
423    ${user_info}=  Filter Struct  ${user_info}  [('user_name', None)]  invert=1
424    ${empty_user_info}=  Filter Struct  ${user_info}  [('user_name', '')]
425    @{invalid_userid_list}=  Create List
426    FOR  ${user_record}  IN  @{empty_user_info}
427        Append To List  ${invalid_userid_list}  ${user_record['user_id']}
428    END
429    ${invalid_user_id}=  Evaluate  random.choice(${invalid_userid_list})  random
430
431    [Return]  ${invalid_user_id}
432
433
434Verify Set User Access Payload For Invalid Channel
435    [Documentation]  Verify set user payload command for invalid channels.
436    [Arguments]  ${user_id}  ${channel_number}
437
438    # Description of argument(s):
439    # user_id           The user ID (e.g. "1", "2", etc.).
440    # channel_number    Input channel number.
441
442    ${channel_number}=  Convert To Hex  ${channel_number}  prefix=0x
443    ${user_id}=  Convert To Hex  ${user_id}  prefix=0x
444    ${raw_cmd}=  Catenate   ${IPMI_RAW_CMD['Payload']['Set_User_Access_Payload'][0]}
445    ...  ${channel_number} ${user_id} 0x02 0x00 0x00 0x00
446
447    Verify Invalid IPMI Command  ${raw_cmd}  0xcc
448
449
450Verify Get User Access Payload For Invalid User Or Channel
451    [Documentation]  Verify get user payload command for invalid userid or invalid channels.
452    [Arguments]  ${user_id}  ${channel_number}
453
454    # Description of argument(s):
455    # user_id           The user ID (e.g. "1", "2", etc.).
456    # channel_number    Input channel number.
457
458    ${channel_number}=  Convert To Hex  ${channel_number}  prefix=0x
459    ${user_id}=  Convert To Hex  ${user_id}  prefix=0x
460    ${raw_cmd}=  Catenate  ${IPMI_RAW_CMD['Payload']['Get_User_Access_Payload'][0]}
461    ...  ${channel_number} ${user_id}
462
463    Verify Invalid IPMI Command  ${raw_cmd}  0xcc
464
465
466Verify Payload Type Version
467    [Documentation]  Verify supported payload version.
468    [Arguments]  ${channel_number}  &{payload_type_dict}
469
470    # Description of argument(s):
471    # channel_number     Input channel number.
472    # payload_type_dict  Supported payload type in dictionary type.
473    #                    standard_payload_types and session_setup_payload_types which we use
474    #                    in this keyword are defined in variable section.
475
476    FOR  ${payload_type_name}  ${payload_type_number}  IN  &{payload_type_dict}
477        ${get_cmd}=  Catenate  ${IPMI_RAW_CMD['Payload']['Get_Channel_Payload_Version'][0]}
478        ...  ${channel_number} ${payload_type_number}
479
480        ${resp}=  Run External IPMI Raw Command  ${get_cmd}
481        ${resp}=  Strip String  ${resp}
482        Should Be Equal  ${resp}  10
483    END
484
485
486Verify Payload Version For Invalid Channel
487    [Documentation]  Verify payload version for invalid channel.
488    [Arguments]  ${channel_number}  &{payload_type_dict}
489
490    # Description of argument(s):
491    # channel_number     Input channel number.
492    # payload_type_dict  Supported payload type in dictionary type.
493    #                    standard_payload_types and session_setup_payload_types which we use
494    #                    in this keyword are defined in variable section.
495
496     ${channel_number}=  Convert To Hex  ${channel_number}  prefix=0x
497     FOR  ${payload_type_name}  ${payload_type_number}  IN  &{payload_type_dict}
498        ${get_cmd}=  Catenate  ${IPMI_RAW_CMD['Payload']['Get_Channel_Payload_Version'][0]}
499        ...  ${channel_number} ${payload_type_number}
500
501        Verify Invalid IPMI Command  ${get_cmd}  0xcc
502     END
503
504
505Verify Payload Version
506    [Documentation]  Verify supported payload version on given channel number.
507    [Arguments]  ${channel_number}
508
509    # Description of argument(s):
510    # channel_number     Input channel number.
511
512    Verify Payload Type Version  ${channel_number}  &{standard_payload_types}
513    Verify Payload Type Version  ${channel_number}  &{session_setup_payload_types}
514
515
516Verify Payload Support
517    [Documentation]  Verify payload support on given channel number.
518    [Arguments]  ${channel_number}  ${invalid_channel}=${0}
519
520    # Description of argument(s):
521    # channel_number     Input channel number.
522    # invalid_channel    This argument indicates whether we checking payload support command
523    #                    for Invalid channel or not.
524    #                    (e.g. 1 indicates checking for invalid channel, 0 indicates valid channel).
525
526    ${channel_number}=  Convert To Hex  ${channel_number}  prefix=0x
527    ${raw_cmd}=  Catenate  ${IPMI_RAW_CMD['Payload']['Get_Channel_Payload_Support'][0]}  ${channel_number}
528
529    Run Keyword And Return If  '${invalid_channel}' == '${1}'
530    ...  Verify Invalid IPMI Command  ${raw_cmd}  0xcc
531
532    # will be executed only if invalid_channel == 0.
533    ${resp}=  Run External IPMI Raw Command  ${raw_cmd}
534
535    ${resp}=  Strip String  ${resp}
536    ${expected_resp}=  Catenate  ${standard_payload_type_resp}  ${session_setup_payload_resp} 00 00 00 00
537    Should Be Equal  ${expected_resp}  ${resp}
538