blob: 32d4e526fb7685e1a85315812f939e1cd3a8a040 [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"
4#include "nlohmann/json.hpp"
5
6#include <gtest/gtest.h>
7
8namespace crow::google_api
9{
10namespace
11{
12
13void 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
27TEST(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