145d841e3SSushil Singh*** Settings *** 245d841e3SSushil Singh 345d841e3SSushil SinghDocumentation Test client identifier feature on BMC. 445d841e3SSushil Singh 545d841e3SSushil SinghResource ../../lib/rest_client.robot 645d841e3SSushil SinghResource ../../lib/openbmc_ffdc.robot 745d841e3SSushil SinghResource ../../lib/resource.robot 845d841e3SSushil SinghResource ../../lib/bmc_redfish_utils.robot 945d841e3SSushil SinghLibrary ../../lib/bmc_network_utils.py 1045d841e3SSushil SinghLibrary ../../lib/gen_robot_valid.py 1145d841e3SSushil Singh 1245d841e3SSushil SinghSuite Setup Redfish.Login 13889a75e4SSushil SinghSuite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions 1445d841e3SSushil SinghTest Setup Printn 1545d841e3SSushil SinghTest Teardown FFDC On Test Case Fail 1645d841e3SSushil Singh 1745d841e3SSushil Singh 1845d841e3SSushil Singh*** Test Cases *** 1945d841e3SSushil Singh 2045d841e3SSushil SinghCreate A Session With ClientID And Verify 2145d841e3SSushil Singh [Documentation] Create a session with client id and verify client id is same. 2245d841e3SSushil Singh [Tags] Create_A_Session_With_ClientID_And_Verify 231384321bSSushil Singh [Template] Create And Verify Session ClientID 2445d841e3SSushil Singh 25889a75e4SSushil Singh # client_id reboot_flag 261384321bSSushil Singh 12345 False 271384321bSSushil Singh 123456 False 281384321bSSushil Singh EXTERNAL-CLIENT-01 False 291384321bSSushil Singh EXTERNAL-CLIENT-02 False 301384321bSSushil Singh 311384321bSSushil Singh 321384321bSSushil SinghCheck ClientID Persistency On BMC Reboot 331384321bSSushil Singh [Documentation] Create a session with client id and verify client id is same after the reboot. 341384321bSSushil Singh [Tags] Check_ClientID_Persistency_On_BMC_Reboot 351384321bSSushil Singh [Template] Create And Verify Session ClientID 361384321bSSushil Singh 37889a75e4SSushil Singh # client_id reboot_flag 381384321bSSushil Singh 12345 True 391384321bSSushil Singh EXTERNAL-CLIENT-01 True 4045d841e3SSushil Singh 41889a75e4SSushil Singh 42889a75e4SSushil SinghCreate A Multiple Session With ClientID And Verify 43889a75e4SSushil Singh [Documentation] Create a multiple session with client id and verify client id is same. 44889a75e4SSushil Singh [Tags] Create_A_Multiple_Session_With_ClientID_And_Verify 45889a75e4SSushil Singh [Template] Create And Verify Session ClientID 46889a75e4SSushil Singh 47889a75e4SSushil Singh # client_id reboot_flag 48889a75e4SSushil Singh 12345,123456 False 49889a75e4SSushil Singh EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 False 50889a75e4SSushil Singh 51889a75e4SSushil Singh 52889a75e4SSushil SinghCheck Multiple ClientID Persistency On BMC Reboot 53889a75e4SSushil Singh [Documentation] Create a multiple session with client id and verify client id is same after the reboot. 54889a75e4SSushil Singh [Tags] Check_Multiple_ClientID_Persistency_On_BMC_Reboot 55889a75e4SSushil Singh [Template] Create And Verify Session ClientID 56889a75e4SSushil Singh 57889a75e4SSushil Singh # client_id reboot_flag 58889a75e4SSushil Singh 12345,123456 True 59889a75e4SSushil Singh EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 True 60889a75e4SSushil Singh 61889a75e4SSushil Singh 62c957f57fSSushil SinghFail To Set Client Origin IP 63c957f57fSSushil Singh [Documentation] Fail to set the client origin IP. 64c957f57fSSushil Singh [Tags] Fail_To_Set_Client_Origin_IP 65c957f57fSSushil Singh [Template] Create Session And Fail To Set Client Origin IP 66c957f57fSSushil Singh 67c957f57fSSushil Singh # client_id 68c957f57fSSushil Singh 12345 69c957f57fSSushil Singh EXTERNAL-CLIENT-01 70c957f57fSSushil Singh 71*4ec68ba8SSushil Singh 72*4ec68ba8SSushil SinghCreate Session For Non Admin User 73*4ec68ba8SSushil Singh [Documentation] Create Session for non-admin user. 74*4ec68ba8SSushil Singh [Tags] Create_Session_For_Non_Admin_User 75*4ec68ba8SSushil Singh [Template] Non Admin User To Create Session 76*4ec68ba8SSushil Singh 77*4ec68ba8SSushil Singh # client_id username password role_id 78*4ec68ba8SSushil Singh 12345 operator_user TestPwd123 Operator 79*4ec68ba8SSushil Singh 80*4ec68ba8SSushil Singh 8145d841e3SSushil Singh*** Keywords *** 8245d841e3SSushil Singh 8345d841e3SSushil SinghCreate A Session With ClientID 8445d841e3SSushil Singh [Documentation] Create redifish session with client id. 8545d841e3SSushil Singh [Arguments] ${client_id} 8645d841e3SSushil Singh 8745d841e3SSushil Singh # Description of argument(s): 8845d841e3SSushil Singh # client_id This client id can contain string value 8945d841e3SSushil Singh # (e.g. 12345, "EXTERNAL-CLIENT"). 9045d841e3SSushil Singh 91889a75e4SSushil Singh @{session_list}= Create List 92889a75e4SSushil Singh &{tmp_dict}= Create Dictionary 9345d841e3SSushil Singh 94889a75e4SSushil Singh FOR ${client} IN @{client_id} 95889a75e4SSushil Singh ${resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client}"}} 96889a75e4SSushil Singh Append To List ${session_list} ${resp} 97889a75e4SSushil Singh END 98889a75e4SSushil Singh 99889a75e4SSushil Singh [Return] ${session_list} 100889a75e4SSushil Singh 101889a75e4SSushil Singh 102889a75e4SSushil SinghGet Session Information By ClientID 103889a75e4SSushil Singh [Documentation] Get session information by client id. 104889a75e4SSushil Singh [Arguments] ${client_id} ${session_ids} 105889a75e4SSushil Singh 106889a75e4SSushil Singh FOR ${session} IN @{session_ids} 107889a75e4SSushil Singh Return From Keyword If '${client_id}' == '${session["Oem"]["OpenBMC"]["ClientID"]}' ${session["Id"]} 108889a75e4SSushil Singh END 109889a75e4SSushil Singh 110889a75e4SSushil Singh [Return] ${EMPTY} 111889a75e4SSushil Singh 11245d841e3SSushil Singh 11345d841e3SSushil SinghVerify A Session Created With ClientID 11445d841e3SSushil Singh [Documentation] Verify session created with client id. 115889a75e4SSushil Singh [Arguments] ${client_ids} ${session_ids} 11645d841e3SSushil Singh 11745d841e3SSushil Singh # Description of argument(s): 11845d841e3SSushil Singh # client_id External client name. 11945d841e3SSushil Singh # session_id This value is a session id. 12045d841e3SSushil Singh 12145d841e3SSushil Singh # { 12245d841e3SSushil Singh # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ", 12345d841e3SSushil Singh # "@odata.type": "#Session.v1_0_2.Session", 12445d841e3SSushil Singh # "Description": "Manager User Session", 12545d841e3SSushil Singh # "Id": "H8q2ZKucSJ", 12645d841e3SSushil Singh # "Name": "User Session", 12745d841e3SSushil Singh # "Oem": { 12845d841e3SSushil Singh # "OpenBMC": { 12945d841e3SSushil Singh # "@odata.type": "#OemSession.v1_0_0.Session", 13045d841e3SSushil Singh # "ClientID": "", 13145d841e3SSushil Singh # "ClientOriginIP": "::ffff:x.x.x.x" 13245d841e3SSushil Singh # } 13345d841e3SSushil Singh # }, 13445d841e3SSushil Singh # "UserName": "root" 13545d841e3SSushil Singh # } 13645d841e3SSushil Singh 137889a75e4SSushil Singh FOR ${client} IN @{client_ids} 138889a75e4SSushil Singh ${session_id}= Get Session Information By ClientID ${client} ${session_ids} 139889a75e4SSushil Singh ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id} 14045d841e3SSushil Singh Rprint Vars sessions 14145d841e3SSushil Singh @{words} = Split String ${sessions["Oem"]["OpenBMC"]["ClientOriginIP"]} : 14207297f8bSSushil Singh ${ip_address}= Get Running System IP 14345d841e3SSushil Singh Set Test Variable ${temp_ipaddr} ${words}[-1] 144889a75e4SSushil Singh Valid Value client ['${sessions["Oem"]["OpenBMC"]["ClientID"]}'] 14545d841e3SSushil Singh Valid Value sessions["Id"] ['${session_id}'] 14607297f8bSSushil Singh Valid Value temp_ipaddr ${ip_address} 147889a75e4SSushil Singh END 1481384321bSSushil Singh 1491384321bSSushil Singh 1501384321bSSushil SinghCreate And Verify Session ClientID 1511384321bSSushil Singh [Documentation] Create redifish session with client id and verify it remain same. 1521384321bSSushil Singh [Arguments] ${client_id} ${reboot_flag}=False 1531384321bSSushil Singh 1541384321bSSushil Singh # Description of argument(s): 1551384321bSSushil Singh # client_id This client id contain string value 1561384321bSSushil Singh # (e.g. 12345, "EXTERNAL-CLIENT"). 1571384321bSSushil Singh # reboot_flag Flag is used to run reboot the BMC code. 1581384321bSSushil Singh # (e.g. True or False). 1591384321bSSushil Singh 160889a75e4SSushil Singh ${client_ids}= Split String ${client_id} , 161889a75e4SSushil Singh ${session_info}= Create A Session With ClientID ${client_ids} 162889a75e4SSushil Singh Verify A Session Created With ClientID ${client_ids} ${session_info} 1631384321bSSushil Singh Run Keyword If '${reboot_flag}' == 'True' 164889a75e4SSushil Singh ... Run Keywords Redfish OBMC Reboot (off) AND 165889a75e4SSushil Singh ... Verify A Session Created With ClientID ${client_ids} ${session_info} 166c957f57fSSushil Singh 167c957f57fSSushil Singh 168c957f57fSSushil SinghSet Client Origin IP 169c957f57fSSushil Singh [Documentation] Set client origin IP. 170c957f57fSSushil Singh [Arguments] ${client_id} ${client_ip} ${status} 171c957f57fSSushil Singh 172c957f57fSSushil Singh # Description of argument(s): 173c957f57fSSushil Singh # client_id This client id contain string value 174c957f57fSSushil Singh # (e.g. 12345, "EXTERNAL-CLIENT"). 175c957f57fSSushil Singh # client_ip Valid IP address 176c957f57fSSushil Singh # status HTTP status code 177c957f57fSSushil Singh 178c957f57fSSushil Singh ${session}= Run Keyword And Return Status 179c957f57fSSushil Singh ... Redfish Login 180c957f57fSSushil Singh ... kwargs= "Oem":{"OpenBMC": {"ClientID":"${client_id}", "ClientOriginIP":"${client_ip}"}} 181c957f57fSSushil Singh Valid Value session [${status}] 182c957f57fSSushil Singh 183c957f57fSSushil Singh 184c957f57fSSushil SinghCreate Session And Fail To Set Client Origin IP 185c957f57fSSushil Singh [Documentation] Create redifish session with client id and fail to set client origin IP. 186c957f57fSSushil Singh [Arguments] ${client_id} 187c957f57fSSushil Singh 188c957f57fSSushil Singh # Description of argument(s): 189c957f57fSSushil Singh # client_id This client id contain string value 190c957f57fSSushil Singh # (e.g. 12345, "EXTERNAL-CLIENT"). 191c957f57fSSushil Singh 192c957f57fSSushil Singh Set Test Variable ${client_ip} 10.6.7.8 193c957f57fSSushil Singh ${resp}= Set Client Origin IP ${client_id} ${client_ip} status=False 194*4ec68ba8SSushil Singh 195*4ec68ba8SSushil Singh 196*4ec68ba8SSushil SinghCreate A Non Admin Session With ClientID 197*4ec68ba8SSushil Singh [Documentation] Create redifish session with client id. 198*4ec68ba8SSushil Singh [Arguments] ${client_id} ${username} ${password} 199*4ec68ba8SSushil Singh 200*4ec68ba8SSushil Singh # Description of argument(s): 201*4ec68ba8SSushil Singh # client_id This client id can contain string value 202*4ec68ba8SSushil Singh # (e.g. 12345, "EXTERNAL-CLIENT"). 203*4ec68ba8SSushil Singh 204*4ec68ba8SSushil Singh @{session_list}= Create List 205*4ec68ba8SSushil Singh &{tmp_dict}= Create Dictionary 206*4ec68ba8SSushil Singh 207*4ec68ba8SSushil Singh FOR ${client} IN @{client_id} 208*4ec68ba8SSushil Singh ${resp}= Redfish Login rest_username=${username} rest_password=${password} kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client}"}} 209*4ec68ba8SSushil Singh Append To List ${session_list} ${resp} 210*4ec68ba8SSushil Singh END 211*4ec68ba8SSushil Singh 212*4ec68ba8SSushil Singh [Return] ${session_list} 213*4ec68ba8SSushil Singh 214*4ec68ba8SSushil Singh 215*4ec68ba8SSushil SinghVerify A Non Admin Session Created With ClientID 216*4ec68ba8SSushil Singh [Documentation] Verify session created with client id. 217*4ec68ba8SSushil Singh [Arguments] ${client_ids} ${session_ids} 218*4ec68ba8SSushil Singh 219*4ec68ba8SSushil Singh # Description of argument(s): 220*4ec68ba8SSushil Singh # client_id External client name. 221*4ec68ba8SSushil Singh # session_id This value is a session id. 222*4ec68ba8SSushil Singh 223*4ec68ba8SSushil Singh # { 224*4ec68ba8SSushil Singh # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ", 225*4ec68ba8SSushil Singh # "@odata.type": "#Session.v1_0_2.Session", 226*4ec68ba8SSushil Singh # "Description": "Manager User Session", 227*4ec68ba8SSushil Singh # "Id": "H8q2ZKucSJ", 228*4ec68ba8SSushil Singh # "Name": "User Session", 229*4ec68ba8SSushil Singh # "Oem": { 230*4ec68ba8SSushil Singh # "OpenBMC": { 231*4ec68ba8SSushil Singh # "@odata.type": "#OemSession.v1_0_0.Session", 232*4ec68ba8SSushil Singh # "ClientID": "", 233*4ec68ba8SSushil Singh # "ClientOriginIP": "::ffff:x.x.x.x" 234*4ec68ba8SSushil Singh # } 235*4ec68ba8SSushil Singh # }, 236*4ec68ba8SSushil Singh # "UserName": "root" 237*4ec68ba8SSushil Singh # } 238*4ec68ba8SSushil Singh 239*4ec68ba8SSushil Singh FOR ${client} IN @{client_ids} 240*4ec68ba8SSushil Singh ${session_id}= Get Session Information By ClientID ${client} ${session_ids} 241*4ec68ba8SSushil Singh ${resp}= Redfish Get Request /redfish/v1/SessionService/Sessions/${session_id} 242*4ec68ba8SSushil Singh ${sessions}= To Json ${resp.content} 243*4ec68ba8SSushil Singh #Set Test Variable ${sessions} ${content["data"]} 244*4ec68ba8SSushil Singh Rprint Vars sessions 245*4ec68ba8SSushil Singh Log ${sessions} 246*4ec68ba8SSushil Singh @{words} = Split String ${sessions["Oem"]["OpenBMC"]["ClientOriginIP"]} : 247*4ec68ba8SSushil Singh ${ip_address}= Get Running System IP 248*4ec68ba8SSushil Singh Set Test Variable ${temp_ipaddr} ${words}[-1] 249*4ec68ba8SSushil Singh Valid Value client ['${sessions["Oem"]["OpenBMC"]["ClientID"]}'] 250*4ec68ba8SSushil Singh Valid Value sessions["Id"] ['${session_id}'] 251*4ec68ba8SSushil Singh Valid Value temp_ipaddr ${ip_address} 252*4ec68ba8SSushil Singh END 253*4ec68ba8SSushil Singh 254*4ec68ba8SSushil Singh 255*4ec68ba8SSushil SinghNon Admin User To Create Session 256*4ec68ba8SSushil Singh [Documentation] Non Admin user create a session and verify the session is created. 257*4ec68ba8SSushil Singh [Arguments] ${client_id} ${username} ${password} ${role} ${enabled}=${True} 258*4ec68ba8SSushil Singh 259*4ec68ba8SSushil Singh # Description of argument(s): 260*4ec68ba8SSushil Singh # client_id This client id contain string value 261*4ec68ba8SSushil Singh # (e.g. 12345, "EXTERNAL-CLIENT"). 262*4ec68ba8SSushil Singh # username Username. 263*4ec68ba8SSushil Singh # password Password. 264*4ec68ba8SSushil Singh # role Role of user. 265*4ec68ba8SSushil Singh # enabled Value can be True or False. 266*4ec68ba8SSushil Singh 267*4ec68ba8SSushil Singh Redfish.Login 268*4ec68ba8SSushil Singh Redfish Create User ${username} ${password} ${role} ${enabled} 269*4ec68ba8SSushil Singh Delete All Sessions 270*4ec68ba8SSushil Singh Redfish.Logout 271*4ec68ba8SSushil Singh Initialize OpenBMC rest_username=${username} rest_password=${password} 272*4ec68ba8SSushil Singh ${client_ids}= Split String ${client_id} , 273*4ec68ba8SSushil Singh ${session_info}= Create A Non Admin Session With ClientID ${client_ids} ${username} ${password} 274*4ec68ba8SSushil Singh Verify A Non Admin Session Created With ClientID ${client_ids} ${session_info} 275