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