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