1*45d841e3SSushil Singh*** Settings ***
2*45d841e3SSushil Singh
3*45d841e3SSushil SinghDocumentation     Test client identifier feature on BMC.
4*45d841e3SSushil Singh
5*45d841e3SSushil SinghResource          ../../lib/rest_client.robot
6*45d841e3SSushil SinghResource          ../../lib/openbmc_ffdc.robot
7*45d841e3SSushil SinghResource          ../../lib/resource.robot
8*45d841e3SSushil SinghResource          ../../lib/bmc_redfish_utils.robot
9*45d841e3SSushil SinghLibrary           ../../lib/bmc_network_utils.py
10*45d841e3SSushil SinghLibrary           ../../lib/gen_robot_valid.py
11*45d841e3SSushil Singh
12*45d841e3SSushil SinghSuite Setup       Redfish.Login
13*45d841e3SSushil SinghSuite Teardown    Delete All Redfish Sessions
14*45d841e3SSushil SinghTest Setup        Printn
15*45d841e3SSushil SinghTest Teardown     FFDC On Test Case Fail
16*45d841e3SSushil Singh
17*45d841e3SSushil Singh
18*45d841e3SSushil Singh*** Test Cases ***
19*45d841e3SSushil Singh
20*45d841e3SSushil SinghCreate A Session With ClientID And Verify
21*45d841e3SSushil Singh   [Documentation]  Create a session with client id and verify client id is same.
22*45d841e3SSushil Singh   [Tags]  Create_A_Session_With_ClientID_And_Verify
23*45d841e3SSushil Singh   [Template]  Create A Session With ClientID
24*45d841e3SSushil Singh
25*45d841e3SSushil Singh   # client_id
26*45d841e3SSushil Singh   12345
27*45d841e3SSushil Singh   123456
28*45d841e3SSushil Singh   EXTERNAL-CLIENT-01
29*45d841e3SSushil Singh   EXTERNAL-CLIENT-02
30*45d841e3SSushil Singh
31*45d841e3SSushil Singh*** Keywords ***
32*45d841e3SSushil Singh
33*45d841e3SSushil SinghCreate A Session With ClientID
34*45d841e3SSushil Singh    [Documentation]  Create redifish session with client id.
35*45d841e3SSushil Singh    [Arguments]  ${client_id}
36*45d841e3SSushil Singh
37*45d841e3SSushil Singh    # Description of argument(s):
38*45d841e3SSushil Singh    # client_id    This client id can contain string value
39*45d841e3SSushil Singh    #              (e.g. 12345, "EXTERNAL-CLIENT").
40*45d841e3SSushil Singh
41*45d841e3SSushil Singh    ${resp}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
42*45d841e3SSushil Singh    Verify A Session Created With ClientID  ${client_id}  ${resp['Id']}
43*45d841e3SSushil Singh
44*45d841e3SSushil Singh
45*45d841e3SSushil SinghVerify A Session Created With ClientID
46*45d841e3SSushil Singh    [Documentation]  Verify session created with client id.
47*45d841e3SSushil Singh    [Arguments]  ${client_id}  ${session_id}
48*45d841e3SSushil Singh
49*45d841e3SSushil Singh    # Description of argument(s):
50*45d841e3SSushil Singh    # client_id    External client name.
51*45d841e3SSushil Singh    # session_id   This value is a session id.
52*45d841e3SSushil Singh
53*45d841e3SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_id}
54*45d841e3SSushil Singh
55*45d841e3SSushil Singh    # {
56*45d841e3SSushil Singh    #   "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ",
57*45d841e3SSushil Singh    #   "@odata.type": "#Session.v1_0_2.Session",
58*45d841e3SSushil Singh    #   "Description": "Manager User Session",
59*45d841e3SSushil Singh    #   "Id": "H8q2ZKucSJ",
60*45d841e3SSushil Singh    #   "Name": "User Session",
61*45d841e3SSushil Singh    #   "Oem": {
62*45d841e3SSushil Singh    #   "OpenBMC": {
63*45d841e3SSushil Singh    #  "@odata.type": "#OemSession.v1_0_0.Session",
64*45d841e3SSushil Singh    #  "ClientID": "",
65*45d841e3SSushil Singh    #  "ClientOriginIP": "::ffff:x.x.x.x"
66*45d841e3SSushil Singh    #       }
67*45d841e3SSushil Singh    #     },
68*45d841e3SSushil Singh    #   "UserName": "root"
69*45d841e3SSushil Singh    # }
70*45d841e3SSushil Singh
71*45d841e3SSushil Singh    Rprint Vars  sessions
72*45d841e3SSushil Singh    @{words} =  Split String  ${sessions["Oem"]["OpenBMC"]["ClientOriginIP"]}  :
73*45d841e3SSushil Singh    ${ipaddr}=  Get Running System IP
74*45d841e3SSushil Singh    Set Test Variable  ${temp_ipaddr}  ${words}[-1]
75*45d841e3SSushil Singh    Valid Value  client_id  ['${sessions["Oem"]["OpenBMC"]["ClientID"]}']
76*45d841e3SSushil Singh    Valid Value  sessions["Id"]  ['${session_id}']
77*45d841e3SSushil Singh    Valid Value  temp_ipaddr  ${ipaddr}
78