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 |
Sushil Singh | ca49ced | 2020-11-05 03:15:19 -0600 | [diff] [blame] | 9 | Resource ../../lib/external_intf/management_console_utils.robot |
Sushil Singh | f90fd65 | 2021-02-05 05:07:40 -0600 | [diff] [blame] | 10 | Resource ../../lib/utils.robot |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 11 | Library ../../lib/bmc_network_utils.py |
| 12 | Library ../../lib/gen_robot_valid.py |
| 13 | |
Sushil Singh | f90fd65 | 2021-02-05 05:07:40 -0600 | [diff] [blame] | 14 | |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 15 | Suite Setup Redfish.Login |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 16 | Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 17 | Test Setup Printn |
| 18 | Test Teardown FFDC On Test Case Fail |
| 19 | |
George Keishing | 7c32f30 | 2023-10-10 16:11:46 +0530 | [diff] [blame] | 20 | Force Tags Client_Identifier |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 21 | |
| 22 | *** Test Cases *** |
| 23 | |
| 24 | Create A Session With ClientID And Verify |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 25 | [Documentation] Create a session with client id and verify client id is same. |
| 26 | [Tags] Create_A_Session_With_ClientID_And_Verify |
| 27 | [Template] Create And Verify Session ClientID |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 28 | |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 29 | # client_id reboot_flag |
| 30 | 12345 False |
| 31 | 123456 False |
| 32 | EXTERNAL-CLIENT-01 False |
| 33 | EXTERNAL-CLIENT-02 False |
Sushil Singh | 1384321 | 2020-08-18 04:00:51 -0500 | [diff] [blame] | 34 | |
| 35 | |
| 36 | Check ClientID Persistency On BMC Reboot |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 37 | [Documentation] Create a session with client id and verify client id is same after the reboot. |
| 38 | [Tags] Check_ClientID_Persistency_On_BMC_Reboot |
| 39 | [Template] Create And Verify Session ClientID |
Sushil Singh | 1384321 | 2020-08-18 04:00:51 -0500 | [diff] [blame] | 40 | |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 41 | # client_id reboot_flag |
| 42 | 12345 True |
| 43 | EXTERNAL-CLIENT-01 True |
| 44 | |
| 45 | |
| 46 | Create A Multiple Session With ClientID And Verify |
| 47 | [Documentation] Create a multiple session with client id and verify client id is same. |
| 48 | [Tags] Create_A_Multiple_Session_With_ClientID_And_Verify |
| 49 | [Template] Create And Verify Session ClientID |
| 50 | |
| 51 | # client_id reboot_flag |
| 52 | 12345,123456 False |
| 53 | EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 False |
| 54 | |
| 55 | |
| 56 | Check Multiple ClientID Persistency On BMC Reboot |
| 57 | [Documentation] Create a multiple session with client id and verify client id is same after the reboot. |
| 58 | [Tags] Check_Multiple_ClientID_Persistency_On_BMC_Reboot |
| 59 | [Template] Create And Verify Session ClientID |
| 60 | |
| 61 | # client_id reboot_flag |
| 62 | 12345,123456 True |
| 63 | EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 True |
| 64 | |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 65 | |
Sushil Singh | c957f57 | 2020-08-20 05:47:02 -0500 | [diff] [blame] | 66 | Fail To Set Client Origin IP |
| 67 | [Documentation] Fail to set the client origin IP. |
| 68 | [Tags] Fail_To_Set_Client_Origin_IP |
| 69 | [Template] Create Session And Fail To Set Client Origin IP |
| 70 | |
| 71 | # client_id |
| 72 | 12345 |
| 73 | EXTERNAL-CLIENT-01 |
| 74 | |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 75 | |
| 76 | Create Session For Non Admin User |
| 77 | [Documentation] Create Session for non-admin user. |
| 78 | [Tags] Create_Session_For_Non_Admin_User |
| 79 | [Template] Non Admin User To Create Session |
| 80 | |
| 81 | # client_id username password role_id |
| 82 | 12345 operator_user TestPwd123 Operator |
| 83 | |
| 84 | |
Sushil Singh | 45d841e | 2020-07-30 11:52:11 -0500 | [diff] [blame] | 85 | *** Keywords *** |
| 86 | |
Sushil Singh | 1384321 | 2020-08-18 04:00:51 -0500 | [diff] [blame] | 87 | Create And Verify Session ClientID |
| 88 | [Documentation] Create redifish session with client id and verify it remain same. |
| 89 | [Arguments] ${client_id} ${reboot_flag}=False |
| 90 | |
| 91 | # Description of argument(s): |
| 92 | # client_id This client id contain string value |
| 93 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 94 | # reboot_flag Flag is used to run reboot the BMC code. |
| 95 | # (e.g. True or False). |
| 96 | |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 97 | ${client_ids}= Split String ${client_id} , |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame] | 98 | ${session_info}= Create Session With List Of ClientID ${client_ids} |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 99 | Verify A Session Created With ClientID ${client_ids} ${session_info} |
Sushil Singh | f90fd65 | 2021-02-05 05:07:40 -0600 | [diff] [blame] | 100 | |
| 101 | ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} |
| 102 | |
Sushil Singh | 1384321 | 2020-08-18 04:00:51 -0500 | [diff] [blame] | 103 | Run Keyword If '${reboot_flag}' == 'True' |
Sushil Singh | f90fd65 | 2021-02-05 05:07:40 -0600 | [diff] [blame] | 104 | ... Run Keywords Redfish BMC Reset Operation AND |
| 105 | ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND |
| 106 | ... Is BMC Standby AND |
Sushil Singh | 889a75e | 2020-08-19 08:50:15 -0500 | [diff] [blame] | 107 | ... Verify A Session Created With ClientID ${client_ids} ${session_info} |
Sushil Singh | f90fd65 | 2021-02-05 05:07:40 -0600 | [diff] [blame] | 108 | |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame] | 109 | Redfish Delete List Of Session ${session_info} |
Sushil Singh | c957f57 | 2020-08-20 05:47:02 -0500 | [diff] [blame] | 110 | |
| 111 | |
| 112 | Set Client Origin IP |
| 113 | [Documentation] Set client origin IP. |
| 114 | [Arguments] ${client_id} ${client_ip} ${status} |
| 115 | |
| 116 | # Description of argument(s): |
| 117 | # client_id This client id contain string value |
| 118 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 119 | # client_ip Valid IP address |
| 120 | # status HTTP status code |
| 121 | |
| 122 | ${session}= Run Keyword And Return Status |
| 123 | ... Redfish Login |
Sushil Singh | 10dba42 | 2023-07-25 02:08:26 -0500 | [diff] [blame] | 124 | ... kwargs= {"Context": "${client_id}", "ClientOriginIP":"${client_ip}"}} |
Sushil Singh | c957f57 | 2020-08-20 05:47:02 -0500 | [diff] [blame] | 125 | Valid Value session [${status}] |
| 126 | |
| 127 | |
| 128 | Create Session And Fail To Set Client Origin IP |
| 129 | [Documentation] Create redifish session with client id and fail to set client origin IP. |
| 130 | [Arguments] ${client_id} |
| 131 | |
| 132 | # Description of argument(s): |
| 133 | # client_id This client id contain string value |
| 134 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 135 | |
| 136 | Set Test Variable ${client_ip} 10.6.7.8 |
| 137 | ${resp}= Set Client Origin IP ${client_id} ${client_ip} status=False |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 138 | |
| 139 | |
| 140 | Create A Non Admin Session With ClientID |
| 141 | [Documentation] Create redifish session with client id. |
| 142 | [Arguments] ${client_id} ${username} ${password} |
| 143 | |
| 144 | # Description of argument(s): |
| 145 | # client_id This client id can contain string value |
| 146 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 147 | |
| 148 | @{session_list}= Create List |
| 149 | &{tmp_dict}= Create Dictionary |
| 150 | |
| 151 | FOR ${client} IN @{client_id} |
George Keishing | b78bca2 | 2021-06-29 11:11:19 -0500 | [diff] [blame] | 152 | ${resp}= Redfish Login rest_username=${username} rest_password=${password} |
Sushil Singh | 10dba42 | 2023-07-25 02:08:26 -0500 | [diff] [blame] | 153 | ... kwargs="Context": "${client_id}" |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 154 | Append To List ${session_list} ${resp} |
| 155 | END |
| 156 | |
| 157 | [Return] ${session_list} |
| 158 | |
| 159 | |
| 160 | Verify A Non Admin Session Created With ClientID |
| 161 | [Documentation] Verify session created with client id. |
| 162 | [Arguments] ${client_ids} ${session_ids} |
| 163 | |
| 164 | # Description of argument(s): |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame] | 165 | # client_ids External client name. |
| 166 | # session_ids This value is a session id. |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 167 | |
| 168 | # { |
| 169 | # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ", |
| 170 | # "@odata.type": "#Session.v1_0_2.Session", |
| 171 | # "Description": "Manager User Session", |
| 172 | # "Id": "H8q2ZKucSJ", |
| 173 | # "Name": "User Session", |
| 174 | # "Oem": { |
| 175 | # "OpenBMC": { |
| 176 | # "@odata.type": "#OemSession.v1_0_0.Session", |
| 177 | # "ClientID": "", |
| 178 | # "ClientOriginIP": "::ffff:x.x.x.x" |
| 179 | # } |
| 180 | # }, |
| 181 | # "UserName": "root" |
| 182 | # } |
| 183 | |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame] | 184 | FOR ${client} ${session} IN ZIP ${client_ids} ${session_ids} |
| 185 | ${resp}= Redfish Get Request /redfish/v1/SessionService/Sessions/${session["Id"]} |
George Keishing | fbd6700 | 2022-08-01 11:24:03 -0500 | [diff] [blame] | 186 | Rprint Vars resp.json() |
| 187 | @{words} = Split String ${resp.json()["ClientOriginIPAddress"]} : |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 188 | ${ip_address}= Get Running System IP |
| 189 | Set Test Variable ${temp_ipaddr} ${words}[-1] |
George Keishing | fbd6700 | 2022-08-01 11:24:03 -0500 | [diff] [blame] | 190 | Valid Value client ['${resp.json()["Oem"]["OpenBMC"]["ClientID"]}'] |
| 191 | Valid Value session["Id"] ['${resp.json()["Id"]}'] |
Sushil Singh | 4ec68ba | 2020-09-11 09:16:43 -0500 | [diff] [blame] | 192 | Valid Value temp_ipaddr ${ip_address} |
| 193 | END |
| 194 | |
| 195 | |
| 196 | Non Admin User To Create Session |
| 197 | [Documentation] Non Admin user create a session and verify the session is created. |
| 198 | [Arguments] ${client_id} ${username} ${password} ${role} ${enabled}=${True} |
| 199 | |
| 200 | # Description of argument(s): |
| 201 | # client_id This client id contain string value |
| 202 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 203 | # username Username. |
| 204 | # password Password. |
| 205 | # role Role of user. |
| 206 | # enabled Value can be True or False. |
| 207 | |
| 208 | Redfish.Login |
| 209 | Redfish Create User ${username} ${password} ${role} ${enabled} |
| 210 | Delete All Sessions |
| 211 | Redfish.Logout |
| 212 | Initialize OpenBMC rest_username=${username} rest_password=${password} |
| 213 | ${client_ids}= Split String ${client_id} , |
| 214 | ${session_info}= Create A Non Admin Session With ClientID ${client_ids} ${username} ${password} |
| 215 | Verify A Non Admin Session Created With ClientID ${client_ids} ${session_info} |