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 162 # Check for session persistency after BMC reboot. 163 # sessions here will have list of all sessions location. 164 ${sessions}= Redfish.Get Attribute /redfish/v1/SessionService/Sessions Members 165 ${payload}= Create Dictionary @odata.id=${session_location} 166 167 List Should Contain Value ${sessions} ${payload} 168 169*** Keywords *** 170 171Create Session And Verify Response Code 172 [Documentation] Create session and verify response code. 173 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD} 174 ... ${valid_status_code}=${HTTP_CREATED} 175 176 # Description of argument(s): 177 # username The username to create a session. 178 # password The password to create a session. 179 # valid_status_code Expected response code, default is ${HTTP_CREATED}. 180 181 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions 182 ... body={'UserName':'${username}', 'Password': '${password}'} 183 ... valid_status_codes=[${valid_status_code}] 184 185 186Set Session Timeout And Verify 187 [Documentation] Set Session Timeout And Verify. 188 [Arguments] ${value}=3600 ${valid_status_code}=${HTTP_OK} 189 190 # Description of argument(s): 191 # value The value to patch session timeout. 192 # valid_status_code Expected response code, default is ${HTTP_OK}. 193 194 ${data}= Create Dictionary SessionTimeout=${value} 195 Redfish.Patch ${REDFISH_BASE_URI}SessionService 196 ... body=&{data} 197 ... valid_status_codes=[${valid_status_code}] 198 199 ${session_timeout}= Redfish.Get Attribute 200 ... ${REDFISH_BASE_URI}SessionService SessionTimeout 201 202 Run Keyword If ${valid_status_code}==${HTTP_OK} 203 ... Valid Value session_timeout [${value}] 204 205 206Suite Setup Execution 207 [Documentation] Suite Setup Execution. 208 209 Redfish.Login 210 Create Users With Different Roles users=${USERS} force=${True} 211 212 213Suite Teardown Execution 214 [Documentation] Suite teardown execution. 215 216 Delete BMC Users Via Redfish users=${USERS} 217 Redfish.Logout 218