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