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