service root: add ProtocolFeaturesSupported
This commits adds a dummy ProtocolFeaturesSupported object in the
service root. It indicates that none of the Query Parameter is
supported. Future commits will add supports for OnlyMemberQuery,
ExpandQuery, and so on.
Tested:
1. unit test
2. passed QEMU Redfish (which contains Redfish Validator) test
This commit is split from these changes:
https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38952
https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/47474
Credits to maxiaochao@inspur.com, ed@tanous.net, and
zhanghch05@inspur.com.
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I81ff856514528f63a462558a8f18fefe4369edae
diff --git a/redfish-core/lib/service_root.hpp b/redfish-core/lib/service_root.hpp
index 2a1803d..e2f32bb 100644
--- a/redfish-core/lib/service_root.hpp
+++ b/redfish-core/lib/service_root.hpp
@@ -16,6 +16,9 @@
#pragma once
#include <app.hpp>
+#include <async_resp.hpp>
+#include <http_request.hpp>
+#include <nlohmann/json.hpp>
#include <persistent_data.hpp>
#include <registries/privilege_registry.hpp>
#include <utils/systemd_utils.hpp>
@@ -64,6 +67,19 @@
asyncResp->res.jsonValue["TelemetryService"] = {
{"@odata.id", "/redfish/v1/TelemetryService"}};
asyncResp->res.jsonValue["Cables"] = {{"@odata.id", "/redfish/v1/Cables"}};
+
+ nlohmann::json& protocolFeatures =
+ asyncResp->res.jsonValue["ProtocolFeaturesSupported"];
+ protocolFeatures["ExcerptQuery"] = false;
+ protocolFeatures["ExpandQuery"]["ExpandAll"] = false;
+ protocolFeatures["ExpandQuery"]["Levels"] = false;
+ protocolFeatures["ExpandQuery"]["Links"] = false;
+ protocolFeatures["ExpandQuery"]["NoLinks"] = false;
+ protocolFeatures["FilterQuery"] = false;
+ protocolFeatures["OnlyMemberQuery"] = false;
+ protocolFeatures["SelectQuery"] = false;
+ protocolFeatures["DeepOperations"]["DeepPOST"] = false;
+ protocolFeatures["DeepOperations"]["DeepPATCH"] = false;
}
inline void requestRoutesServiceRoot(App& app)
diff --git a/redfish-core/lib/ut/service_root_test.cpp b/redfish-core/lib/ut/service_root_test.cpp
index 9e6c423..61b0d02 100644
--- a/redfish-core/lib/ut/service_root_test.cpp
+++ b/redfish-core/lib/ut/service_root_test.cpp
@@ -7,6 +7,7 @@
#include <string>
#include "gmock/gmock.h"
+#include "gtest/gtest.h"
static void assertServiceRootGet(crow::Response& res)
{
@@ -63,7 +64,23 @@
"9a-fA-F]{4}-[0-9a-fA-F]{12}"));
EXPECT_EQ(json["UpdateService"]["@odata.id"], "/redfish/v1/UpdateService");
- EXPECT_EQ(20, json.size());
+
+ EXPECT_EQ(json["ProtocolFeaturesSupported"].size(), 6);
+ EXPECT_FALSE(json["ProtocolFeaturesSupported"]["ExcerptQuery"]);
+ EXPECT_FALSE(json["ProtocolFeaturesSupported"]["ExpandQuery"]["ExpandAll"]);
+ EXPECT_FALSE(json["ProtocolFeaturesSupported"]["ExpandQuery"]["Levels"]);
+ EXPECT_FALSE(json["ProtocolFeaturesSupported"]["ExpandQuery"]["Links"]);
+ EXPECT_FALSE(json["ProtocolFeaturesSupported"]["ExpandQuery"]["NoLinks"]);
+ EXPECT_EQ(json["ProtocolFeaturesSupported"]["ExpandQuery"].size(), 4);
+ EXPECT_FALSE(json["ProtocolFeaturesSupported"]["FilterQuery"]);
+ EXPECT_FALSE(json["ProtocolFeaturesSupported"]["OnlyMemberQuery"]);
+ EXPECT_FALSE(json["ProtocolFeaturesSupported"]["SelectQuery"]);
+ EXPECT_FALSE(
+ json["ProtocolFeaturesSupported"]["DeepOperations"]["DeepPOST"]);
+ EXPECT_FALSE(
+ json["ProtocolFeaturesSupported"]["DeepOperations"]["DeepPATCH"]);
+ EXPECT_EQ(json["ProtocolFeaturesSupported"]["DeepOperations"].size(), 2);
+ EXPECT_EQ(json.size(), 21);
}
TEST(ServiceRootTest, ServiceRootConstructor)