Added a test case to create a session with clientid and verify
its exsistence

Changes:
   - Added test case "Create A Session With ClientID And Verify".
   - Added logic in lib to find test bed system IP(s).

Change-Id: I6f49d3c36c179bb22785352544b69ac25f46d484
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/lib/bmc_network_utils.py b/lib/bmc_network_utils.py
index a01ee78..b6e2ba0 100644
--- a/lib/bmc_network_utils.py
+++ b/lib/bmc_network_utils.py
@@ -12,10 +12,25 @@
 import collections
 import re
 import ipaddress
+import subprocess
 from robot.libraries.BuiltIn import BuiltIn
 import json
 import bmc_ssh_utils as bsu
 
+ip_regex = r"\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}"
+
+
+def get_running_system_ip():
+    r"""
+    Get the IP address of server from which robot code is running.
+    """
+
+    stdout = subprocess.check_output("ifconfig", shell=True)
+    stdout = stdout.decode("utf-8")
+    ip_list = re.findall(ip_regex, stdout)
+
+    return ip_list
+
 
 def netmask_prefix_length(netmask):
     r"""
diff --git a/openpower/ext_interfaces/test_client_identifier.robot b/openpower/ext_interfaces/test_client_identifier.robot
new file mode 100644
index 0000000..2436d75
--- /dev/null
+++ b/openpower/ext_interfaces/test_client_identifier.robot
@@ -0,0 +1,77 @@
+*** Settings ***
+
+Documentation     Test client identifier feature on BMC.
+
+Resource          ../../lib/rest_client.robot
+Resource          ../../lib/openbmc_ffdc.robot
+Resource          ../../lib/resource.robot
+Resource          ../../lib/bmc_redfish_utils.robot
+Library           ../../lib/bmc_network_utils.py
+Library           ../../lib/gen_robot_valid.py
+
+Suite Setup       Redfish.Login
+Suite Teardown    Delete All Redfish Sessions
+Test Setup        Printn
+Test Teardown     FFDC On Test Case Fail
+
+
+*** Test Cases ***
+
+Create A Session With ClientID And Verify
+   [Documentation]  Create a session with client id and verify client id is same.
+   [Tags]  Create_A_Session_With_ClientID_And_Verify
+   [Template]  Create A Session With ClientID
+
+   # client_id
+   12345
+   123456
+   EXTERNAL-CLIENT-01
+   EXTERNAL-CLIENT-02
+
+*** Keywords ***
+
+Create A Session With ClientID
+    [Documentation]  Create redifish session with client id.
+    [Arguments]  ${client_id}
+
+    # Description of argument(s):
+    # client_id    This client id can contain string value
+    #              (e.g. 12345, "EXTERNAL-CLIENT").
+
+    ${resp}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
+    Verify A Session Created With ClientID  ${client_id}  ${resp['Id']}
+
+
+Verify A Session Created With ClientID
+    [Documentation]  Verify session created with client id.
+    [Arguments]  ${client_id}  ${session_id}
+
+    # Description of argument(s):
+    # client_id    External client name.
+    # session_id   This value is a session id.
+
+    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_id}
+
+    # {
+    #   "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ",
+    #   "@odata.type": "#Session.v1_0_2.Session",
+    #   "Description": "Manager User Session",
+    #   "Id": "H8q2ZKucSJ",
+    #   "Name": "User Session",
+    #   "Oem": {
+    #   "OpenBMC": {
+    #  "@odata.type": "#OemSession.v1_0_0.Session",
+    #  "ClientID": "",
+    #  "ClientOriginIP": "::ffff:x.x.x.x"
+    #       }
+    #     },
+    #   "UserName": "root"
+    # }
+
+    Rprint Vars  sessions
+    @{words} =  Split String  ${sessions["Oem"]["OpenBMC"]["ClientOriginIP"]}  :
+    ${ipaddr}=  Get Running System IP
+    Set Test Variable  ${temp_ipaddr}  ${words}[-1]
+    Valid Value  client_id  ['${sessions["Oem"]["OpenBMC"]["ClientID"]}']
+    Valid Value  sessions["Id"]  ['${session_id}']
+    Valid Value  temp_ipaddr  ${ipaddr}