1*** Settings *** 2 3Documentation Test Redfish SessionService. 4 5Resource ../../lib/resource.robot 6Resource ../../lib/bmc_redfish_resource.robot 7Resource ../../lib/bmc_redfish_utils.robot 8Resource ../../lib/openbmc_ffdc.robot 9 10Suite Setup Suite Setup Execution 11Suite Teardown Suite Teardown Execution 12Test Setup Printn 13Test Teardown FFDC On Test Case Fail 14 15 16*** Variables *** 17 18@{ADMIN} admin_user TestPwd123 19@{OPERATOR} operator_user TestPwd123 20# User-driven input parameter to skip operator user. 21# -v SKIP_OPERATOR_USER:1 to skip from CLI. 22${SKIP_OPERATOR_USER} ${0} 23 24 25*** Test Cases *** 26 27Create Session And Verify Response Code Using Different Credentials 28 [Documentation] Create session and verify response code using different credentials. 29 [Tags] Create_Session_And_Verify_Response_Code_Using_Different_Credentials 30 [Template] Create Session And Verify Response Code 31 32 # username password valid_status_code 33 ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${HTTP_CREATED} 34 r00t ${OPENBMC_PASSWORD} ${HTTP_UNAUTHORIZED} 35 ${OPENBMC_USERNAME} password ${HTTP_UNAUTHORIZED} 36 r00t password ${HTTP_UNAUTHORIZED} 37 admin_user TestPwd123 ${HTTP_CREATED} 38 39 40Create Session And Verify Response Code Using Operator Credentials 41 [Documentation] Create session and verify response code using operator credentials. 42 [Tags] Create_Session_And_Verify_Response_Code_Using_Operator_Credentials 43 [Template] Create Session And Verify Response Code 44 45 # username password valid_status_code 46 operator_user TestPwd123 ${HTTP_CREATED} 47 48 49Set Session Timeout And Verify Response Code 50 [Documentation] Set Session Timeout And Verify Response Code. 51 [Tags] Set_Session_Timeout_And_Verify_Response_Code 52 [Template] Set Session Timeout And Verify 53 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK} 54 55 # The minimum & maximum allowed values for session timeout are 30 56 # seconds and 86400 seconds respectively as per the session service 57 # schema mentioned at 58 # https://redfish.dmtf.org/schemas/v1/SessionService.v1_1_7.json 59 60 # value valid_status_code 61 ${25} ${HTTP_BAD_REQUEST} 62 ${30} ${HTTP_OK} 63 ${3600} ${HTTP_OK} 64 ${86400} ${HTTP_OK} 65 ${86500} ${HTTP_BAD_REQUEST} 66 67 68Set Session Timeout And Verify Session After Timeout 69 [Documentation] Set timeout for session service and verify session is deleted after timeout. 70 [Tags] Set_Session_Timeout_And_Verify_Session_After_Timeout 71 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK} 72 [Template] Set Session Timeout And Verify Session Deleted After Timeout 73 74 #timeout Value 75 ${30} 76 ${300} 77 78 79Verify Session Login And Logout For Newly Created User 80 [Documentation] Verify able to login and logout using the session created for new user. 81 [Tags] Verify_Session_Login_And_Logout_For_Newly_Created_User 82 [Teardown] Redfish.Login 83 84 # Logout already created redfish session. 85 Redfish.Logout 86 Redfish.Login ${ADMIN}[0] ${ADMIN}[1] 87 ${systems}= Redfish.Get Properties /redfish/v1/Systems 88 Rprint Vars systems 89 Redfish.Logout 90 ${systems}= Redfish.Get /redfish/v1/Systems 91 ... valid_status_codes=[${HTTP_UNAUTHORIZED}] 92 93 94Verify SessionService Defaults 95 [Documentation] Verify SessionService default property values. 96 [Tags] Verify_SessionService_Defaults 97 98 ${session_service}= Redfish.Get Properties /redfish/v1/SessionService 99 Rprint Vars session_service 100 101 Valid Value session_service['@odata.id'] ['/redfish/v1/SessionService/'] 102 Valid Value session_service['Description'] ['Session Service'] 103 Valid Value session_service['Id'] ['SessionService'] 104 Valid Value session_service['Name'] ['Session Service'] 105 Valid Value session_service['ServiceEnabled'] [True] 106 Valid Value session_service['SessionTimeout'] [${Default_Timeout_Value}] 107 Valid Value session_service['Sessions']['@odata.id'] ['/redfish/v1/SessionService/Sessions'] 108 109 110Verify Sessions Defaults 111 [Documentation] Verify Sessions default property values. 112 [Tags] Verify_Sessions_Defaults 113 114 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions 115 Rprint Vars sessions 116 ${sessions_count}= Get length ${sessions['Members']} 117 118 Valid Value sessions['@odata.id'] ['/redfish/v1/SessionService/Sessions/'] 119 Valid Value sessions['Description'] ['Session Collection'] 120 Valid Value sessions['Name'] ['Session Collection'] 121 Valid Value sessions['Members@odata.count'] [${sessions_count}] 122 123 124Verify Current Session Defaults 125 [Documentation] Verify Current session default property values. 126 [Tags] Verify_Current_Session_Defaults 127 128 ${session_location}= Redfish.Get Session Location 129 ${session_id}= Evaluate os.path.basename($session_location) modules=os 130 ${session_properties}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id} 131 Rprint Vars session_location session_id session_properties 132 133 Valid Value session_properties['@odata.id'] ['/redfish/v1/SessionService/Sessions/${session_id}'] 134 Valid Value session_properties['Description'] ['Manager User Session'] 135 Valid Value session_properties['Name'] ['User Session'] 136 Valid Value session_properties['Id'] ['${session_id}'] 137 Valid Value session_properties['UserName'] ['${OPENBMC_USERNAME}'] 138 139 140Verify Managers Defaults 141 [Documentation] Verify managers defaults. 142 [Tags] Verify_Managers_Defaults 143 144 ${managers}= Redfish.Get Properties /redfish/v1/Managers 145 Rprint Vars managers 146 ${managers_count}= Get Length ${managers['Members']} 147 148 Valid Value managers['Name'] ['Manager Collection'] 149 Valid Value managers['@odata.id'] ['/redfish/v1/Managers'] 150 Valid Value managers['Members@odata.count'] [${managers_count}] 151 152 # Members can be one or more, hence checking in the list. 153 Valid List managers['Members'] required_values=[{'@odata.id': '/redfish/v1/Managers/bmc'}] 154 155 156Verify Chassis Defaults 157 [Documentation] Verify chassis defaults. 158 [Tags] Verify_Chassis_Defaults 159 160 ${chassis}= Redfish.Get Properties /redfish/v1/Chassis 161 Rprint Vars chassis 162 ${chassis_count}= Get Length ${chassis['Members']} 163 164 Valid Value chassis['Name'] ['Chassis Collection'] 165 Valid Value chassis['@odata.id'] ['/redfish/v1/Chassis'] 166 Valid Value chassis['Members@odata.count'] [${chassis_count}] 167 Valid Value chassis['Members@odata.count'] [${chassis_count}] 168 169 # Members can be one or more, hence checking in the list. 170 Valid List chassis['Members'] 171 ... required_values=[{'@odata.id': '/redfish/v1/Chassis/${CHASSIS_ID}'}] 172 173 174Verify Systems Defaults 175 [Documentation] Verify systems defaults. 176 [Tags] Verify_Systems_Defaults 177 178 ${systems}= Redfish.Get Properties /redfish/v1/Systems 179 Rprint Vars systems 180 ${systems_count}= Get Length ${systems['Members']} 181 Valid Value systems['Name'] ['Computer System Collection'] 182 Valid Value systems['@odata.id'] ['/redfish/v1/Systems'] 183 Valid Value systems['Members@odata.count'] [${systems_count}] 184 Valid Value systems['Members@odata.count'] [${systems_count}] 185 # Members can be one or more, hence checking in the list. 186 Valid List systems['Members'] required_values=[{'@odata.id': '/redfish/v1/Systems/system'}] 187 188 189Verify Session Persistency After BMC Reboot 190 [Documentation] Verify session persistency after BMC reboot. 191 [Tags] Verify_Session_Persistency_After_BMC_Reboot 192 193 # Note the current session location. 194 ${session_location}= Redfish.Get Session Location 195 196 Redfish OBMC Reboot (off) stack_mode=normal 197 198 # Check for session persistency after BMC reboot. 199 # sessions here will have list of all sessions location. 200 ${sessions}= Redfish.Get Attribute /redfish/v1/SessionService/Sessions Members 201 ${payload}= Create Dictionary @odata.id=${session_location} 202 203 List Should Contain Value ${sessions} ${payload} 204 205*** Keywords *** 206 207Create Session And Verify Response Code 208 [Documentation] Create session and verify response code. 209 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD} 210 ... ${valid_status_code}=${HTTP_CREATED} 211 212 # Description of argument(s): 213 # username The username to create a session. 214 # password The password to create a session. 215 # valid_status_code Expected response code, default is ${HTTP_CREATED}. 216 217 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions 218 ... body={'UserName':'${username}', 'Password': '${password}'} 219 ... valid_status_codes=[${valid_status_code}] 220 221 222Set Session Timeout And Verify 223 [Documentation] Set Session Timeout And Verify. 224 [Arguments] ${value}=3600 ${valid_status_code}=${HTTP_OK} 225 226 # Description of argument(s): 227 # value The value to patch session timeout. 228 # valid_status_code Expected response code, default is ${HTTP_OK}. 229 230 Redfish.Login 231 ${data}= Create Dictionary SessionTimeout=${value} 232 Redfish.Patch ${REDFISH_BASE_URI}SessionService 233 ... body=&{data} 234 ... valid_status_codes=[${valid_status_code}] 235 236 ${session_timeout}= Redfish.Get Attribute 237 ... ${REDFISH_BASE_URI}SessionService SessionTimeout 238 239 Run Keyword If ${valid_status_code}==${HTTP_OK} 240 ... Valid Value session_timeout [${value}] 241 242 243Create Session And Check Session Timeout 244 [Documentation] Create session and check session timeout. 245 [Arguments] ${value} 246 247 # Description of argument(s): 248 # value timeout value in integer to be configured. 249 250 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions 251 ... body={'UserName':'${OPENBMC_USERNAME}', 'Password': '${OPENBMC_PASSWORD}'} 252 ... valid_status_codes=[${HTTP_CREATED}] 253 ${session_id}= Set Variable ${resp.dict['@odata.id']} 254 Sleep ${value}s 255 256 Redfish.Get ${REDFISH_SESSION} valid_status_codes=[${HTTP_UNAUTHORIZED}] 257 # Since sessions will deleted so logging again. 258 Redfish.login 259 ${session_list}= Redfish.Get Members List /redfish/v1/SessionService/Sessions 260 261 List Should Not Contain Value ${session_list} ${session_id} 262 263 264Set Session Timeout And Verify Session Deleted After Timeout 265 [Documentation] Set timeout for session service and verify session is deleted after timeout. 266 [Arguments] ${timeout_value} 267 268 # Description of argument(s): 269 # timeout_value timeout value in integer to be configured. 270 271 ${data}= Create Dictionary SessionTimeout=${timeout_value} 272 ${resp_patch}= Redfish.Patch /redfish/v1/SessionService 273 ... body=&{data} valid_status_codes=[${HTTP_OK}] 274 Create Session And Check Session Timeout ${timeout_value} 275 276 277Get Default Timeout Value 278 [Documentation] Get default session timeout value and set as a suite variable. 279 280 ${Default_Timeout_Value}= Redfish.Get Attribute /redfish/v1/SessionService SessionTimeout 281 Set Suite Variable ${Default_Timeout_Value} 282 283 284Suite Setup Execution 285 [Documentation] Suite Setup Execution. 286 287 Redfish.Login 288 289 # Skip operator user if SKIP_OPERATOR_USER is 1. 290 Run Keyword If 291 ... ${SKIP_OPERATOR_USER} == ${1} 292 ... Set Suite Variable &{USERS} Administrator=${ADMIN} 293 ... ELSE 294 ... Set Suite Variable &{USERS} Administrator=${ADMIN} Operator=${OPERATOR} 295 296 Create Users With Different Roles users=${USERS} force=${True} 297 Get Default Timeout Value 298 299 300Suite Teardown Execution 301 [Documentation] Suite teardown execution. 302 303 Delete BMC Users Via Redfish users=${USERS} 304 Run Keyword And Ignore Error Delete All Redfish Sessions 305 Redfish.Logout 306