1 #include "app.hpp" 2 #include "async_resp.hpp" 3 #include "chassis.hpp" 4 #include "http_request.hpp" 5 #include "http_response.hpp" 6 7 #include <boost/beast/core/string_type.hpp> 8 #include <boost/beast/http/message.hpp> 9 #include <boost/beast/http/verb.hpp> 10 #include <nlohmann/json.hpp> 11 12 #include <functional> 13 #include <memory> 14 #include <string> 15 #include <system_error> 16 #include <utility> 17 18 #include <gtest/gtest.h> 19 20 namespace redfish 21 { 22 namespace 23 { 24 25 void assertChassisResetActionInfoGet(const std::string& chassisId, 26 crow::Response& res) 27 { 28 EXPECT_EQ(res.jsonValue["@odata.type"], "#ActionInfo.v1_1_2.ActionInfo"); 29 EXPECT_EQ(res.jsonValue["@odata.id"], 30 "/redfish/v1/Chassis/" + chassisId + "/ResetActionInfo"); 31 EXPECT_EQ(res.jsonValue["Name"], "Reset Action Info"); 32 33 EXPECT_EQ(res.jsonValue["Id"], "ResetActionInfo"); 34 35 nlohmann::json::array_t parameters; 36 nlohmann::json::object_t parameter; 37 parameter["Name"] = "ResetType"; 38 parameter["Required"] = true; 39 parameter["DataType"] = "String"; 40 nlohmann::json::array_t allowed; 41 allowed.emplace_back("PowerCycle"); 42 parameter["AllowableValues"] = std::move(allowed); 43 parameters.emplace_back(std::move(parameter)); 44 45 EXPECT_EQ(res.jsonValue["Parameters"], parameters); 46 } 47 48 TEST(HandleChassisResetActionInfoGet, StaticAttributesAreExpected) 49 { 50 auto response = std::make_shared<bmcweb::AsyncResp>(); 51 std::error_code err; 52 crow::Request request{{boost::beast::http::verb::get, "/whatever", 11}, 53 err}; 54 55 std::string fakeChassis = "fakeChassis"; 56 response->res.setCompleteRequestHandler( 57 std::bind_front(assertChassisResetActionInfoGet, fakeChassis)); 58 59 crow::App app; 60 handleChassisResetActionInfoGet(app, request, response, fakeChassis); 61 } 62 63 } // namespace 64 } // namespace redfish 65