1*** Settings *** 2 3Documentation Test client identifier feature on BMC. 4 5Resource ../../lib/rest_client.robot 6Resource ../../lib/openbmc_ffdc.robot 7Resource ../../lib/resource.robot 8Resource ../../lib/bmc_redfish_utils.robot 9Resource ../../lib/external_intf/management_console_utils.robot 10Resource ../../lib/utils.robot 11Library ../../lib/bmc_network_utils.py 12Library ../../lib/gen_robot_valid.py 13 14 15Suite Setup Redfish.Login 16Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions 17Test Setup Printn 18Test Teardown FFDC On Test Case Fail 19 20Test Tags Client_Identifier 21 22*** Test Cases *** 23 24Create A Session With ClientID And Verify 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 28 29 # client_id reboot_flag 30 12345 False 31 123456 False 32 EXTERNAL-CLIENT-01 False 33 EXTERNAL-CLIENT-02 False 34 35 36Check ClientID Persistency On BMC Reboot 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 40 41 # client_id reboot_flag 42 12345 True 43 EXTERNAL-CLIENT-01 True 44 45 46Create 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 56Check 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 65 66Fail 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 75 76Create 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 85*** Keywords *** 86 87Create 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 97 ${client_ids}= Split String ${client_id} , 98 ${session_info}= Create Session With List Of ClientID ${client_ids} 99 Verify A Session Created With ClientID ${client_ids} ${session_info} 100 101 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} 102 103 IF '${reboot_flag}' == 'True' 104 Redfish BMC Reset Operation 105 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} 106 Is BMC Standby 107 Verify A Session Created With ClientID ${client_ids} ${session_info} 108 END 109 110 Redfish Delete List Of Session ${session_info} 111 112 113Set Client Origin IP 114 [Documentation] Set client origin IP. 115 [Arguments] ${client_id} ${client_ip} ${status} 116 117 # Description of argument(s): 118 # client_id This client id contain string value 119 # (e.g. 12345, "EXTERNAL-CLIENT"). 120 # client_ip Valid IP address 121 # status HTTP status code 122 123 ${session}= Run Keyword And Return Status 124 ... Redfish Login 125 ... kwargs= {"Context": "${client_id}", "ClientOriginIP":"${client_ip}"}} 126 Valid Value session [${status}] 127 128 129Create Session And Fail To Set Client Origin IP 130 [Documentation] Create redifish session with client id and fail to set client origin IP. 131 [Arguments] ${client_id} 132 133 # Description of argument(s): 134 # client_id This client id contain string value 135 # (e.g. 12345, "EXTERNAL-CLIENT"). 136 137 Set Test Variable ${client_ip} 10.6.7.8 138 ${resp}= Set Client Origin IP ${client_id} ${client_ip} status=False 139 140 141Create A Non Admin Session With ClientID 142 [Documentation] Create redifish session with client id. 143 [Arguments] ${client_id} ${username} ${password} 144 145 # Description of argument(s): 146 # client_id This client id can contain string value 147 # (e.g. 12345, "EXTERNAL-CLIENT"). 148 149 @{session_list}= Create List 150 &{tmp_dict}= Create Dictionary 151 152 FOR ${client} IN @{client_id} 153 ${resp}= Redfish Login rest_username=${username} rest_password=${password} 154 ... kwargs="Context": "${client_id}" 155 Append To List ${session_list} ${resp} 156 END 157 158 RETURN ${session_list} 159 160 161Verify A Non Admin Session Created With ClientID 162 [Documentation] Verify session created with client id. 163 [Arguments] ${client_ids} ${session_ids} 164 165 # Description of argument(s): 166 # client_ids External client name. 167 # session_ids This value is a session id. 168 169 # { 170 # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ", 171 # "@odata.type": "#Session.v1_0_2.Session", 172 # "Description": "Manager User Session", 173 # "Id": "H8q2ZKucSJ", 174 # "Name": "User Session", 175 # "Oem": { 176 # "OpenBMC": { 177 # "@odata.type": "#OemSession.v1_0_0.Session", 178 # "ClientID": "", 179 # "ClientOriginIP": "::ffff:x.x.x.x" 180 # } 181 # }, 182 # "UserName": "root" 183 # } 184 185 FOR ${client} ${session} IN ZIP ${client_ids} ${session_ids} 186 ${resp}= Redfish Get Request /redfish/v1/SessionService/Sessions/${session["Id"]} 187 Rprint Vars resp.json() 188 @{words} = Split String ${resp.json()["ClientOriginIPAddress"]} : 189 ${ip_address}= Get Running System IP 190 Set Test Variable ${temp_ipaddr} ${words}[-1] 191 Valid Value client ['${resp.json()["Oem"]["OpenBMC"]["ClientID"]}'] 192 Valid Value session["Id"] ['${resp.json()["Id"]}'] 193 Valid Value temp_ipaddr ${ip_address} 194 END 195 196 197Non Admin User To Create Session 198 [Documentation] Non Admin user create a session and verify the session is created. 199 [Arguments] ${client_id} ${username} ${password} ${role} ${enabled}=${True} 200 201 # Description of argument(s): 202 # client_id This client id contain string value 203 # (e.g. 12345, "EXTERNAL-CLIENT"). 204 # username Username. 205 # password Password. 206 # role Role of user. 207 # enabled Value can be True or False. 208 209 Redfish.Login 210 Redfish Create User ${username} ${password} ${role} ${enabled} 211 Delete All Sessions 212 Redfish.Logout 213 Initialize OpenBMC rest_username=${username} rest_password=${password} 214 ${client_ids}= Split String ${client_id} , 215 ${session_info}= Create A Non Admin Session With ClientID ${client_ids} ${username} ${password} 216 Verify A Non Admin Session Created With ClientID ${client_ids} ${session_info} 217