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 |
| 7 | Resource ../../lib/openbmc_ffdc.robot |
| 8 | |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 9 | Suite Setup Suite Setup Execution |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 10 | Suite Teardown Redfish.Logout |
| 11 | Test Setup Printn |
| 12 | Test Teardown FFDC On Test Case Fail |
| 13 | |
| 14 | |
| 15 | *** Test Cases *** |
| 16 | |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 17 | Create Session And Verify Response Code Using Different Credentials |
| 18 | [Documentation] Create session and verify response code using different credentials. |
| 19 | [Tags] Create_Session_And_Verify_Response_Code_Using_Different_Credentails |
| 20 | [Template] Create Session And Verify Response Code |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 21 | |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 22 | # username password valid_status_code |
| 23 | ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${HTTP_CREATED} |
| 24 | r00t ${OPENBMC_PASSWORD} ${HTTP_FORBIDDEN} |
| 25 | ${OPENBMC_USERNAME} password ${HTTP_FORBIDDEN} |
| 26 | r00t password ${HTTP_FORBIDDEN} |
| 27 | admin_user TestPwd123 ${HTTP_CREATED} |
| 28 | operator_user TestPwd123 ${HTTP_CREATED} |
Vijay | 53a0055 | 2020-01-08 04:24:47 -0600 | [diff] [blame] | 29 | |
| 30 | |
| 31 | Verify SessionService Defaults |
| 32 | [Documentation] Verify SessionService default property values. |
| 33 | [Tags] Verify_SessionService_Defaults |
| 34 | |
| 35 | ${session_service}= Redfish.Get Properties /redfish/v1/SessionService |
| 36 | Rprint Vars session_service |
| 37 | |
| 38 | Valid Value session_service['@odata.context'] ['/redfish/v1/$metadata#SessionService.SessionService'] |
| 39 | Valid Value session_service['@odata.id'] ['/redfish/v1/SessionService/'] |
| 40 | Valid Value session_service['Description'] ['Session Service'] |
| 41 | Valid Value session_service['Id'] ['SessionService'] |
| 42 | Valid Value session_service['Name'] ['Session Service'] |
| 43 | Valid Value session_service['ServiceEnabled'] [True] |
| 44 | Valid Value session_service['SessionTimeout'] [3600] |
| 45 | Valid Value session_service['Sessions']['@odata.id'] ['/redfish/v1/SessionService/Sessions'] |
| 46 | |
| 47 | |
| 48 | Verify Sessions Defaults |
| 49 | [Documentation] Verify Sessions default property values. |
| 50 | [Tags] Verify_Sessions_Defaults |
| 51 | |
| 52 | ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions |
| 53 | Rprint Vars sessions |
| 54 | ${sessions_count}= Get length ${sessions['Members']} |
| 55 | |
| 56 | Valid Value sessions['@odata.context'] ['/redfish/v1/$metadata#SessionCollection.SessionCollection'] |
| 57 | Valid Value sessions['@odata.id'] ['/redfish/v1/SessionService/Sessions/'] |
| 58 | Valid Value sessions['Description'] ['Session Collection'] |
| 59 | Valid Value sessions['Name'] ['Session Collection'] |
| 60 | Valid Value sessions['Members@odata.count'] [${sessions_count}] |
| 61 | |
| 62 | |
| 63 | Verify Current Session Defaults |
| 64 | [Documentation] Verify Current session default property values. |
| 65 | [Tags] Verify_Current_Session_Defaults |
| 66 | |
| 67 | ${session_location}= Redfish.Get Session Location |
| 68 | ${session_id}= Evaluate os.path.basename($session_location) modules=os |
| 69 | ${session_properties}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id} |
| 70 | Rprint Vars session_location session_id session_properties |
| 71 | |
| 72 | Valid Value session_properties['@odata.context'] ['/redfish/v1/$metadata#Session.Session'] |
| 73 | Valid Value session_properties['@odata.id'] ['/redfish/v1/SessionService/Sessions/${session_id}'] |
| 74 | Valid Value session_properties['Description'] ['Manager User Session'] |
| 75 | Valid Value session_properties['Name'] ['User Session'] |
| 76 | Valid Value session_properties['Id'] ['${session_id}'] |
| 77 | Valid Value session_properties['UserName'] ['${OPENBMC_USERNAME}'] |
Vijay | 5b2f779 | 2020-01-14 04:18:32 -0600 | [diff] [blame] | 78 | |
| 79 | |
| 80 | Verify Managers Defaults |
| 81 | [Documentation] Verify managers defaults. |
| 82 | [Tags] Verify_Managers_Defaults |
| 83 | |
| 84 | ${managers}= Redfish.Get Properties /redfish/v1/Managers |
| 85 | Rprint Vars managers |
| 86 | ${managers_count}= Get Length ${managers['Members']} |
| 87 | |
| 88 | Valid Value managers['@odata.context'] ['/redfish/v1/$metadata#ManagerCollection.ManagerCollection'] |
| 89 | Valid Value managers['Name'] ['Manager Collection'] |
| 90 | Valid Value managers['@odata.id'] ['/redfish/v1/Managers'] |
| 91 | Valid Value managers['Members@odata.count'] [${managers_count}] |
| 92 | |
| 93 | # Members can be one or more, hence checking in the list |
| 94 | Valid List managers['Members'] required_values=[{'@odata.id': '/redfish/v1/Managers/bmc'}] |
| 95 | |
| 96 | |
| 97 | Verify Chassis Defaults |
| 98 | [Documentation] Verify chassis defaults. |
| 99 | [Tags] Verify_Chassis_Defaults |
| 100 | |
| 101 | ${chassis}= Redfish.Get Properties /redfish/v1/Chassis |
| 102 | Rprint Vars chassis |
| 103 | ${chassis_count}= Get Length ${chassis['Members']} |
| 104 | |
| 105 | Valid Value chassis['@odata.context'] ['/redfish/v1/$metadata#ChassisCollection.ChassisCollection'] |
| 106 | Valid Value chassis['Name'] ['Chassis Collection'] |
| 107 | Valid Value chassis['@odata.id'] ['/redfish/v1/Chassis'] |
| 108 | Valid Value chassis['Members@odata.count'] [${chassis_count}] |
| 109 | Valid Value chassis['Members@odata.count'] [${chassis_count}] |
| 110 | |
| 111 | # Members can be one or more, hence checking in the list |
| 112 | Log To Console ${chassis['Members']} |
| 113 | Valid List chassis['Members'] |
| 114 | ... required_values=[{'@odata.id': '/redfish/v1/Chassis/chassis'}] |
| 115 | |
| 116 | |
| 117 | Verify Systems Defaults |
| 118 | [Documentation] Verify systems defaults. |
| 119 | [Tags] Verify_Systems_Defaults |
| 120 | |
| 121 | ${systems}= Redfish.Get Properties /redfish/v1/Systems |
| 122 | Rprint Vars systems |
| 123 | ${systems_count}= Get Length ${systems['Members']} |
| 124 | |
| 125 | Valid Value systems['@odata.context'] |
| 126 | ... ['/redfish/v1/$metadata#ComputerSystemCollection.ComputerSystemCollection'] |
| 127 | Valid Value systems['Name'] ['Computer System Collection'] |
| 128 | Valid Value systems['@odata.id'] ['/redfish/v1/Systems'] |
| 129 | Valid Value systems['Members@odata.count'] [${systems_count}] |
| 130 | Valid Value systems['Members@odata.count'] [${systems_count}] |
| 131 | # Members can be one or more, hence checking in the list |
| 132 | Valid List systems['Members'] required_values=[{'@odata.id': '/redfish/v1/Systems/system'}] |
| 133 | |
| 134 | |
| 135 | Verify Session Persistency After BMC Reboot |
| 136 | [Documentation] Verify session persistency after BMC reboot. |
| 137 | [Tags] Verify_Session_Persistency_After_BMC_Reboot |
| 138 | |
| 139 | # Note the current session location |
| 140 | ${session_location}= Redfish.Get Session Location |
| 141 | |
| 142 | Redfish OBMC Reboot (off) stack_mode=normal |
| 143 | Redfish.Login |
| 144 | |
| 145 | # Check for session persistency after BMC reboot |
| 146 | # sessions here will have list of all sessions location |
| 147 | ${sessions}= Redfish.Get Attribute /redfish/v1/SessionService/Sessions Members |
| 148 | ${payload}= Create Dictionary @odata.id=${session_location} |
| 149 | |
| 150 | List Should Contain Value ${sessions} ${payload} |
| 151 | |
| 152 | |
| 153 | REST Logging Interface Read Should Be A SUCCESS For Authorized Users |
| 154 | [Documentation] REST logging interface read should be a success for authorized users. |
| 155 | [Tags] REST_Logging_Interface_Read_Should_Be_A_SUCCESS_For_Authorized_Users |
| 156 | |
| 157 | ${resp}= Redfish.Get /xyz/openbmc_project/logging |
| 158 | |
| 159 | ${resp_output}= evaluate json.loads('''${resp.text}''') json |
| 160 | ${log_count}= Get Length ${resp_output["data"]} |
| 161 | |
| 162 | # Max 200 error logs are allowed in OpenBmc |
| 163 | Run Keyword Unless ${-1} < ${log_count} < ${201} Fail |
| 164 | |
Vijay | e6fa855 | 2020-01-14 04:44:36 -0600 | [diff] [blame] | 165 | |
| 166 | |
| 167 | *** Keywords *** |
| 168 | |
| 169 | Create Session And Verify Response Code |
| 170 | [Documentation] Create session and verify response code. |
| 171 | [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD} |
| 172 | ... ${valid_status_code}=${HTTP_CREATED} |
| 173 | |
| 174 | # Description of argument(s): |
| 175 | # username The username to create a session. |
| 176 | # password The password to create a session. |
| 177 | # valid_status_code Expected response code, default is ${HTTP_CREATED} |
| 178 | |
| 179 | |
| 180 | ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions |
| 181 | ... body={'UserName':'${username}', 'Password': '${password}'} |
| 182 | ... valid_status_codes=[${valid_status_code}] |
| 183 | |
| 184 | |
| 185 | Create Users With Different Roles |
| 186 | [Documentation] Create users with different roles. |
| 187 | |
| 188 | Create User Of Given Role admin_user TestPwd123 Administrator ${True} |
| 189 | Create User Of Given Role operator_user TestPwd123 Operator ${True} |
| 190 | |
| 191 | |
| 192 | Create User Of Given Role |
| 193 | [Documentation] Create user of given role. |
| 194 | [Arguments] ${username} ${password} ${role_id} ${enabled} |
| 195 | |
| 196 | # Description of argument(s): |
| 197 | # username The username to be created. |
| 198 | # password The password to be assigned. |
| 199 | # role_id The role ID of the user to be created |
| 200 | # (e.g. "Administrator", "Operator", etc.). |
| 201 | # enabled Indicates whether the username being created |
| 202 | # should be enabled (${True}, ${False}). |
| 203 | |
| 204 | # Make sure the user account in question does not already exist. |
| 205 | Redfish.Delete /redfish/v1/AccountService/Accounts/${username} |
| 206 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] |
| 207 | |
| 208 | # Create specified user. |
| 209 | ${payload}= Create Dictionary |
| 210 | ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled} |
| 211 | Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload} |
| 212 | ... valid_status_codes=[${HTTP_CREATED}] |
| 213 | |
| 214 | |
| 215 | Suite Setup Execution |
| 216 | [Documentation] Suite Setup Execution. |
| 217 | |
| 218 | Redfish.Login |
| 219 | Create Users With Different Roles |