Added create and delete LDAP group test cases

- Verify User Group And Privilege Created
- Delete LDAP Group

Change-Id: I458afee74117df6040967d4be57e09cca5e17f9e
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/lib/user_utils.robot b/lib/user_utils.robot
index 893dd72..df39392 100644
--- a/lib/user_utils.robot
+++ b/lib/user_utils.robot
@@ -2,44 +2,17 @@
 Documentation   OpenBMC user management keywords.
 
 Resource         ../lib/rest_client.robot
-Resource         ../lib/openbmc_ffdc.robot
 Resource         ../lib/utils.robot
 Library          SSHLibrary
 
-Test Teardown    Test Teardown Execution
-
-*** Variables ****
-
-${test_password}   0penBmc123
-
 *** Keywords ***
 
-Test Teardown Execution
-    [Documentation]  Do test teardown task.
-
-    # REST Login to BMC with new "root" password.
-    Initialize OpenBMC  REST_PASSWORD=${test_password}
-    Update Root Password
-    Sleep  5 s
-    Delete All Sessions
-
-    # SSH Login to BMC with user default "root" password.
-    SSHLibrary.Open Connection  ${OPENBMC_HOST}
-    Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
-
-    # REST Login to BMC with user default "root" password.
-    Initialize OpenBMC
-
-    FFDC On Test Case Fail
-    Close All Connections
-
-
 Create Group And Privilege
     [Documentation]  Create group and privilege for users.
     [Arguments]  ${user_group}  ${user_privilege}
 
     # Description of argument(s):
-    # user_group  User group.
+    # user_group      User group.
     # user_privilege  User privilege like priv-admin, priv-user.
 
     @{ldap_parm_list}=  Create List  ${user_group}  ${user_privilege}
@@ -56,7 +29,7 @@
     [Documentation]  Create privilege as priv-admin.
     [Arguments]  ${user_privilege}
 
-    Create Group And Privilege  ${GROUP_NAME}  ${user_privilege}
+    Create Group And Privilege  ${group_name}=${GROUP_NAME}  ${user_privilege}
     ${bmc_user_uris}=  Read Properties  ${BMC_USER_URI}ldap/enumerate
     # Sample output:
     # "data": {
@@ -119,7 +92,8 @@
     [Arguments]  ${ldap_server_uri}=${LDAP_SERVER_URI}
 
     # Description of argument(s):
-    # ldap_server_uri  The LDAP server uri (e.g. "ldap://x.x.x.x/" for non-secured or ""ldaps://x.x.x.x/"" for secured).
+    # ldap_server_uri  The LDAP server uri (e.g. "ldap://x.x.x.x/" for non-secured or
+    # ""ldaps://x.x.x.x/"" for secured).
 
     ${ldap_server_config}=  Read Properties  ${BMC_USER_URI}ldap/enumerate
     ${ldap_server_config}=  Convert To String  ${ldap_server_config}
@@ -194,7 +168,7 @@
     [Arguments]  ${user_group}
 
     # Description of argument(s):
-    # user_group(s)   contain LDAP user group string. Example: "Domain Admins"
+    # user_group  A space-delimited list of user group (e.g. "Domain Admins").
 
     @{ldap_entries}=  Get LDAP Entries
 
@@ -206,6 +180,7 @@
 
     Fail  No ${user_group} LDAP user group entry found.
 
+
 Delete Defined LDAP Group And Privilege
     [Documentation]  Delete LDAP group and its privilege.
     [Arguments]  ${user_group}
diff --git a/tests_ldap/test_user_ldap_management.robot b/tests_ldap/test_user_ldap_management.robot
index e601d1e..0062e60 100644
--- a/tests_ldap/test_user_ldap_management.robot
+++ b/tests_ldap/test_user_ldap_management.robot
@@ -3,6 +3,7 @@
 
 Resource         ../lib/rest_client.robot
 Resource         ../lib/openbmc_ffdc.robot
+Resource         ../lib/user_utils.robot
 Library          ../lib/bmc_ssh_utils.py
 
 Suite Setup      Suite Setup Execution
@@ -20,6 +21,17 @@
     Should Be Empty  ${resp}
 
 
+Verify User Group And Privilege Created
+    [Documentation]  Verify user group and associated privilege is created.
+    [Tags]  Verify_User_Group_And_Privilege_Created
+    [Teardown]  FFDC On Test Case Fail
+
+    Create Group And Privilege  ${GROUP_NAME}  ${GROUP_PRIVILEGE}
+    ${bmc_user_uris}=  Read Properties  ${BMC_USER_URI}ldap/enumerate
+    ${bmc_user_uris}=  Convert To String  ${bmc_user_uris}
+    Should Contain  ${bmc_user_uris}  ${GROUP_NAME}
+    Should Contain  ${bmc_user_uris}  ${GROUP_PRIVILEGE}
+
 Verify LDAP Config Is Created
     [Documentation]  Verify LDAP config is created in BMC.
     [Tags]  Verify_LDAP_Config_Is_Created
@@ -152,97 +164,8 @@
     ...  verify=${True}  expected_value=${LDAP_BIND_DN_PASSWORD}
 
 
-*** Keywords ***
+Delete LDAP Group
+    [Documentation]  Delete LDAP group which is configured.
+    [Tags]  Delete_LDAP_Group
 
-Suite Setup Execution
-    [Documentation]  Check for LDAP test readiness.
-
-    Should Not Be Empty  ${LDAP_SERVER_URI}
-    Should Not Be Empty  ${LDAP_BIND_DN}
-    Should Not Be Empty  ${LDAP_BASE_DN}
-    Should Not Be Empty  ${LDAP_BIND_DN_PASSWORD}
-    Should Not Be Empty  ${LDAP_SEARCH_SCOPE}
-    Should Not Be Empty  ${LDAP_SERVER_TYPE}
-
-Check LDAP Service Running
-    [Documentation]  Check LDAP service running in BMC.
-
-    BMC Execute Command  systemctl | grep -in ldap
-
-
-Configure LDAP Server On BMC
-    [Documentation]  Configure LDAP Server On BMC.
-
-    ${LDAP_SECURE_MODE}=  Convert To Boolean  ${LDAP_SECURE_MODE}
-
-    @{ldap_parm_list}=  Create List
-    ...  ${LDAP_SERVER_URI}  ${LDAP_BIND_DN}
-    ...  ${LDAP_BASE_DN}  ${LDAP_BIND_DN_PASSWORD}  ${LDAP_SEARCH_SCOPE}
-    ...  ${LDAP_SERVER_TYPE}
-
-    ${data}=  Create Dictionary  data=@{ldap_parm_list}
-
-    ${resp}=  OpenBMC Post Request
-    ...  ${BMC_LDAP_URI}/action/CreateConfig  data=${data}
-    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
-
-
-Check LDAP Config File Generated
-    [Documentation]  Check LDAP file nslcd.conf generated.
-    [Arguments]  ${ldap_server}=${LDAP_SERVER_URI}
-
-    # Description of argument(s):
-    # Non-Secured ldap_server  Contains ldap server URI eg. (e.g. "ldap://x.x.x.x/").
-    # Secured ldap_server  Contains ldap server URI eg. (e.g. "ldaps://x.x.x.x/").
-
-    ${ldap_server_config}=  Read Properties  ${BMC_USER_URI}ldap/enumerate
-    ${ldap_server_config}=  Convert To String  ${ldap_server_config}
-    Should Contain  ${ldap_server_config}  ${ldap_server}
-    ...  msg=${ldap_server} is not configured.
-
-
-Delete LDAP Config
-    [Documentation]  Delete LDAP Config from REST.
-
-    ${data}=  Create Dictionary  data=@{EMPTY}
-    ${resp}=  OpenBMC Post Request
-    ...  ${BMC_LDAP_URI}/config/action/delete  data=${data}
-
-    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
-
-
-Check LDAP Config File Deleted
-    [Documentation]  Check LDAP file nslcd.conf deleted.
-
-    ${ldap_server_config}=  Read Properties  ${BMC_USER_URI}ldap/enumerate
-    ${ldap_server_config}=  Convert To String  ${ldap_server_config}
-
-    Should Not Contain  ${ldap_server_config}  ${LDAP_SERVER_URI}
-    ...  msg=${ldap_server_config} is not configured.
-
-
-
-Modify LDAP Search Scope
-    [Documentation]  Modify LDAP search scope parameter in LDAP config.
-    [Arguments]  ${search_scope}=${LDAP_SEARCH_SCOPE}
-
-    # Description of argument(s):
-    # search_scope  Contains ldap search scope (e.g. "xyz.openbmc_project.User.Ldap.Config.SearchScope.one").
-
-    ${search_scope_dict}=  Create Dictionary  data=${search_scope}
-    Write Attribute  ${BMC_LDAP_URI}/config   LDAPSearchScope  data=${search_scope_dict}
-    ...  verify=${True}  expected_value=${search_scope}
-
-
-Modify LDAP Server Type
-    [Documentation]  Modify LDAP server type parameter in LDAP config.
-    [Arguments]  ${ldap_type}=${LDAP_SERVER_TYPE}
-
-    # Description of argument(s):
-    # ldap_type Contains ldap server type (e.g. "xyz.openbmc_project.User.Ldap.Config.Type.ActiveDirectory").
-
-    ${ldap_type_dict}=  Create Dictionary  data=${ldap_type}
-    Write Attribute  ${BMC_LDAP_URI}/config   LDAPType  data=${ldap_type_dict}
-    ...  verify=${True}  expected_value=${ldap_type}
-
-
+    Delete Defined LDAP Group And Privilege  ${GROUP_NAME}