summaryrefslogtreecommitdiff
path: root/redfish-core/lib/ut
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-03-23 09:53:51 +0300
committerEd Tanous <ed@tanous.net>2022-04-05 21:50:46 +0300
commit7cf436c913a109c0d3ebf7e696970966500bc6b6 (patch)
tree395401354b8ea67abd0ce20a769af9f584b74a55 /redfish-core/lib/ut
parentf4c99e70dad320abf84fd25a32ad5fce2bf16f4a (diff)
downloadbmcweb-7cf436c913a109c0d3ebf7e696970966500bc6b6.tar.xz
Implement Expand
Section 7.3 of the Redfish specification lays out a feature called "expand" that allows users to expand portions of the Redfish tree automatically on the server side. This commit implements them to the specification. To accomplish this, a new class, MultiAsyncResp is created, that allows RAII objects to handle lifetime properly. When an expand query is generated, a MultiAsyncResp object is instantiated, which allows "new" requests to attach themselves to the multi object, and keep the request alive until they all complete. This also allows requests to be created, while requests are in flight, which is required for queries above depth=1. Negatives: Similar to the previous $only commit, this requires that all nodes redfish nodes now capture App by reference. This is common, but does interfere with some of our other patterns, and attempts to improve the syntactic sugar for this proved unworkable. This commit only adds the above to service root and Computer systems, in hopes that we find a better syntax before this merges. Left to future patches in series: Merging the error json structures in responses. The Redfish spec isn't very clear on how errors propagate for expanded queries, and in a conforming we shouldn't ever hit them, but nonetheless, I suspect the behavior we have is sub-optimal (attaching an error node to every place in the tree that had an issue) and we should attempt to do better in the future. Tested (on previous patch): curl --insecure --user root:0penBmc https://localhost:18080/redfish/v1\?\$expand\=.\(\$levels\=255\) Returns the full tree Setting $levels=1 query returns only a depth of 1 tree being returned. Unit tests passing Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I874aabfaa9df5dbf832a80ec62ae65369284791d
Diffstat (limited to 'redfish-core/lib/ut')
-rw-r--r--redfish-core/lib/ut/service_root_test.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/redfish-core/lib/ut/service_root_test.cpp b/redfish-core/lib/ut/service_root_test.cpp
index 4c05751f09..1a7b249011 100644
--- a/redfish-core/lib/ut/service_root_test.cpp
+++ b/redfish-core/lib/ut/service_root_test.cpp
@@ -1,3 +1,5 @@
+#include "bmcweb_config.h"
+
#include "http_request.hpp"
#include "include/async_resp.hpp"
#include "nlohmann/json.hpp"
@@ -67,11 +69,24 @@ static void assertServiceRootGet(crow::Response& res)
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_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_FALSE(json["ProtocolFeaturesSupported"]["FilterQuery"]);
EXPECT_EQ(json["ProtocolFeaturesSupported"]["OnlyMemberQuery"],
bmcwebInsecureEnableQueryParams);
@@ -87,10 +102,9 @@ static void assertServiceRootGet(crow::Response& res)
TEST(ServiceRootTest, ServiceRootConstructor)
{
std::error_code ec;
- crow::Request req({}, ec);
auto shareAsyncResp = std::make_shared<bmcweb::AsyncResp>();
shareAsyncResp->res.setCompleteRequestHandler(assertServiceRootGet);
- redfish::handleServiceRootGet(req, shareAsyncResp);
+ redfish::handleServiceRootGet(shareAsyncResp);
}