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 8Library ../lib/ipmi_utils.py 9 10Test Setup Test Setup Execution 11Test Teardown Test Teardown Execution 12 13 14*** Variables *** 15 16${valid_password} 0penBmc1 17${valid_password2} 0penBmc2 18${admin_level_priv} 4 19${operator_level_priv} 3 20 21** Test Cases ** 22 23Create Admin Redfish User And Verify Login Via IPMI 24 [Documentation] Create user using redfish and verify via IPMI. 25 [Tags] Create_Admin_Redfish_User_And_Verify_Login_Via_IPMI 26 27 ${random_username}= Generate Random String 8 [LETTERS] 28 Set Test Variable ${random_username} 29 30 ${payload}= Create Dictionary 31 ... UserName=${random_username} Password=${valid_password} 32 ... RoleId=Administrator Enabled=${True} 33 Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} 34 ... valid_status_codes=[${HTTP_CREATED}] 35 36 Verify IPMI Username And Password ${random_username} ${valid_password} 37 38 39Update User Password Via Redfish And Verify Using IPMI 40 [Documentation] Update user password via Redfish and verify using IPMI. 41 [Tags] Update_User_Password_Via_Redfish_And_Verify_Using_IPMI 42 43 # Create user using Redfish. 44 ${random_username}= Generate Random String 8 [LETTERS] 45 Set Test Variable ${random_username} 46 47 ${payload}= Create Dictionary 48 ... UserName=${random_username} Password=${valid_password} 49 ... RoleId=Administrator Enabled=${True} 50 Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} 51 ... valid_status_codes=[${HTTP_CREATED}] 52 53 # Update user password using Redfish. 54 ${payload}= Create Dictionary Password=${valid_password2} 55 Redfish.Patch /redfish/v1/AccountService/Accounts/${random_username} body=&{payload} 56 57 # Verify that IPMI command works with new password and fails with older password. 58 Verify IPMI Username And Password ${random_username} ${valid_password2} 59 60 Run Keyword And Expect Error Error: Unable to establish IPMI* 61 ... Verify IPMI Username And Password ${random_username} ${valid_password} 62 63 64Delete User Via Redfish And Verify Using IPMI 65 [Documentation] Delete user via redfish and verify using IPMI. 66 [Tags] Delete_User_Via_Redfish_And_Verify_Using_IPMI 67 68 # Create user using Redfish. 69 ${random_username}= Generate Random String 8 [LETTERS] 70 Set Test Variable ${random_username} 71 72 ${payload}= Create Dictionary 73 ... UserName=${random_username} Password=${valid_password} 74 ... RoleId=Administrator Enabled=${True} 75 Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} 76 ... valid_status_codes=[${HTTP_CREATED}] 77 78 # Delete user using Redfish. 79 Redfish.Delete /redfish/v1/AccountService/Accounts/${random_username} 80 81 # Verify that IPMI command fails with deleted user. 82 Run Keyword And Expect Error Error: Unable to establish IPMI* 83 ... Verify IPMI Username And Password ${random_username} ${valid_password} 84 85 86Create IPMI User And Verify Login Via Redfish 87 [Documentation] Create user using IPMI and verify user login via Redfish. 88 [Tags] Create_IPMI_User_And_Verify_Login_Via_Redfish 89 90 ${username} ${userid}= IPMI Create Random User Plus Password And Privilege 91 ... ${valid_password} ${admin_level_priv} 92 93 # Verify user login using Redfish. 94 Redfish.Login ${username} ${valid_password} 95 96 97Update User Password Via IPMI And Verify Using Redfish 98 [Documentation] Update user password using IPMI and verify user 99 ... login via Redfish. 100 [Tags] Update_User_Password_Via_IPMI_And_Verify_Using_Redfish 101 102 ${username} ${userid}= IPMI Create Random User Plus Password And Privilege 103 ... ${valid_password} ${admin_level_priv} 104 105 # Update user password using IPMI. 106 Run IPMI Standard Command 107 ... user set password ${userid} ${valid_password2} 108 109 # Verify that user login works with new password using Redfish. 110 Redfish.Login ${username} ${valid_password2} 111 112 113Update User Privilege Via IPMI And Verify Using Redfish 114 [Documentation] Update user privilege via IPMI and verify using Redfish. 115 [Tags] Update_User_Privilege_Via_IPMI_And_Verify_Using_Redfish 116 117 # Create user using IPMI with admin privilege. 118 ${username} ${userid}= IPMI Create Random User Plus Password And Privilege 119 ... ${valid_password} ${admin_level_priv} 120 121 # Change user privilege to opetrator using IPMI. 122 Run IPMI Standard Command 123 ... user priv ${userid} ${operator_level_priv} 124 125 # Verify new user privilege level via Redfish. 126 ${privilege}= Redfish_Utils.Get Attribute 127 ... /redfish/v1/AccountService/Accounts/${username} RoleId 128 Should Be Equal ${privilege} Operator 129 130 131Delete User Via IPMI And Verify Using Redfish 132 [Documentation] Delete user using IPMI and verify error while doing 133 ... user login with deleted user via Redfish. 134 [Tags] Delete_User_Via_IPMI_And_Verify_Using_Redfish 135 136 ${username} ${userid}= IPMI Create Random User Plus Password And Privilege 137 ... ${valid_password} ${admin_level_priv} 138 139 # Delete IPMI User. 140 Run IPMI Standard Command user set name ${userid} "" 141 142 # Verify that Redfish login fails with deleted user. 143 Run Keyword And Expect Error *InvalidCredentialsError* 144 ... Redfish.Login ${username} ${valid_password} 145 146 147*** Keywords *** 148 149IPMI Create Random User Plus Password And Privilege 150 [Documentation] Create random IPMI user with given password and privilege 151 ... level. 152 [Arguments] ${password} ${privilege} 153 154 # Description of argument(s): 155 # password Password to be assigned for the user. 156 # privilege Privilege level for the user (e.g. "1", "2", "3", etc.). 157 158 # Create IPMI user. 159 ${random_username}= Generate Random String 8 [LETTERS] 160 Set Suite Variable ${random_username} 161 162 ${random_userid}= Evaluate random.randint(2, 15) modules=random 163 IPMI Create User ${random_userid} ${random_username} 164 165 # Set given password for newly created user. 166 Run IPMI Standard Command 167 ... user set password ${random_userid} ${password} 168 169 # Enable IPMI user. 170 Run IPMI Standard Command user enable ${random_userid} 171 172 # Set given privilege and enable IPMI messaging for newly created user. 173 Set Channel Access ${random_userid} ipmi=on privilege=${privilege} 174 175 [Return] ${random_username} ${random_userid} 176 177 178Test Setup Execution 179 [Documentation] Do test case setup tasks. 180 181 Redfish.Login 182 183 184Test Teardown Execution 185 [Documentation] Do the post test teardown. 186 187 FFDC On Test Case Fail 188 # Delete the test user. 189 Run Keyword And Ignore Error 190 ... Redfish.Delete /redfish/v1/AccountService/Accounts/${random_username} 191 192 Redfish.Logout 193