summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2023-02-10 05:08:23 +0300
committerEd Tanous <ed@tanous.net>2023-04-27 20:18:35 +0300
commit15a42df05b033a06e38d2998511d6c79d09d66a7 (patch)
tree9e21eba54b9d5783a5d233c69a345d9bb964123d /test
parent02e01b5108d46720a0b438c0d79952464320d954 (diff)
downloadbmcweb-15a42df05b033a06e38d2998511d6c79d09d66a7.tar.xz
Remove number support from the router
The router historically came from crow. Crow supported wildcards of <int>, <float>, and <double>. bmcweb doesn't use them, nor should it in basically any case, as we now have explicit 404 handling. This commit removes them. This amounts to about -450 lines of code, but it's some of the scarier code we have, some of it existing in the namespace "black_magic". Reducing the brain debt for people working in this subsystem seems worthwhile. There is no case in the future where we would use integer based url parameters. Tested: Redfish service validator passes. Should be good enough coverage for a code removal. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I34add8df7d3486952474ca7ec3dc6be990c50ed0
Diffstat (limited to 'test')
-rw-r--r--test/http/crow_getroutes_test.cpp23
-rw-r--r--test/http/utility_test.cpp14
2 files changed, 19 insertions, 18 deletions
diff --git a/test/http/crow_getroutes_test.cpp b/test/http/crow_getroutes_test.cpp
index 23a511e735..e5c9d6eb7e 100644
--- a/test/http/crow_getroutes_test.cpp
+++ b/test/http/crow_getroutes_test.cpp
@@ -20,6 +20,7 @@ namespace crow
namespace
{
+using ::bmcweb::AsyncResp;
using ::testing::Eq;
using ::testing::IsEmpty;
using ::testing::Pointee;
@@ -38,7 +39,9 @@ TEST(GetRoutes, TestOneRoute)
{
App app;
- BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/")
+ ([](const crow::Request& /*req*/,
+ const std::shared_ptr<AsyncResp>& /*asyncResp*/) {});
// TODO: "/" doesn't get reported in |getRoutes| today. Uncomment this once
// it is fixed
@@ -50,12 +53,18 @@ TEST(GetRoutes, TestOneRoute)
TEST(GetRoutes, TestlotsOfRoutes)
{
App app;
- BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
- BMCWEB_ROUTE(app, "/foo")([]() { return boost::beast::http::status::ok; });
- BMCWEB_ROUTE(app, "/bar")([]() { return boost::beast::http::status::ok; });
- BMCWEB_ROUTE(app, "/baz")([]() { return boost::beast::http::status::ok; });
- BMCWEB_ROUTE(app, "/boo")([]() { return boost::beast::http::status::ok; });
- BMCWEB_ROUTE(app, "/moo")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/")
+ ([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
+ BMCWEB_ROUTE(app, "/foo")
+ ([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
+ BMCWEB_ROUTE(app, "/bar")
+ ([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
+ BMCWEB_ROUTE(app, "/baz")
+ ([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
+ BMCWEB_ROUTE(app, "/boo")
+ ([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
+ BMCWEB_ROUTE(app, "/moo")
+ ([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
app.validate();
diff --git a/test/http/utility_test.cpp b/test/http/utility_test.cpp
index 957c13d2db..67264551a5 100644
--- a/test/http/utility_test.cpp
+++ b/test/http/utility_test.cpp
@@ -220,17 +220,9 @@ TEST(Utility, ValidateAndSplitUrlPositive)
TEST(Router, ParameterTagging)
{
- EXPECT_EQ(6 * 6 + 6 * 3 + 2, getParameterTag("<uint><double><int>"));
- EXPECT_EQ(1, getParameterTag("<int>"));
- EXPECT_EQ(2, getParameterTag("<uint>"));
- EXPECT_EQ(3, getParameterTag("<float>"));
- EXPECT_EQ(3, getParameterTag("<double>"));
- EXPECT_EQ(4, getParameterTag("<str>"));
- EXPECT_EQ(4, getParameterTag("<string>"));
- EXPECT_EQ(5, getParameterTag("<path>"));
- EXPECT_EQ(6 * 6 + 6 + 1, getParameterTag("<int><int><int>"));
- EXPECT_EQ(6 * 6 + 6 + 2, getParameterTag("<uint><int><int>"));
- EXPECT_EQ(6 * 6 + 6 * 3 + 2, getParameterTag("<uint><double><int>"));
+ EXPECT_EQ(1, getParameterTag("<str>"));
+ EXPECT_EQ(1, getParameterTag("<string>"));
+ EXPECT_EQ(2, getParameterTag("<path>"));
}
TEST(URL, JsonEncoding)