Added a testcase to verify LDAP user with admin privilege
Change-Id: I262c70218b50dedf6945ac67b0f7e041369ab48e
Signed-off-by: Anves Kumar rayankula <anvesr77@in.ibm.com>
diff --git a/lib/bmc_ldap_utils.robot b/lib/bmc_ldap_utils.robot
new file mode 100644
index 0000000..a5d2a8d
--- /dev/null
+++ b/lib/bmc_ldap_utils.robot
@@ -0,0 +1,61 @@
+*** Settings ***
+Documentation This module provides general keywords for LDAP.
+
+*** Keywords ***
+
+Get LDAP Configuration Using Redfish
+ [Documentation] Retrieve LDAP Configuration.
+ [Arguments] ${ldap_type}
+
+ # Description of argument(s):
+ # ldap_type The LDAP type ("ActiveDirectory" or "LDAP").
+
+ ${ldap_config}= Redfish.Get Properties ${REDFISH_BASE_URI}AccountService
+ [Return] ${ldap_config["${ldap_type}"]}
+
+
+Get LDAP Privilege And Group Name Via Redfish
+ [Documentation] Get LDAP groupname via Redfish.
+
+ # Get LDAP configuration via Redfish.
+ # Sample output of LDAP configuration:
+ # {
+ # 'RemoteRoleMapping': [
+ # {
+ # 'RemoteGroup': 'openldapgroup',
+ # 'LocalRole': 'Administrator'
+ # },
+ # ],
+ # 'Authentication':
+ # {
+ # 'Username': 'cn=Administrator,dc=ldap,dc=com',
+ # 'Password': None,
+ # 'AuthenticationType': 'UsernameAndPassword'
+ # },
+ # 'LDAPService':
+ # {
+ # 'SearchSettings':
+ # {
+ # 'BaseDistinguishedNames': ['dc=ldap,dc=com'],
+ # 'UsernameAttribute': 'cn',
+ # 'GroupsAttribute': 'gidNumber'
+ # }
+ # },
+ # 'ServiceEnabled': True,
+ # 'Certificates':
+ # {
+ # '@odata.id': u'/redfish/v1/AccountService/LDAP/Certificates'
+ # },
+ # 'ServiceAddresses': ['ldap://xx.xx.xx.xx/']
+ # }
+
+ ${ldap_config}= Get LDAP Configuration Using Redfish ${LDAP_TYPE}
+ ${num_list_entries}= Get Length ${ldap_config["RemoteRoleMapping"]}
+ Return From Keyword If ${num_list_entries} == ${0} @{EMPTY}
+ ${ldap_group_names}= Create List
+ FOR ${i} IN RANGE ${num_list_entries}
+ Append To List ${ldap_group_names} ${ldap_config["RemoteRoleMapping"][${i}]["RemoteGroup"]}
+ END
+
+ [Return] ${ldap_group_names}
+