diff options
author | Nan Zhou <nanzhoumails@gmail.com> | 2022-07-03 09:07:21 +0300 |
---|---|---|
committer | Nan Zhou <nanzhoumails@gmail.com> | 2022-07-11 04:51:44 +0300 |
commit | 322204a4c91373eec03bcdc3ce4b3a123790c621 (patch) | |
tree | 8bc65d645ab8f85274e158c025b590fb01de2839 /include/google | |
parent | cd02759bce6a0ed290a8c0391de6aef992c3005d (diff) | |
download | bmcweb-322204a4c91373eec03bcdc3ce4b3a123790c621.tar.xz |
Google RoT: add unit tests for /google/v1
Tested: unit test worked.
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I4feb6c9cdf52930617a7011732a5837f06c1adda
Diffstat (limited to 'include/google')
-rw-r--r-- | include/google/google_service_root_test.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/include/google/google_service_root_test.cpp b/include/google/google_service_root_test.cpp new file mode 100644 index 0000000000..f979a42275 --- /dev/null +++ b/include/google/google_service_root_test.cpp @@ -0,0 +1,39 @@ +#include "async_resp.hpp" +#include "google_service_root.hpp" +#include "http_request.hpp" +#include "nlohmann/json.hpp" + +#include <gtest/gtest.h> + +namespace crow::google_api +{ +namespace +{ + +void validateServiceRootGet(crow::Response& res) +{ + nlohmann::json& json = res.jsonValue; + EXPECT_EQ(json["@odata.id"], "/google/v1"); + EXPECT_EQ(json["@odata.type"], + "#GoogleServiceRoot.v1_0_0.GoogleServiceRoot"); + EXPECT_EQ(json["@odata.id"], "/google/v1"); + EXPECT_EQ(json["Id"], "Google Rest RootService"); + EXPECT_EQ(json["Name"], "Google Service Root"); + EXPECT_EQ(json["Version"], "1.0.0"); + EXPECT_EQ(json["RootOfTrustCollection"]["@odata.id"], + "/google/v1/RootOfTrustCollection"); +} + +TEST(HandleGoogleV1Get, OnSuccess) +{ + std::error_code ec; + auto asyncResp = std::make_shared<bmcweb::AsyncResp>(); + + asyncResp->res.setCompleteRequestHandler(validateServiceRootGet); + + crow::Request dummyRequest{{boost::beast::http::verb::get, "", 11}, ec}; + handleGoogleV1Get(dummyRequest, asyncResp); +} + +} // namespace +} // namespace crow::google_api
\ No newline at end of file |