blob: 6d2799120ae09389d72cb8ea1ac8802a761b7410 [file]
#include "service_root.hpp"
#include <memory>
#include <gtest/gtest.h>
#include "bmcweb_config.h"
#include "http_response.hpp"
#include "async_resp.hpp"
#include <nlohmann/json.hpp>
namespace redfish {
namespace {
void assertServiceRootGet(crow::Response& res) {
nlohmann::json& json = res.jsonValue;
EXPECT_EQ(json["@odata.id"], "/redfish/v1");
EXPECT_EQ(json["@odata.type"], "#ServiceRoot.v1_15_0.ServiceRoot");
EXPECT_EQ(json["CertificateService"]["@odata.id"],
"/redfish/v1/CertificateService");
EXPECT_EQ(json["CertificateService"].size(), 1);
EXPECT_EQ(json["Chassis"]["@odata.id"], "/redfish/v1/Chassis");
EXPECT_EQ(json["Chassis"].size(), 1);
EXPECT_EQ(json["Id"], "RootService");
EXPECT_EQ(json["Links"].size(), 1);
EXPECT_EQ(json["Links"]["ManagerProvidingService"].size(), 1);
EXPECT_EQ(json["Links"]["ManagerProvidingService"]["@odata.id"],
"/redfish/v1/Managers/bmc");
EXPECT_EQ(json["Managers"]["@odata.id"], "/redfish/v1/Managers");
EXPECT_EQ(json["Managers"].size(), 1);
EXPECT_EQ(json["Name"], "Root Service");
EXPECT_EQ(json["RedfishVersion"], "1.9.0");
EXPECT_EQ(json["Storage"]["@odata.id"], "/redfish/v1/Storage");
EXPECT_EQ(json["Storage"].size(), 1);
EXPECT_EQ(json["Systems"]["@odata.id"], "/redfish/v1/Systems");
EXPECT_EQ(json["Systems"].size(), 1);
EXPECT_EQ(json["Tasks"]["@odata.id"], "/redfish/v1/TaskService");
EXPECT_EQ(json["Tasks"].size(), 1);
EXPECT_EQ(json["TelemetryService"]["@odata.id"],
"/redfish/v1/TelemetryService");
EXPECT_EQ(json["TelemetryService"].size(), 1);
EXPECT_EQ(json["UpdateService"]["@odata.id"], "/redfish/v1/UpdateService");
EXPECT_EQ(json["ProtocolFeaturesSupported"].size(), 7);
EXPECT_FALSE(json["ProtocolFeaturesSupported"]["ExcerptQuery"]);
EXPECT_EQ(json["ProtocolFeaturesSupported"]["ExpandQuery"]["ExpandAll"],
bmcwebInsecureEnableQueryParams);
EXPECT_EQ(json["ProtocolFeaturesSupported"]["ExpandQuery"]["Levels"],
bmcwebInsecureEnableQueryParams);
EXPECT_EQ(json["ProtocolFeaturesSupported"]["ExpandQuery"]["Links"],
bmcwebInsecureEnableQueryParams);
EXPECT_EQ(json["ProtocolFeaturesSupported"]["ExpandQuery"]["NoLinks"],
bmcwebInsecureEnableQueryParams);
if (bmcwebInsecureEnableQueryParams) {
EXPECT_EQ(json["ProtocolFeaturesSupported"]["ExpandQuery"].size(), 5);
EXPECT_EQ(json["ProtocolFeaturesSupported"]["ExpandQuery"]["MaxLevels"], 6);
} else {
EXPECT_EQ(json["ProtocolFeaturesSupported"]["ExpandQuery"].size(), 4);
}
EXPECT_TRUE(json["ProtocolFeaturesSupported"]["FilterQuery"]);
EXPECT_TRUE(json["ProtocolFeaturesSupported"]["OnlyMemberQuery"]);
EXPECT_TRUE(json["ProtocolFeaturesSupported"]["SelectQuery"]);
EXPECT_TRUE(json["ProtocolFeaturesSupported"]["TopSkipQuery"]);
EXPECT_FALSE(json["ProtocolFeaturesSupported"]["DeepOperations"]["DeepPOST"]);
EXPECT_FALSE(
json["ProtocolFeaturesSupported"]["DeepOperations"]["DeepPATCH"]);
EXPECT_EQ(json["ProtocolFeaturesSupported"]["DeepOperations"].size(), 2);
EXPECT_EQ(json.size(), 18);
}
TEST(HandleServiceRootGet, ServiceRootStaticAttributesAreExpected) {
auto shareAsyncResp = std::make_shared<bmcweb::AsyncResp>();
shareAsyncResp->res.setCompleteRequestHandler(assertServiceRootGet);
redfish::handleServiceRootGetImpl(shareAsyncResp);
}
} // namespace
} // namespace redfish