blob: a04385984ea18cb5a846a302174d191b79d74b79 [file] [log] [blame]
Nan Zhoucf7eba02022-07-21 23:53:20 +00001#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
15namespace redfish
16{
17namespace
18{
19
20void 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.push_back("PowerCycle");
37 parameter["AllowableValues"] = std::move(allowed);
38 parameters.push_back(std::move(parameter));
39
40 EXPECT_EQ(res.jsonValue["Parameters"], parameters);
41}
42
43TEST(HandleChassisResetActionInfoGet, StaticAttributesAreExpected)
44{
45
46 auto response = std::make_shared<bmcweb::AsyncResp>();
47 std::error_code err;
48 crow::Request request{{boost::beast::http::verb::get, "/whatever", 11},
49 err};
50
51 std::string fakeChassis = "fakeChassis";
52 response->res.setCompleteRequestHandler(
53 std::bind_front(assertChassisResetActionInfoGet, fakeChassis));
54
55 crow::App app;
56 handleChassisResetActionInfoGet(app, request, response, fakeChassis);
57}
58
59} // namespace
60} // namespace redfish