1*** Settings ***
2Documentation    Test IPMI and Redfish combinations for user management.
3
4Resource         ../../lib/resource.robot
5Resource         ../../lib/bmc_redfish_resource.robot
6Resource         ../../lib/openbmc_ffdc.robot
7Resource         ../../lib/ipmi_client.robot
8
9Test Setup       Test Setup Execution
10Test Teardown    Test Teardown Execution
11
12
13*** Variables ***
14
15${valid_password}       0penBmc1
16${valid_password2}      0penBmc2
17
18** Test Cases **
19
20Create Admin Redfish User And Verify Login Via IPMI
21    [Documentation]  Create user using redfish and verify via IPMI.
22    [Tags]  Create_Admin_Redfish_User_And_Verify_Login_Via_IPMI
23
24    ${random_username}=  Generate Random String  8  [LETTERS]
25    Set Test Variable  ${random_username}
26
27    ${payload}=  Create Dictionary
28    ...  UserName=${random_username}  Password=${valid_password}
29    ...  RoleId=Administrator  Enabled=${True}
30    Redfish.Post  /redfish/v1/AccountService/Accounts  body=&{payload}
31    ...  valid_status_codes=[${HTTP_CREATED}]
32
33    Verify IPMI Username And Password  ${random_username}  ${valid_password}
34
35
36Update User Password Via Redfish And Verify Using IPMI
37    [Documentation]  Update user password via Redfish and verify using IPMI.
38    [Tags]  Update_User_Password_Via_Redfish_And_Verify_Using_IPMI
39
40    # Create user using Redfish.
41    ${random_username}=  Generate Random String  8  [LETTERS]
42    Set Test Variable  ${random_username}
43
44    ${payload}=  Create Dictionary
45    ...  UserName=${random_username}  Password=${valid_password}
46    ...  RoleId=Administrator  Enabled=${True}
47    Redfish.Post  /redfish/v1/AccountService/Accounts  body=&{payload}
48    ...  valid_status_codes=[${HTTP_CREATED}]
49
50    # Update user password using Redfish.
51    ${payload}=  Create Dictionary  Password=${valid_password2}
52    Redfish.Patch  /redfish/v1/AccountService/Accounts/${random_username}  body=&{payload}
53
54    # Verify that IPMI command works with new password and fails with older password.
55    Verify IPMI Username And Password  ${random_username}  ${valid_password2}
56
57    Run Keyword And Expect Error  Error: Unable to establish IPMI*
58    ...  Verify IPMI Username And Password  ${random_username}  ${valid_password}
59
60
61Delete User Via Redfish And Verify Using IPMI
62    [Documentation]  Delete user via redfish and verify using IPMI.
63    [Tags]  Delete_User_Via_Redfish_And_Verify_Using_IPMI
64
65    # Create user using Redfish.
66    ${random_username}=  Generate Random String  8  [LETTERS]
67    Set Test Variable  ${random_username}
68
69    ${payload}=  Create Dictionary
70    ...  UserName=${random_username}  Password=${valid_password}
71    ...  RoleId=Administrator  Enabled=${True}
72    Redfish.Post  /redfish/v1/AccountService/Accounts  body=&{payload}
73    ...  valid_status_codes=[${HTTP_CREATED}]
74
75    # Delete user using Redfish.
76    Redfish.Delete  /redfish/v1/AccountService/Accounts/${random_username}
77
78    # Verify that IPMI command fails with deleted user.
79    Run Keyword And Expect Error  Error: Unable to establish IPMI*
80    ...  Verify IPMI Username And Password  ${random_username}  ${valid_password}
81
82
83*** Keywords ***
84
85Test Setup Execution
86    [Documentation]  Do test case setup tasks.
87
88    Redfish.Login
89
90
91Test Teardown Execution
92    [Documentation]  Do the post test teardown.
93
94    FFDC On Test Case Fail
95    # Delete the test user.
96    Run Keyword And Ignore Error
97    ...  Redfish.Delete  /redfish/v1/AccountService/Accounts/${random_username}
98
99    Redfish.Logout
100