Add unit test for trailing slashes

Common error #9 requires that most urls end in a trailing slash.  Given
the redfish standard, we know that all redfish routes need to end in a
trailing slash, so write a unit test that verifies that is true.

Despite code review, this appears to have snuck into the codebase in 4
different handlers.  Fix those at the same time so the tests pass.

Tested: Unit tests pass.

Change-Id: I0299a7231662725a7100d5308b3977a549b49253
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/COMMON_ERRORS.md b/COMMON_ERRORS.md
index 75871ba..2c92cec 100644
--- a/COMMON_ERRORS.md
+++ b/COMMON_ERRORS.md
@@ -190,6 +190,8 @@
 by users. While many specifications do not require this, it resolves a whole
 class of bug that we've seen in the past.
 
+Note, unit tests can now find this for redfish routes.
+
 ## 10. URLs constructed in aggregate
 
 ```cpp
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 8bb746e..2ec3e32 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -2277,21 +2277,21 @@
 
     BMCWEB_ROUTE(
         app,
-        "/redfish/v1/AccountService/MultiFactorAuth/ClientCertificate/Certificates")
+        "/redfish/v1/AccountService/MultiFactorAuth/ClientCertificate/Certificates/")
         .privileges(redfish::privileges::headCertificateCollection)
         .methods(boost::beast::http::verb::head)(std::bind_front(
             handleAccountServiceClientCertificatesHead, std::ref(app)));
 
     BMCWEB_ROUTE(
         app,
-        "/redfish/v1/AccountService/MultiFactorAuth/ClientCertificate/Certificates")
+        "/redfish/v1/AccountService/MultiFactorAuth/ClientCertificate/Certificates/")
         .privileges(redfish::privileges::getCertificateCollection)
         .methods(boost::beast::http::verb::get)(std::bind_front(
             handleAccountServiceClientCertificatesGet, std::ref(app)));
 
     BMCWEB_ROUTE(
         app,
-        "/redfish/v1/AccountService/MultiFactorAuth/ClientCertificate/Certificates/<str>")
+        "/redfish/v1/AccountService/MultiFactorAuth/ClientCertificate/Certificates/<str>/")
         .privileges(redfish::privileges::headCertificate)
         .methods(boost::beast::http::verb::head)(std::bind_front(
             handleAccountServiceClientCertificatesInstanceHead, std::ref(app)));
diff --git a/redfish-core/lib/metadata.hpp b/redfish-core/lib/metadata.hpp
index 4d8b131..e708928 100644
--- a/redfish-core/lib/metadata.hpp
+++ b/redfish-core/lib/metadata.hpp
@@ -115,7 +115,7 @@
 
 inline void requestRoutesMetadata(App& app)
 {
-    BMCWEB_ROUTE(app, "/redfish/v1/$metadata")
+    BMCWEB_ROUTE(app, "/redfish/v1/$metadat/")
         .methods(boost::beast::http::verb::get)(
             std::bind_front(handleMetadataGet, std::ref(app)));
 }
diff --git a/test/redfish-core/include/redfish_test.cpp b/test/redfish-core/include/redfish_test.cpp
index 2bfabbf..57f9cea 100644
--- a/test/redfish-core/include/redfish_test.cpp
+++ b/test/redfish-core/include/redfish_test.cpp
@@ -4,13 +4,16 @@
 #include <boost/asio/io_context.hpp>
 
 #include <memory>
+#include <string>
 
+#include <gmock/gmock.h>
 #include <gtest/gtest.h>
 
 namespace redfish
 {
 namespace
 {
+using ::testing::EndsWith;
 
 TEST(Redfish, PathsShouldValidate)
 {
@@ -20,6 +23,12 @@
     RedfishService redfish(app);
 
     app.validate();
+
+    for (const std::string* route : app.getRoutes())
+    {
+        ASSERT_NE(route, nullptr);
+        EXPECT_THAT(*route, EndsWith("/"));
+    }
 }
 
 } // namespace