From 0d4197e0b9262b21e20d79456ef148407cb52791 Mon Sep 17 00:00:00 2001 From: anil kumar appana Date: Thu, 13 Jun 2019 15:06:23 +0000 Subject: account_service:redfish user creation err handling Modified POST method to handle redfish user creation error codes. Tested: Tested user creation with below test cases 1)Already user exists 2)Max users reached 3)Username is NULL 4)Username is not starting with alphabet 5)Username exceed more than 16 characters 6)Invalid Password Redfish validator test results: Passed Signed-off-by: anil kumar appana Change-Id: I58361ddd4dfd067802f805f9d870b2bc1692ea1d --- redfish-core/lib/account_service.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'redfish-core') diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp index bc8ce771d6..0658f3ff3b 100644 --- a/redfish-core/lib/account_service.hpp +++ b/redfish-core/lib/account_service.hpp @@ -1429,13 +1429,12 @@ class AccountsCollection : public Node crow::connections::systemBus->async_method_call( [asyncResp, username, password{std::move(password)}]( - const boost::system::error_code ec) { + const boost::system::error_code ec, + sdbusplus::message::message& m) { if (ec) { - messages::resourceAlreadyExists( - asyncResp->res, - "#ManagerAccount.v1_0_3.ManagerAccount", - "UserName", username); + userErrorMessageHandler(m.get_error(), asyncResp, + username, ""); return; } @@ -1446,16 +1445,17 @@ class AccountsCollection : public Node // but the password set failed.Something is wrong, // so delete the user that we've already created crow::connections::systemBus->async_method_call( - [asyncResp]( - const boost::system::error_code ec) { + [asyncResp, + password](const boost::system::error_code ec) { if (ec) { messages::internalError(asyncResp->res); return; } - messages::invalidObject(asyncResp->res, - "Password"); + // If password is invalid + messages::propertyValueFormatError( + asyncResp->res, password, "Password"); }, "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user/" + username, -- cgit v1.2.3