1 #include "async_resp.hpp" 2 #include "google/google_service_root.hpp" 3 #include "http_request.hpp" 4 #include "nlohmann/json.hpp" 5 6 #include <gtest/gtest.h> 7 8 namespace crow::google_api 9 { 10 namespace 11 { 12 13 void validateServiceRootGet(crow::Response& res) 14 { 15 nlohmann::json& json = res.jsonValue; 16 EXPECT_EQ(json["@odata.id"], "/google/v1"); 17 EXPECT_EQ(json["@odata.type"], 18 "#GoogleServiceRoot.v1_0_0.GoogleServiceRoot"); 19 EXPECT_EQ(json["@odata.id"], "/google/v1"); 20 EXPECT_EQ(json["Id"], "Google Rest RootService"); 21 EXPECT_EQ(json["Name"], "Google Service Root"); 22 EXPECT_EQ(json["Version"], "1.0.0"); 23 EXPECT_EQ(json["RootOfTrustCollection"]["@odata.id"], 24 "/google/v1/RootOfTrustCollection"); 25 } 26 27 TEST(HandleGoogleV1Get, OnSuccess) 28 { 29 std::error_code ec; 30 auto asyncResp = std::make_shared<bmcweb::AsyncResp>(); 31 32 asyncResp->res.setCompleteRequestHandler(validateServiceRootGet); 33 34 crow::Request dummyRequest{{boost::beast::http::verb::get, "", 11}, ec}; 35 handleGoogleV1Get(dummyRequest, asyncResp); 36 } 37 38 } // namespace 39 } // namespace crow::google_api 40