Added test to verify error while creating more than max user limit

Change-Id: Ic78b956fde379e044aa9b3dc0ad1aa16ede58529
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/ipmi/test_ipmi_user.robot b/ipmi/test_ipmi_user.robot
index 783cde1..2a64c4f 100644
--- a/ipmi/test_ipmi_user.robot
+++ b/ipmi/test_ipmi_user.robot
@@ -427,16 +427,6 @@
     ...  L=${privilege}
 
 
-Delete All Non Root IPMI User
-    [Documentation]  Delete all non-root IPMI user.
-
-    FOR  ${userid}  IN RANGE  2  16
-      ${user_info}=  Get User Info  ${userid}
-      Run Keyword If  "${user_info['user_name']}" != ""
-      ...  Run IPMI Standard Command  user set name ${userid} ""
-    END
-
-
 Test Teardown Execution
     [Documentation]  Do the test teardown execution.
 
diff --git a/lib/ipmi_client.robot b/lib/ipmi_client.robot
index 63179a2..1fba459 100755
--- a/lib/ipmi_client.robot
+++ b/lib/ipmi_client.robot
@@ -408,3 +408,13 @@
     ...  channel setaccess${SPACE}${channel}${SPACE}${userid}
     ...  ${SPACE}${options}
     Run IPMI Standard Command  ${ipmi_cmd}
+
+
+Delete All Non Root IPMI User
+    [Documentation]  Delete all non-root IPMI user.
+
+    FOR  ${userid}  IN RANGE  2  16
+      ${user_info}=  Get User Info  ${userid}
+      Run Keyword If  "${user_info['user_name']}" != ""
+      ...  Run IPMI Standard Command  user set name ${userid} ""
+    END
diff --git a/redfish/account_service/test_ipmi_redfish_user.robot b/redfish/account_service/test_ipmi_redfish_user.robot
index 35b82dc..808f221 100644
--- a/redfish/account_service/test_ipmi_redfish_user.robot
+++ b/redfish/account_service/test_ipmi_redfish_user.robot
@@ -17,6 +17,7 @@
 ${valid_password2}      0penBmc2
 ${admin_level_priv}     4
 ${operator_level_priv}  3
+${max_num_users}        ${15}
 
 ** Test Cases **
 
@@ -179,6 +180,33 @@
     ...  Redfish.Login  ${username}  ${valid_password}
 
 
+Verify Failure To Exceed Max Number Of Users
+    [Documentation]  Verify failure attempting to exceed the max number of user accounts.
+    [Tags]  Verify_Failure_To_Exceed_Max_Number_Of_Users
+    [Teardown]  Run Keywords  Test Teardown Execution  AND  Delete All Non Root IPMI User
+
+    # Get existing user count.
+    ${resp}=  Redfish.Get  /redfish/v1/AccountService/Accounts/
+    ${current_user_count}=  Get From Dictionary  ${resp.dict}  Members@odata.count
+
+    ${payload}=  Create Dictionary  Password=${valid_password}
+    ...  RoleId=Administrator  Enabled=${True}
+
+    # Create users to reach maximum users count (i.e. 15 users).
+    FOR  ${INDEX}  IN RANGE  ${current_user_count}  ${max_num_users}
+      ${random_username}=  Generate Random String  8  [LETTERS]
+      Set To Dictionary  ${payload}  UserName  ${random_username}
+      Redfish.Post  ${REDFISH_ACCOUNTS_URI}  body=&{payload}
+      ...  valid_status_codes=[${HTTP_CREATED}]
+    END
+
+    # Verify error while creating 16th user.
+    ${random_username}=  Generate Random String  8  [LETTERS]
+    Set To Dictionary  ${payload}  UserName  ${random_username}
+    Redfish.Post  ${REDFISH_ACCOUNTS_URI}  body=&{payload}
+    ...  valid_status_codes=[${HTTP_BAD_REQUEST}]
+
+
 *** Keywords ***
 
 IPMI Create Random User Plus Password And Privilege