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