blob: 88b40d71db0d2ebd8f6e362002fdb84f8d728a4f [file] [log] [blame]
Nan Zhou322204a2022-07-03 06:07:21 +00001#include "async_resp.hpp"
Nan Zhouc33a0392022-09-10 18:11:41 +00002#include "google/google_service_root.hpp"
Nan Zhou322204a2022-07-03 06:07:21 +00003#include "http_request.hpp"
Ed Tanousfaf100f2023-05-25 10:03:14 -07004
5#include <nlohmann/json.hpp>
Nan Zhou322204a2022-07-03 06:07:21 +00006
7#include <gtest/gtest.h>
8
9namespace crow::google_api
10{
11namespace
12{
13
14void 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
28TEST(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
Patrick Williams89492a12023-05-10 07:51:34 -050040} // namespace crow::google_api