LDAP additional test cases

Verify LDAP Valid Group Name Update
- Valid
- Invalid

Resolves openbmc/openbmc-test-automation#1895

Change-Id: If73e65009e71e8869efcbcca1b1968037249075a
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/redfish/account_service/test_ldap_configuration.robot b/redfish/account_service/test_ldap_configuration.robot
index e02c6aa..907db7b 100644
--- a/redfish/account_service/test_ldap_configuration.robot
+++ b/redfish/account_service/test_ldap_configuration.robot
@@ -210,8 +210,50 @@
     Callback
 
 
+Update LDAP Group Name And Verify Operations
+    [Documentation]  Verify LDAP group name update and able to do right operations.
+    [Tags]  Update_LDAP_Group_Name_And_Verify_Operations
+    [Template]  Update LDAP Config And Verify Set Host Name
+    [Teardown]  Restore LDAP Privilege
+
+    # group_name             group_privilege  valid_status_codes
+    ${GROUP_NAME}            Administrator    [${HTTP_OK}]
+    ${GROUP_NAME}            Operator         [${HTTP_UNAUTHORIZED}, ${HTTP_FORBIDDEN}]
+    ${GROUP_NAME}            User             [${HTTP_UNAUTHORIZED}, ${HTTP_FORBIDDEN}]
+    ${GROUP_NAME}            Callback         [${HTTP_UNAUTHORIZED}, ${HTTP_FORBIDDEN}]
+    Invalid_LDAP_Group_Name  Administrator    [${HTTP_UNAUTHORIZED}, ${HTTP_FORBIDDEN}]
+    Invalid_LDAP_Group_Name  Operator         [${HTTP_UNAUTHORIZED}, ${HTTP_FORBIDDEN}]
+    Invalid_LDAP_Group_Name  User             [${HTTP_UNAUTHORIZED}, ${HTTP_FORBIDDEN}]
+    Invalid_LDAP_Group_Name  Callback         [${HTTP_UNAUTHORIZED}, ${HTTP_FORBIDDEN}]
+
+
 *** Keywords ***
 
+Update LDAP Config And Verify Set Host Name
+    [Documentation]  Update LDAP config and verify by attempting to set host name.
+    [Arguments]  ${group_name}  ${group_privilege}=Administrator
+    ...  ${valid_status_codes}=[${HTTP_OK}]
+
+    # Description of argument(s):
+    # group_name                    The group name of user.
+    # group_privilege               The group privilege ("Administrator",
+    #                               "Operator", "User" or "Callback").
+    # valid_status_codes            Expected return code(s) from patch
+    #                               operation (e.g. "200") used to update
+    #                               HostName.  See prolog of rest_request
+    #                               method in redfish_plut.py for details.
+    Update LDAP Configuration with LDAP User Role And Group  ${LDAP_TYPE}
+    ...  ${group_privilege}  ${group_name}
+    Redfish.Login  ${LDAP_USER}  ${LDAP_USER_PASSWORD}
+    # Verify that the LDAP user in ${group_name} with the given privilege is
+    # allowed to change the hostname.
+    ${hostname}=  Redfish_Utils.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  HostName
+    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'HostName': '${hostname}'}
+    ...  valid_status_codes=${valid_status_codes}
+    Redfish.Logout
+    Redfish.Login
+
+
 Disable Other LDAP
     [Documentation]  Disable other LDAP configuration.
 
@@ -284,6 +326,11 @@
     Rvalid Value  LDAP_USER_PASSWORD
     Rvalid Value  GROUP_PRIVILEGE
     Rvalid Value  GROUP_NAME
+    Rvalid Value  LDAP_SERVER_URI
+    Rvalid Value  LDAP_BIND_DN_PASSWORD
+    Rvalid Value  LDAP_BIND_DN
+    Rvalid Value  LDAP_BASE_DN
+
     Redfish.Login
     # Call 'Get LDAP Configuration' to verify that LDAP configuration exists.
     Get LDAP Configuration  ${LDAP_TYPE}
@@ -358,6 +405,9 @@
     [Documentation]  Get LDAP privilege and return it.
 
     ${ldap_config}=  Get LDAP Configuration  ${LDAP_TYPE}
+    ${num_list_entries}=  Get Length  ${ldap_config["RemoteRoleMapping"]}
+    Return From Keyword If  ${num_list_entries} == ${0}  @{EMPTY}
+
     [Return]  ${ldap_config["RemoteRoleMapping"][0]["LocalRole"]}