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