Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Test client identifier feature on BMC. |
| 4 | |
| 5 | Resource ../../lib/rest_client.robot |
| 6 | Resource ../../lib/openbmc_ffdc.robot |
| 7 | Resource ../../lib/resource.robot |
| 8 | Resource ../../lib/bmc_redfish_utils.robot |
| 9 | Library ../../lib/bmc_network_utils.py |
| 10 | Library ../../lib/gen_robot_valid.py |
| 11 | |
| 12 | Suite Setup Redfish.Login |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 13 | Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 14 | Test Setup Printn |
| 15 | Test Teardown FFDC On Test Case Fail |
| 16 | |
| 17 | |
| 18 | *** Test Cases *** |
| 19 | |
| 20 | Create A Session With ClientID And Verify |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 21 | [Documentation] Create a session with client id and verify client id is same. |
| 22 | [Tags] Create_A_Session_With_ClientID_And_Verify |
| 23 | [Template] Create And Verify Session ClientID |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 24 | |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 25 | # client_id reboot_flag |
| 26 | 12345 False |
| 27 | 123456 False |
| 28 | EXTERNAL-CLIENT-01 False |
| 29 | EXTERNAL-CLIENT-02 False |
Sushil Singh | 1384321 | 2020-08-18 04:00:51 -0500 | [diff] [blame] | 30 | |
| 31 | |
| 32 | Check ClientID Persistency On BMC Reboot |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 33 | [Documentation] Create a session with client id and verify client id is same after the reboot. |
| 34 | [Tags] Check_ClientID_Persistency_On_BMC_Reboot |
| 35 | [Template] Create And Verify Session ClientID |
Sushil Singh | 1384321 | 2020-08-18 04:00:51 -0500 | [diff] [blame] | 36 | |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 37 | # client_id reboot_flag |
| 38 | 12345 True |
| 39 | EXTERNAL-CLIENT-01 True |
| 40 | |
| 41 | |
| 42 | Create A Multiple Session With ClientID And Verify |
| 43 | [Documentation] Create a multiple session with client id and verify client id is same. |
| 44 | [Tags] Create_A_Multiple_Session_With_ClientID_And_Verify |
| 45 | [Template] Create And Verify Session ClientID |
| 46 | |
| 47 | # client_id reboot_flag |
| 48 | 12345,123456 False |
| 49 | EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 False |
| 50 | |
| 51 | |
| 52 | Check Multiple ClientID Persistency On BMC Reboot |
| 53 | [Documentation] Create a multiple session with client id and verify client id is same after the reboot. |
| 54 | [Tags] Check_Multiple_ClientID_Persistency_On_BMC_Reboot |
| 55 | [Template] Create And Verify Session ClientID |
| 56 | |
| 57 | # client_id reboot_flag |
| 58 | 12345,123456 True |
| 59 | EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 True |
| 60 | |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 61 | |
Sushil Singh | c957f57 | 2020-08-20 05:47:02 -0500 | [diff] [blame] | 62 | Fail To Set Client Origin IP |
| 63 | [Documentation] Fail to set the client origin IP. |
| 64 | [Tags] Fail_To_Set_Client_Origin_IP |
| 65 | [Template] Create Session And Fail To Set Client Origin IP |
| 66 | |
| 67 | # client_id |
| 68 | 12345 |
| 69 | EXTERNAL-CLIENT-01 |
| 70 | |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 71 | |
| 72 | Create Session For Non Admin User |
| 73 | [Documentation] Create Session for non-admin user. |
| 74 | [Tags] Create_Session_For_Non_Admin_User |
| 75 | [Template] Non Admin User To Create Session |
| 76 | |
| 77 | # client_id username password role_id |
| 78 | 12345 operator_user TestPwd123 Operator |
| 79 | |
| 80 | |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 81 | *** Keywords *** |
| 82 | |
| 83 | Create A Session With ClientID |
| 84 | [Documentation] Create redifish session with client id. |
| 85 | [Arguments] ${client_id} |
| 86 | |
| 87 | # Description of argument(s): |
| 88 | # client_id This client id can contain string value |
| 89 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 90 | |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 91 | @{session_list}= Create List |
| 92 | &{tmp_dict}= Create Dictionary |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 93 | |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 94 | FOR ${client} IN @{client_id} |
| 95 | ${resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client}"}} |
| 96 | Append To List ${session_list} ${resp} |
| 97 | END |
| 98 | |
| 99 | [Return] ${session_list} |
| 100 | |
| 101 | |
| 102 | Get Session Information By ClientID |
| 103 | [Documentation] Get session information by client id. |
| 104 | [Arguments] ${client_id} ${session_ids} |
| 105 | |
| 106 | FOR ${session} IN @{session_ids} |
| 107 | Return From Keyword If '${client_id}' == '${session["Oem"]["OpenBMC"]["ClientID"]}' ${session["Id"]} |
| 108 | END |
| 109 | |
| 110 | [Return] ${EMPTY} |
| 111 | |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 112 | |
| 113 | Verify A Session Created With ClientID |
| 114 | [Documentation] Verify session created with client id. |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 115 | [Arguments] ${client_ids} ${session_ids} |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 116 | |
| 117 | # Description of argument(s): |
| 118 | # client_id External client name. |
| 119 | # session_id This value is a session id. |
| 120 | |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 121 | # { |
| 122 | # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ", |
| 123 | # "@odata.type": "#Session.v1_0_2.Session", |
| 124 | # "Description": "Manager User Session", |
| 125 | # "Id": "H8q2ZKucSJ", |
| 126 | # "Name": "User Session", |
| 127 | # "Oem": { |
| 128 | # "OpenBMC": { |
| 129 | # "@odata.type": "#OemSession.v1_0_0.Session", |
| 130 | # "ClientID": "", |
| 131 | # "ClientOriginIP": "::ffff:x.x.x.x" |
| 132 | # } |
| 133 | # }, |
| 134 | # "UserName": "root" |
| 135 | # } |
| 136 | |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 137 | FOR ${client} IN @{client_ids} |
| 138 | ${session_id}= Get Session Information By ClientID ${client} ${session_ids} |
| 139 | ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id} |
| 140 | Rprint Vars sessions |
Sushil Singh | 24e32af | 2020-10-05 08:09:00 -0500 | [diff] [blame] | 141 | @{words} = Split String ${sessions["ClientOriginIPAddress"]} : |
Sushil Singh | 07297f8 | 2020-09-08 09:12:04 -0500 | [diff] [blame] | 142 | ${ip_address}= Get Running System IP |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 143 | Set Test Variable ${temp_ipaddr} ${words}[-1] |
| 144 | Valid Value client ['${sessions["Oem"]["OpenBMC"]["ClientID"]}'] |
| 145 | Valid Value sessions["Id"] ['${session_id}'] |
Sushil Singh | 07297f8 | 2020-09-08 09:12:04 -0500 | [diff] [blame] | 146 | Valid Value temp_ipaddr ${ip_address} |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 147 | END |
Sushil Singh | 1384321 | 2020-08-18 04:00:51 -0500 | [diff] [blame] | 148 | |
| 149 | |
| 150 | Create And Verify Session ClientID |
| 151 | [Documentation] Create redifish session with client id and verify it remain same. |
| 152 | [Arguments] ${client_id} ${reboot_flag}=False |
| 153 | |
| 154 | # Description of argument(s): |
| 155 | # client_id This client id contain string value |
| 156 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 157 | # reboot_flag Flag is used to run reboot the BMC code. |
| 158 | # (e.g. True or False). |
| 159 | |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 160 | ${client_ids}= Split String ${client_id} , |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame^] | 161 | ${session_info}= Create Session With List Of ClientID ${client_ids} |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 162 | Verify A Session Created With ClientID ${client_ids} ${session_info} |
Sushil Singh | 1384321 | 2020-08-18 04:00:51 -0500 | [diff] [blame] | 163 | Run Keyword If '${reboot_flag}' == 'True' |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 164 | ... Run Keywords Redfish OBMC Reboot (off) AND |
| 165 | ... Verify A Session Created With ClientID ${client_ids} ${session_info} |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame^] | 166 | Redfish Delete List Of Session ${session_info} |
Sushil Singh | c957f57 | 2020-08-20 05:47:02 -0500 | [diff] [blame] | 167 | |
| 168 | |
| 169 | Set Client Origin IP |
| 170 | [Documentation] Set client origin IP. |
| 171 | [Arguments] ${client_id} ${client_ip} ${status} |
| 172 | |
| 173 | # Description of argument(s): |
| 174 | # client_id This client id contain string value |
| 175 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 176 | # client_ip Valid IP address |
| 177 | # status HTTP status code |
| 178 | |
| 179 | ${session}= Run Keyword And Return Status |
| 180 | ... Redfish Login |
| 181 | ... kwargs= "Oem":{"OpenBMC": {"ClientID":"${client_id}", "ClientOriginIP":"${client_ip}"}} |
| 182 | Valid Value session [${status}] |
| 183 | |
| 184 | |
| 185 | Create Session And Fail To Set Client Origin IP |
| 186 | [Documentation] Create redifish session with client id and fail to set client origin IP. |
| 187 | [Arguments] ${client_id} |
| 188 | |
| 189 | # Description of argument(s): |
| 190 | # client_id This client id contain string value |
| 191 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 192 | |
| 193 | Set Test Variable ${client_ip} 10.6.7.8 |
| 194 | ${resp}= Set Client Origin IP ${client_id} ${client_ip} status=False |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 195 | |
| 196 | |
| 197 | Create A Non Admin Session With ClientID |
| 198 | [Documentation] Create redifish session with client id. |
| 199 | [Arguments] ${client_id} ${username} ${password} |
| 200 | |
| 201 | # Description of argument(s): |
| 202 | # client_id This client id can contain string value |
| 203 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 204 | |
| 205 | @{session_list}= Create List |
| 206 | &{tmp_dict}= Create Dictionary |
| 207 | |
| 208 | FOR ${client} IN @{client_id} |
| 209 | ${resp}= Redfish Login rest_username=${username} rest_password=${password} kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client}"}} |
| 210 | Append To List ${session_list} ${resp} |
| 211 | END |
| 212 | |
| 213 | [Return] ${session_list} |
| 214 | |
| 215 | |
| 216 | Verify A Non Admin Session Created With ClientID |
| 217 | [Documentation] Verify session created with client id. |
| 218 | [Arguments] ${client_ids} ${session_ids} |
| 219 | |
| 220 | # Description of argument(s): |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame^] | 221 | # client_ids External client name. |
| 222 | # session_ids This value is a session id. |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 223 | |
| 224 | # { |
| 225 | # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ", |
| 226 | # "@odata.type": "#Session.v1_0_2.Session", |
| 227 | # "Description": "Manager User Session", |
| 228 | # "Id": "H8q2ZKucSJ", |
| 229 | # "Name": "User Session", |
| 230 | # "Oem": { |
| 231 | # "OpenBMC": { |
| 232 | # "@odata.type": "#OemSession.v1_0_0.Session", |
| 233 | # "ClientID": "", |
| 234 | # "ClientOriginIP": "::ffff:x.x.x.x" |
| 235 | # } |
| 236 | # }, |
| 237 | # "UserName": "root" |
| 238 | # } |
| 239 | |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame^] | 240 | FOR ${client} ${session} IN ZIP ${client_ids} ${session_ids} |
| 241 | ${resp}= Redfish Get Request /redfish/v1/SessionService/Sessions/${session["Id"]} |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 242 | ${sessions}= To Json ${resp.content} |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 243 | Rprint Vars sessions |
Sushil Singh | 24e32af | 2020-10-05 08:09:00 -0500 | [diff] [blame] | 244 | @{words} = Split String ${sessions["ClientOriginIPAddress"]} : |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 245 | ${ip_address}= Get Running System IP |
| 246 | Set Test Variable ${temp_ipaddr} ${words}[-1] |
| 247 | Valid Value client ['${sessions["Oem"]["OpenBMC"]["ClientID"]}'] |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame^] | 248 | Valid Value session["Id"] ['${sessions["Id"]}'] |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 249 | Valid Value temp_ipaddr ${ip_address} |
| 250 | END |
| 251 | |
| 252 | |
| 253 | Non Admin User To Create Session |
| 254 | [Documentation] Non Admin user create a session and verify the session is created. |
| 255 | [Arguments] ${client_id} ${username} ${password} ${role} ${enabled}=${True} |
| 256 | |
| 257 | # Description of argument(s): |
| 258 | # client_id This client id contain string value |
| 259 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 260 | # username Username. |
| 261 | # password Password. |
| 262 | # role Role of user. |
| 263 | # enabled Value can be True or False. |
| 264 | |
| 265 | Redfish.Login |
| 266 | Redfish Create User ${username} ${password} ${role} ${enabled} |
| 267 | Delete All Sessions |
| 268 | Redfish.Logout |
| 269 | Initialize OpenBMC rest_username=${username} rest_password=${password} |
| 270 | ${client_ids}= Split String ${client_id} , |
| 271 | ${session_info}= Create A Non Admin Session With ClientID ${client_ids} ${username} ${password} |
| 272 | Verify A Non Admin Session Created With ClientID ${client_ids} ${session_info} |