#include "utils/dbus_utils.hpp" #include "async_resp.hpp" #include "http_response.hpp" #include #include #include #include #include #include #include namespace redfish::details { namespace { TEST(DbusUtils, AfterPropertySetSuccess) { std::shared_ptr asyncResp = std::make_shared(); boost::system::error_code ec; sdbusplus::message_t msg; afterSetProperty(asyncResp, "MyRedfishProperty", nlohmann::json("MyRedfishValue"), ec, msg); EXPECT_EQ(asyncResp->res.result(), boost::beast::http::status::no_content); EXPECT_TRUE(asyncResp->res.jsonValue.empty()); } TEST(DbusUtils, AfterPropertySetInternalError) { std::shared_ptr asyncResp = std::make_shared(); boost::system::error_code ec = boost::system::errc::make_error_code(boost::system::errc::timed_out); sdbusplus::message_t msg; afterSetProperty(asyncResp, "MyRedfishProperty", nlohmann::json("MyRedfishValue"), ec, msg); EXPECT_EQ(asyncResp->res.result(), boost::beast::http::status::internal_server_error); EXPECT_EQ(asyncResp->res.jsonValue.size(), 1); using nlohmann::literals::operator""_json; EXPECT_EQ(asyncResp->res.jsonValue, R"({ "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The request failed due to an internal service error. The service is still operational.", "MessageArgs": [], "MessageId": "Base.1.16.0.InternalError", "MessageSeverity": "Critical", "Resolution": "Resubmit the request. If the problem persists, consider resetting the service." } ], "code": "Base.1.16.0.InternalError", "message": "The request failed due to an internal service error. The service is still operational." } })"_json); } } // namespace } // namespace redfish::details