Verify LDAP Login Works When Eth1 IP Is Not Configured

changes:
     - Moved LDAP keys to lib.
     - Added new LDAP test case for multiple interfaces.

Change-Id: I843a62034268eeb890c0c15d33a3838b78654215
Signed-off-by: Anves Kumar rayankula <anvesr77@in.ibm.com>
diff --git a/lib/bmc_ldap_utils.robot b/lib/bmc_ldap_utils.robot
index a5d2a8d..867c37d 100644
--- a/lib/bmc_ldap_utils.robot
+++ b/lib/bmc_ldap_utils.robot
@@ -59,3 +59,30 @@
 
     [Return]  ${ldap_group_names}
 
+
+Create LDAP Configuration
+    [Documentation]  Create LDAP configuration.
+    [Arguments]  ${ldap_type}=${LDAP_TYPE}  ${ldap_server_uri}=${LDAP_SERVER_URI}
+    ...  ${ldap_bind_dn}=${LDAP_BIND_DN}  ${ldap_bind_dn_password}=${LDAP_BIND_DN_PASSWORD}
+    ...  ${ldap_base_dn}=${LDAP_BASE_DN}
+
+    # Description of argument(s):
+    # ldap_type              The LDAP type ("ActiveDirectory" or "LDAP").
+    # ldap_server_uri        LDAP server uri (e.g. ldap://XX.XX.XX.XX).
+    # ldap_bind_dn           The LDAP bind distinguished name.
+    # ldap_bind_dn_password  The LDAP bind distinguished name password.
+    # ldap_base_dn           The LDAP base distinguished name.
+
+    ${body}=  Catenate  {'${ldap_type}':
+    ...  {'ServiceEnabled': ${True},
+    ...   'ServiceAddresses': ['${ldap_server_uri}'],
+    ...   'Authentication':
+    ...       {'AuthenticationType': 'UsernameAndPassword',
+    ...        'Username':'${ldap_bind_dn}',
+    ...        'Password': '${ldap_bind_dn_password}'},
+    ...   'LDAPService':
+    ...       {'SearchSettings':
+    ...           {'BaseDistinguishedNames': ['${ldap_base_dn}']}}}}
+
+    Redfish.Patch  ${REDFISH_BASE_URI}AccountService  body=${body}
+    Sleep  15s
diff --git a/redfish/account_service/test_ldap_configuration.robot b/redfish/account_service/test_ldap_configuration.robot
index 2620d0a..6edd53b 100644
--- a/redfish/account_service/test_ldap_configuration.robot
+++ b/redfish/account_service/test_ldap_configuration.robot
@@ -566,34 +566,6 @@
     Sleep  15s
 
 
-Create LDAP Configuration
-    [Documentation]  Create LDAP configuration.
-    [Arguments]  ${ldap_type}=${LDAP_TYPE}  ${ldap_server_uri}=${LDAP_SERVER_URI}
-    ...  ${ldap_bind_dn}=${LDAP_BIND_DN}  ${ldap_bind_dn_password}=${LDAP_BIND_DN_PASSWORD}
-    ...  ${ldap_base_dn}=${LDAP_BASE_DN}
-
-    # Description of argument(s):
-    # ldap_type              The LDAP type ("ActiveDirectory" or "LDAP").
-    # ldap_server_uri        LDAP server uri (e.g. ldap://XX.XX.XX.XX).
-    # ldap_bind_dn           The LDAP bind distinguished name.
-    # ldap_bind_dn_password  The LDAP bind distinguished name password.
-    # ldap_base_dn           The LDAP base distinguished name.
-
-    ${body}=  Catenate  {'${ldap_type}':
-    ...  {'ServiceEnabled': ${True},
-    ...   'ServiceAddresses': ['${ldap_server_uri}'],
-    ...   'Authentication':
-    ...       {'AuthenticationType': 'UsernameAndPassword',
-    ...        'Username':'${ldap_bind_dn}',
-    ...        'Password': '${ldap_bind_dn_password}'},
-    ...   'LDAPService':
-    ...       {'SearchSettings':
-    ...           {'BaseDistinguishedNames': ['${ldap_base_dn}']}}}}
-
-    Redfish.Patch  ${REDFISH_BASE_URI}AccountService  body=${body}
-    Sleep  15s
-
-
 Config LDAP URL
     [Documentation]  Config LDAP URL.
     [Arguments]  ${ldap_server_uri}=${LDAP_SERVER_URI}  ${expected_status}=${TRUE}
diff --git a/redfish/managers/test_multiple_interfaces.robot b/redfish/managers/test_multiple_interfaces.robot
index 4a0a4b2..15b1ccf 100644
--- a/redfish/managers/test_multiple_interfaces.robot
+++ b/redfish/managers/test_multiple_interfaces.robot
@@ -11,14 +11,15 @@
 Resource        ../../lib/connection_client.robot
 Resource        ../../lib/bmc_network_utils.robot
 Resource        ../../lib/openbmc_ffdc.robot
+Resource        ../../lib/bmc_ldap_utils.robot
 
 Suite Setup     Suite Setup Execution
 Test Teardown   FFDC On Test Case Fail
-
+Suite Teardown  Run Keywords  Redfish1.Logout  AND  Redfish.Logout
 
 *** Test Cases ***
 
-Verify Both Interfaces BMC IP Addreeses Accessible Via SSH
+Verify Both Interfaces BMC IP Addresses Accessible Via SSH
     [Documentation]  Verify both interfaces (eth0, eth1) BMC IP addresses accessible via SSH.
     [Tags]  Verify_Both_Interfaces_BMC_IP_Addresses_Accessible_Via_SSH
 
@@ -47,6 +48,20 @@
     ${resp2}=  Redfish1.Get  ${REDFISH_NW_ETH_IFACE}eth1
     Should Be Equal  ${resp1.dict['HostName']}  ${resp2.dict['HostName']}
 
+
+Verify LDAP Login Works When Eth1 IP Is Not Configured
+    [Documentation]  Verify LDAP login works when eth1 IP is erased.
+    [Tags]  Verify_LDAP_Login_Works_When_Eth1_IP_Is_Not_Configured
+    [Setup]  Run Keywords  Set Test Variable  ${CHANNEL_NUMBER}  ${2}
+    ...  AND  Delete IP Address  ${OPENBMC_HOST_1}
+    [Teardown]  Run Keywords  Redfish.Login  AND
+    ...  Add IP Address  ${OPENBMC_HOST_1}  ${eth1_subnet_mask}  ${eth1_gateway}
+
+    Create LDAP Configuration
+    Redfish.Login  ${LDAP_USER}  ${LDAP_USER_PASSWORD}
+    Redfish.Logout
+
+
 *** Keywords ***
 
 Get Network Configuration Using Channel Number
@@ -72,3 +87,14 @@
     # Check both interfaces are configured and reachable.
     Ping Host  ${OPENBMC_HOST}
     Ping Host  ${OPENBMC_HOST_1}
+
+    ${network_configurations}=  Get Network Configuration Using Channel Number  ${2}
+    FOR  ${network_configuration}  IN  @{network_configurations}
+
+      Run Keyword If  '${network_configuration['Address']}' == '${OPENBMC_HOST_1}'
+      ...  Run Keywords  Set Suite Variable  ${eth1_subnet_mask}  ${network_configuration['SubnetMask']}
+      ...  AND  Set Suite Variable  ${eth1_gateway}  ${network_configuration['Gateway']}
+      ...  AND  Exit For Loop
+
+    END
+