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 9*ca49ced3SSushil SinghResource ../../lib/external_intf/management_console_utils.robot 1045d841e3SSushil SinghLibrary ../../lib/bmc_network_utils.py 1145d841e3SSushil SinghLibrary ../../lib/gen_robot_valid.py 1245d841e3SSushil Singh 1345d841e3SSushil SinghSuite Setup Redfish.Login 14889a75e4SSushil SinghSuite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions 1545d841e3SSushil SinghTest Setup Printn 1645d841e3SSushil SinghTest Teardown FFDC On Test Case Fail 1745d841e3SSushil Singh 1845d841e3SSushil Singh 1945d841e3SSushil Singh*** Test Cases *** 2045d841e3SSushil Singh 2145d841e3SSushil SinghCreate A Session With ClientID And Verify 2245d841e3SSushil Singh [Documentation] Create a session with client id and verify client id is same. 2345d841e3SSushil Singh [Tags] Create_A_Session_With_ClientID_And_Verify 241384321bSSushil Singh [Template] Create And Verify Session ClientID 2545d841e3SSushil Singh 26889a75e4SSushil Singh # client_id reboot_flag 271384321bSSushil Singh 12345 False 281384321bSSushil Singh 123456 False 291384321bSSushil Singh EXTERNAL-CLIENT-01 False 301384321bSSushil Singh EXTERNAL-CLIENT-02 False 311384321bSSushil Singh 321384321bSSushil Singh 331384321bSSushil SinghCheck ClientID Persistency On BMC Reboot 341384321bSSushil Singh [Documentation] Create a session with client id and verify client id is same after the reboot. 351384321bSSushil Singh [Tags] Check_ClientID_Persistency_On_BMC_Reboot 361384321bSSushil Singh [Template] Create And Verify Session ClientID 371384321bSSushil Singh 38889a75e4SSushil Singh # client_id reboot_flag 391384321bSSushil Singh 12345 True 401384321bSSushil Singh EXTERNAL-CLIENT-01 True 4145d841e3SSushil Singh 42889a75e4SSushil Singh 43889a75e4SSushil SinghCreate A Multiple Session With ClientID And Verify 44889a75e4SSushil Singh [Documentation] Create a multiple session with client id and verify client id is same. 45889a75e4SSushil Singh [Tags] Create_A_Multiple_Session_With_ClientID_And_Verify 46889a75e4SSushil Singh [Template] Create And Verify Session ClientID 47889a75e4SSushil Singh 48889a75e4SSushil Singh # client_id reboot_flag 49889a75e4SSushil Singh 12345,123456 False 50889a75e4SSushil Singh EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 False 51889a75e4SSushil Singh 52889a75e4SSushil Singh 53889a75e4SSushil SinghCheck Multiple ClientID Persistency On BMC Reboot 54889a75e4SSushil Singh [Documentation] Create a multiple session with client id and verify client id is same after the reboot. 55889a75e4SSushil Singh [Tags] Check_Multiple_ClientID_Persistency_On_BMC_Reboot 56889a75e4SSushil Singh [Template] Create And Verify Session ClientID 57889a75e4SSushil Singh 58889a75e4SSushil Singh # client_id reboot_flag 59889a75e4SSushil Singh 12345,123456 True 60889a75e4SSushil Singh EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 True 61889a75e4SSushil Singh 62889a75e4SSushil Singh 63c957f57fSSushil SinghFail To Set Client Origin IP 64c957f57fSSushil Singh [Documentation] Fail to set the client origin IP. 65c957f57fSSushil Singh [Tags] Fail_To_Set_Client_Origin_IP 66c957f57fSSushil Singh [Template] Create Session And Fail To Set Client Origin IP 67c957f57fSSushil Singh 68c957f57fSSushil Singh # client_id 69c957f57fSSushil Singh 12345 70c957f57fSSushil Singh EXTERNAL-CLIENT-01 71c957f57fSSushil Singh 724ec68ba8SSushil Singh 734ec68ba8SSushil SinghCreate Session For Non Admin User 744ec68ba8SSushil Singh [Documentation] Create Session for non-admin user. 754ec68ba8SSushil Singh [Tags] Create_Session_For_Non_Admin_User 764ec68ba8SSushil Singh [Template] Non Admin User To Create Session 774ec68ba8SSushil Singh 784ec68ba8SSushil Singh # client_id username password role_id 794ec68ba8SSushil Singh 12345 operator_user TestPwd123 Operator 804ec68ba8SSushil Singh 814ec68ba8SSushil Singh 8245d841e3SSushil Singh*** Keywords *** 8345d841e3SSushil Singh 841384321bSSushil SinghCreate And Verify Session ClientID 851384321bSSushil Singh [Documentation] Create redifish session with client id and verify it remain same. 861384321bSSushil Singh [Arguments] ${client_id} ${reboot_flag}=False 871384321bSSushil Singh 881384321bSSushil Singh # Description of argument(s): 891384321bSSushil Singh # client_id This client id contain string value 901384321bSSushil Singh # (e.g. 12345, "EXTERNAL-CLIENT"). 911384321bSSushil Singh # reboot_flag Flag is used to run reboot the BMC code. 921384321bSSushil Singh # (e.g. True or False). 931384321bSSushil Singh 94889a75e4SSushil Singh ${client_ids}= Split String ${client_id} , 9587e984c8SSushil Singh ${session_info}= Create Session With List Of ClientID ${client_ids} 96889a75e4SSushil Singh Verify A Session Created With ClientID ${client_ids} ${session_info} 971384321bSSushil Singh Run Keyword If '${reboot_flag}' == 'True' 98889a75e4SSushil Singh ... Run Keywords Redfish OBMC Reboot (off) AND 99889a75e4SSushil Singh ... Verify A Session Created With ClientID ${client_ids} ${session_info} 10087e984c8SSushil Singh Redfish Delete List Of Session ${session_info} 101c957f57fSSushil Singh 102c957f57fSSushil Singh 103c957f57fSSushil SinghSet Client Origin IP 104c957f57fSSushil Singh [Documentation] Set client origin IP. 105c957f57fSSushil Singh [Arguments] ${client_id} ${client_ip} ${status} 106c957f57fSSushil Singh 107c957f57fSSushil Singh # Description of argument(s): 108c957f57fSSushil Singh # client_id This client id contain string value 109c957f57fSSushil Singh # (e.g. 12345, "EXTERNAL-CLIENT"). 110c957f57fSSushil Singh # client_ip Valid IP address 111c957f57fSSushil Singh # status HTTP status code 112c957f57fSSushil Singh 113c957f57fSSushil Singh ${session}= Run Keyword And Return Status 114c957f57fSSushil Singh ... Redfish Login 115c957f57fSSushil Singh ... kwargs= "Oem":{"OpenBMC": {"ClientID":"${client_id}", "ClientOriginIP":"${client_ip}"}} 116c957f57fSSushil Singh Valid Value session [${status}] 117c957f57fSSushil Singh 118c957f57fSSushil Singh 119c957f57fSSushil SinghCreate Session And Fail To Set Client Origin IP 120c957f57fSSushil Singh [Documentation] Create redifish session with client id and fail to set client origin IP. 121c957f57fSSushil Singh [Arguments] ${client_id} 122c957f57fSSushil Singh 123c957f57fSSushil Singh # Description of argument(s): 124c957f57fSSushil Singh # client_id This client id contain string value 125c957f57fSSushil Singh # (e.g. 12345, "EXTERNAL-CLIENT"). 126c957f57fSSushil Singh 127c957f57fSSushil Singh Set Test Variable ${client_ip} 10.6.7.8 128c957f57fSSushil Singh ${resp}= Set Client Origin IP ${client_id} ${client_ip} status=False 1294ec68ba8SSushil Singh 1304ec68ba8SSushil Singh 1314ec68ba8SSushil SinghCreate A Non Admin Session With ClientID 1324ec68ba8SSushil Singh [Documentation] Create redifish session with client id. 1334ec68ba8SSushil Singh [Arguments] ${client_id} ${username} ${password} 1344ec68ba8SSushil Singh 1354ec68ba8SSushil Singh # Description of argument(s): 1364ec68ba8SSushil Singh # client_id This client id can contain string value 1374ec68ba8SSushil Singh # (e.g. 12345, "EXTERNAL-CLIENT"). 1384ec68ba8SSushil Singh 1394ec68ba8SSushil Singh @{session_list}= Create List 1404ec68ba8SSushil Singh &{tmp_dict}= Create Dictionary 1414ec68ba8SSushil Singh 1424ec68ba8SSushil Singh FOR ${client} IN @{client_id} 1434ec68ba8SSushil Singh ${resp}= Redfish Login rest_username=${username} rest_password=${password} kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client}"}} 1444ec68ba8SSushil Singh Append To List ${session_list} ${resp} 1454ec68ba8SSushil Singh END 1464ec68ba8SSushil Singh 1474ec68ba8SSushil Singh [Return] ${session_list} 1484ec68ba8SSushil Singh 1494ec68ba8SSushil Singh 1504ec68ba8SSushil SinghVerify A Non Admin Session Created With ClientID 1514ec68ba8SSushil Singh [Documentation] Verify session created with client id. 1524ec68ba8SSushil Singh [Arguments] ${client_ids} ${session_ids} 1534ec68ba8SSushil Singh 1544ec68ba8SSushil Singh # Description of argument(s): 15587e984c8SSushil Singh # client_ids External client name. 15687e984c8SSushil Singh # session_ids This value is a session id. 1574ec68ba8SSushil Singh 1584ec68ba8SSushil Singh # { 1594ec68ba8SSushil Singh # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ", 1604ec68ba8SSushil Singh # "@odata.type": "#Session.v1_0_2.Session", 1614ec68ba8SSushil Singh # "Description": "Manager User Session", 1624ec68ba8SSushil Singh # "Id": "H8q2ZKucSJ", 1634ec68ba8SSushil Singh # "Name": "User Session", 1644ec68ba8SSushil Singh # "Oem": { 1654ec68ba8SSushil Singh # "OpenBMC": { 1664ec68ba8SSushil Singh # "@odata.type": "#OemSession.v1_0_0.Session", 1674ec68ba8SSushil Singh # "ClientID": "", 1684ec68ba8SSushil Singh # "ClientOriginIP": "::ffff:x.x.x.x" 1694ec68ba8SSushil Singh # } 1704ec68ba8SSushil Singh # }, 1714ec68ba8SSushil Singh # "UserName": "root" 1724ec68ba8SSushil Singh # } 1734ec68ba8SSushil Singh 17487e984c8SSushil Singh FOR ${client} ${session} IN ZIP ${client_ids} ${session_ids} 17587e984c8SSushil Singh ${resp}= Redfish Get Request /redfish/v1/SessionService/Sessions/${session["Id"]} 1764ec68ba8SSushil Singh ${sessions}= To Json ${resp.content} 1774ec68ba8SSushil Singh Rprint Vars sessions 17824e32afaSSushil Singh @{words} = Split String ${sessions["ClientOriginIPAddress"]} : 1794ec68ba8SSushil Singh ${ip_address}= Get Running System IP 1804ec68ba8SSushil Singh Set Test Variable ${temp_ipaddr} ${words}[-1] 1814ec68ba8SSushil Singh Valid Value client ['${sessions["Oem"]["OpenBMC"]["ClientID"]}'] 18287e984c8SSushil Singh Valid Value session["Id"] ['${sessions["Id"]}'] 1834ec68ba8SSushil Singh Valid Value temp_ipaddr ${ip_address} 1844ec68ba8SSushil Singh END 1854ec68ba8SSushil Singh 1864ec68ba8SSushil Singh 1874ec68ba8SSushil SinghNon Admin User To Create Session 1884ec68ba8SSushil Singh [Documentation] Non Admin user create a session and verify the session is created. 1894ec68ba8SSushil Singh [Arguments] ${client_id} ${username} ${password} ${role} ${enabled}=${True} 1904ec68ba8SSushil Singh 1914ec68ba8SSushil Singh # Description of argument(s): 1924ec68ba8SSushil Singh # client_id This client id contain string value 1934ec68ba8SSushil Singh # (e.g. 12345, "EXTERNAL-CLIENT"). 1944ec68ba8SSushil Singh # username Username. 1954ec68ba8SSushil Singh # password Password. 1964ec68ba8SSushil Singh # role Role of user. 1974ec68ba8SSushil Singh # enabled Value can be True or False. 1984ec68ba8SSushil Singh 1994ec68ba8SSushil Singh Redfish.Login 2004ec68ba8SSushil Singh Redfish Create User ${username} ${password} ${role} ${enabled} 2014ec68ba8SSushil Singh Delete All Sessions 2024ec68ba8SSushil Singh Redfish.Logout 2034ec68ba8SSushil Singh Initialize OpenBMC rest_username=${username} rest_password=${password} 2044ec68ba8SSushil Singh ${client_ids}= Split String ${client_id} , 2054ec68ba8SSushil Singh ${session_info}= Create A Non Admin Session With ClientID ${client_ids} ${username} ${password} 2064ec68ba8SSushil Singh Verify A Non Admin Session Created With ClientID ${client_ids} ${session_info} 207