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