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