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_Credentails 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 ${3600} ${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 58Verify SessionService Defaults 59 [Documentation] Verify SessionService default property values. 60 [Tags] Verify_SessionService_Defaults 61 62 ${session_service}= Redfish.Get Properties /redfish/v1/SessionService 63 Rprint Vars session_service 64 65 Valid Value session_service['@odata.id'] ['/redfish/v1/SessionService/'] 66 Valid Value session_service['Description'] ['Session Service'] 67 Valid Value session_service['Id'] ['SessionService'] 68 Valid Value session_service['Name'] ['Session Service'] 69 Valid Value session_service['ServiceEnabled'] [True] 70 Valid Value session_service['SessionTimeout'] [3600] 71 Valid Value session_service['Sessions']['@odata.id'] ['/redfish/v1/SessionService/Sessions'] 72 73 74Verify Sessions Defaults 75 [Documentation] Verify Sessions default property values. 76 [Tags] Verify_Sessions_Defaults 77 78 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions 79 Rprint Vars sessions 80 ${sessions_count}= Get length ${sessions['Members']} 81 82 Valid Value sessions['@odata.id'] ['/redfish/v1/SessionService/Sessions/'] 83 Valid Value sessions['Description'] ['Session Collection'] 84 Valid Value sessions['Name'] ['Session Collection'] 85 Valid Value sessions['Members@odata.count'] [${sessions_count}] 86 87 88Verify Current Session Defaults 89 [Documentation] Verify Current session default property values. 90 [Tags] Verify_Current_Session_Defaults 91 92 ${session_location}= Redfish.Get Session Location 93 ${session_id}= Evaluate os.path.basename($session_location) modules=os 94 ${session_properties}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id} 95 Rprint Vars session_location session_id session_properties 96 97 Valid Value session_properties['@odata.id'] ['/redfish/v1/SessionService/Sessions/${session_id}'] 98 Valid Value session_properties['Description'] ['Manager User Session'] 99 Valid Value session_properties['Name'] ['User Session'] 100 Valid Value session_properties['Id'] ['${session_id}'] 101 Valid Value session_properties['UserName'] ['${OPENBMC_USERNAME}'] 102 103 104Verify Managers Defaults 105 [Documentation] Verify managers defaults. 106 [Tags] Verify_Managers_Defaults 107 108 ${managers}= Redfish.Get Properties /redfish/v1/Managers 109 Rprint Vars managers 110 ${managers_count}= Get Length ${managers['Members']} 111 112 Valid Value managers['Name'] ['Manager Collection'] 113 Valid Value managers['@odata.id'] ['/redfish/v1/Managers'] 114 Valid Value managers['Members@odata.count'] [${managers_count}] 115 116 # Members can be one or more, hence checking in the list. 117 Valid List managers['Members'] required_values=[{'@odata.id': '/redfish/v1/Managers/bmc'}] 118 119 120Verify Chassis Defaults 121 [Documentation] Verify chassis defaults. 122 [Tags] Verify_Chassis_Defaults 123 124 ${chassis}= Redfish.Get Properties /redfish/v1/Chassis 125 Rprint Vars chassis 126 ${chassis_count}= Get Length ${chassis['Members']} 127 128 Valid Value chassis['Name'] ['Chassis Collection'] 129 Valid Value chassis['@odata.id'] ['/redfish/v1/Chassis'] 130 Valid Value chassis['Members@odata.count'] [${chassis_count}] 131 Valid Value chassis['Members@odata.count'] [${chassis_count}] 132 133 # Members can be one or more, hence checking in the list. 134 Valid List chassis['Members'] 135 ... required_values=[{'@odata.id': '/redfish/v1/Chassis/${CHASSIS_ID}'}] 136 137 138Verify Systems Defaults 139 [Documentation] Verify systems defaults. 140 [Tags] Verify_Systems_Defaults 141 142 ${systems}= Redfish.Get Properties /redfish/v1/Systems 143 Rprint Vars systems 144 ${systems_count}= Get Length ${systems['Members']} 145 Valid Value systems['Name'] ['Computer System Collection'] 146 Valid Value systems['@odata.id'] ['/redfish/v1/Systems'] 147 Valid Value systems['Members@odata.count'] [${systems_count}] 148 Valid Value systems['Members@odata.count'] [${systems_count}] 149 # Members can be one or more, hence checking in the list. 150 Valid List systems['Members'] required_values=[{'@odata.id': '/redfish/v1/Systems/system'}] 151 152 153Verify Session Persistency After BMC Reboot 154 [Documentation] Verify session persistency after BMC reboot. 155 [Tags] Verify_Session_Persistency_After_BMC_Reboot 156 157 # Note the current session location. 158 ${session_location}= Redfish.Get Session Location 159 160 Redfish OBMC Reboot (off) stack_mode=normal 161 Redfish.Login 162 163 # Check for session persistency after BMC reboot. 164 # sessions here will have list of all sessions location. 165 ${sessions}= Redfish.Get Attribute /redfish/v1/SessionService/Sessions Members 166 ${payload}= Create Dictionary @odata.id=${session_location} 167 168 List Should Contain Value ${sessions} ${payload} 169 170 171REST Logging Interface Read Should Be A SUCCESS For Authorized Users 172 [Documentation] REST logging interface read should be a success for authorized users. 173 [Tags] REST_Logging_Interface_Read_Should_Be_A_SUCCESS_For_Authorized_Users 174 175 ${resp}= Redfish.Get /xyz/openbmc_project/logging 176 177 ${resp_output}= evaluate json.loads('''${resp.text}''') json 178 ${log_count}= Get Length ${resp_output["data"]} 179 180 # Max 200 error logs are allowed in OpenBmc. 181 Run Keyword Unless ${-1} < ${log_count} < ${201} Fail 182 183 184*** Keywords *** 185 186Create Session And Verify Response Code 187 [Documentation] Create session and verify response code. 188 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD} 189 ... ${valid_status_code}=${HTTP_CREATED} 190 191 # Description of argument(s): 192 # username The username to create a session. 193 # password The password to create a session. 194 # valid_status_code Expected response code, default is ${HTTP_CREATED}. 195 196 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions 197 ... body={'UserName':'${username}', 'Password': '${password}'} 198 ... valid_status_codes=[${valid_status_code}] 199 200 201Set Session Timeout And Verify 202 [Documentation] Set Session Timeout And Verify. 203 [Arguments] ${value}=3600 ${valid_status_code}=${HTTP_OK} 204 205 # Description of argument(s): 206 # value The value to patch session timeout. 207 # valid_status_code Expected response code, default is ${HTTP_OK}. 208 209 ${data}= Create Dictionary SessionTimeout=${value} 210 Redfish.Patch ${REDFISH_BASE_URI}SessionService 211 ... body=&{data} 212 ... valid_status_codes=[${valid_status_code}] 213 214 ${session_timeout}= Redfish.Get Attribute 215 ... ${REDFISH_BASE_URI}SessionService SessionTimeout 216 217 Run Keyword If ${valid_status_code}==${HTTP_OK} 218 ... Valid Value session_timeout [${value}] 219 220 221Suite Setup Execution 222 [Documentation] Suite Setup Execution. 223 224 Redfish.Login 225 Create Users With Different Roles users=${USERS} force=${True} 226 227 228Suite Teardown Execution 229 [Documentation] Suite teardown execution. 230 231 Delete BMC Users Via Redfish users=${USERS} 232 Redfish.Logout 233