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