Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 1 | *** Settings *** |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 2 | |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 3 | Documentation Test Redfish SessionService. |
| 4 | |
| 5 | Resource ../../lib/resource.robot |
| 6 | Resource ../../lib/bmc_redfish_resource.robot |
Vijay | ff2c0bc | 2020-02-03 00:05:45 -0600 | [diff] [blame] | 7 | Resource ../../lib/bmc_redfish_utils.robot |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 8 | Resource ../../lib/openbmc_ffdc.robot |
| 9 | |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 10 | Suite Setup Suite Setup Execution |
Vijay | 3937315 | 2020-02-14 08:08:20 -0600 | [diff] [blame] | 11 | Suite Teardown Suite Teardown Execution |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 12 | Test Setup Printn |
| 13 | Test Teardown FFDC On Test Case Fail |
| 14 | |
Vijay | 3937315 | 2020-02-14 08:08:20 -0600 | [diff] [blame] | 15 | |
Vijay | ff2c0bc | 2020-02-03 00:05:45 -0600 | [diff] [blame] | 16 | *** Variables *** |
Vijay | 3937315 | 2020-02-14 08:08:20 -0600 | [diff] [blame] | 17 | |
Vijay | ff2c0bc | 2020-02-03 00:05:45 -0600 | [diff] [blame] | 18 | @{ADMIN} admin_user TestPwd123 |
| 19 | @{OPERATOR} operator_user TestPwd123 |
Rahul Maheshwari | b075397 | 2022-08-29 05:04:47 -0500 | [diff] [blame] | 20 | # User-driven input parameter to skip operator user. |
| 21 | # -v SKIP_OPERATOR_USER:1 to skip from CLI. |
| 22 | ${SKIP_OPERATOR_USER} ${0} |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 23 | |
Vijay | 3937315 | 2020-02-14 08:08:20 -0600 | [diff] [blame] | 24 | |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 25 | *** Test Cases *** |
| 26 | |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 27 | Create Session And Verify Response Code Using Different Credentials |
| 28 | [Documentation] Create session and verify response code using different credentials. |
George Keishing | 0c8100f | 2022-01-13 00:24:57 -0600 | [diff] [blame] | 29 | [Tags] Create_Session_And_Verify_Response_Code_Using_Different_Credentials |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 30 | [Template] Create Session And Verify Response Code |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 31 | |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 32 | # username password valid_status_code |
| 33 | ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${HTTP_CREATED} |
Vijay | ff2c0bc | 2020-02-03 00:05:45 -0600 | [diff] [blame] | 34 | r00t ${OPENBMC_PASSWORD} ${HTTP_UNAUTHORIZED} |
| 35 | ${OPENBMC_USERNAME} password ${HTTP_UNAUTHORIZED} |
| 36 | r00t password ${HTTP_UNAUTHORIZED} |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 37 | admin_user TestPwd123 ${HTTP_CREATED} |
Rahul Maheshwari | bb79b9d | 2022-11-11 05:48:36 -0600 | [diff] [blame] | 38 | |
| 39 | |
| 40 | Create 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 |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 46 | operator_user TestPwd123 ${HTTP_CREATED} |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 47 | |
| 48 | |
David Wang | d511f5d | 2021-02-26 16:19:20 +0800 | [diff] [blame] | 49 | Set 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 |
nagarjunb22 | 917d2e3 | 2022-04-20 09:57:29 +0530 | [diff] [blame] | 53 | [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK} |
David Wang | d511f5d | 2021-02-26 16:19:20 +0800 | [diff] [blame] | 54 | |
George Keishing | 9614383 | 2021-03-23 07:55:08 -0500 | [diff] [blame] | 55 | # The minimum & maximum allowed values for session timeout are 30 |
David Wang | d511f5d | 2021-02-26 16:19:20 +0800 | [diff] [blame] | 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 | |
nagarjunb22 | 917d2e3 | 2022-04-20 09:57:29 +0530 | [diff] [blame] | 68 | Set 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 | |
| 79 | Verify 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 | |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 94 | Verify 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 | |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 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] |
nagarjunb22 | 917d2e3 | 2022-04-20 09:57:29 +0530 | [diff] [blame] | 106 | Valid Value session_service['SessionTimeout'] [${Default_Timeout_Value}] |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 107 | Valid Value session_service['Sessions']['@odata.id'] ['/redfish/v1/SessionService/Sessions'] |
| 108 | |
| 109 | |
| 110 | Verify 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 | |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 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 | |
| 124 | Verify 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 | |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 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}'] |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 138 | |
| 139 | |
| 140 | Verify 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 | |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 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 | |
Vijay | ff2c0bc | 2020-02-03 00:05:45 -0600 | [diff] [blame] | 152 | # Members can be one or more, hence checking in the list. |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 153 | Valid List managers['Members'] required_values=[{'@odata.id': '/redfish/v1/Managers/bmc'}] |
| 154 | |
| 155 | |
| 156 | Verify 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 | |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 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 | |
Vijay | ff2c0bc | 2020-02-03 00:05:45 -0600 | [diff] [blame] | 169 | # Members can be one or more, hence checking in the list. |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 170 | Valid List chassis['Members'] |
Tony Lee | 2b97582 | 2021-04-01 11:15:00 +0800 | [diff] [blame] | 171 | ... required_values=[{'@odata.id': '/redfish/v1/Chassis/${CHASSIS_ID}'}] |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 172 | |
| 173 | |
| 174 | Verify 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']} |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 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}] |
Vijay | ff2c0bc | 2020-02-03 00:05:45 -0600 | [diff] [blame] | 185 | # Members can be one or more, hence checking in the list. |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 186 | Valid List systems['Members'] required_values=[{'@odata.id': '/redfish/v1/Systems/system'}] |
| 187 | |
| 188 | |
| 189 | Verify Session Persistency After BMC Reboot |
| 190 | [Documentation] Verify session persistency after BMC reboot. |
| 191 | [Tags] Verify_Session_Persistency_After_BMC_Reboot |
| 192 | |
Vijay | ff2c0bc | 2020-02-03 00:05:45 -0600 | [diff] [blame] | 193 | # Note the current session location. |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 194 | ${session_location}= Redfish.Get Session Location |
| 195 | |
| 196 | Redfish OBMC Reboot (off) stack_mode=normal |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 197 | |
Vijay | ff2c0bc | 2020-02-03 00:05:45 -0600 | [diff] [blame] | 198 | # Check for session persistency after BMC reboot. |
| 199 | # sessions here will have list of all sessions location. |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 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 | |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 205 | *** Keywords *** |
| 206 | |
| 207 | Create 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. |
Vijay | ff2c0bc | 2020-02-03 00:05:45 -0600 | [diff] [blame] | 215 | # valid_status_code Expected response code, default is ${HTTP_CREATED}. |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 216 | |
| 217 | ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions |
| 218 | ... body={'UserName':'${username}', 'Password': '${password}'} |
| 219 | ... valid_status_codes=[${valid_status_code}] |
| 220 | |
| 221 | |
David Wang | d511f5d | 2021-02-26 16:19:20 +0800 | [diff] [blame] | 222 | Set 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 | |
nagarjunb22 | 917d2e3 | 2022-04-20 09:57:29 +0530 | [diff] [blame] | 230 | Redfish.Login |
David Wang | d511f5d | 2021-02-26 16:19:20 +0800 | [diff] [blame] | 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 | |
nagarjunb22 | 917d2e3 | 2022-04-20 09:57:29 +0530 | [diff] [blame] | 243 | Create 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 | |
| 264 | Set 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 | |
| 277 | Get 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 | |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 284 | Suite Setup Execution |
| 285 | [Documentation] Suite Setup Execution. |
| 286 | |
| 287 | Redfish.Login |
Rahul Maheshwari | b075397 | 2022-08-29 05:04:47 -0500 | [diff] [blame] | 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 | |
Vijay | ff2c0bc | 2020-02-03 00:05:45 -0600 | [diff] [blame] | 296 | Create Users With Different Roles users=${USERS} force=${True} |
nagarjunb22 | 917d2e3 | 2022-04-20 09:57:29 +0530 | [diff] [blame] | 297 | Get Default Timeout Value |
Vijay | 3937315 | 2020-02-14 08:08:20 -0600 | [diff] [blame] | 298 | |
| 299 | |
| 300 | Suite Teardown Execution |
| 301 | [Documentation] Suite teardown execution. |
| 302 | |
| 303 | Delete BMC Users Via Redfish users=${USERS} |
nagarjunb22 | 917d2e3 | 2022-04-20 09:57:29 +0530 | [diff] [blame] | 304 | Run Keyword And Ignore Error Delete All Redfish Sessions |
Vijay | 3937315 | 2020-02-14 08:08:20 -0600 | [diff] [blame] | 305 | Redfish.Logout |