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