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