blob: daeb657bfdf228d1e593a665d890921fa2a82291 [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 Tanousf0b59af2024-03-20 13:38:04 -07004#include "http_response.hpp"
Ed Tanousfaf100f2023-05-25 10:03:14 -07005
Ed Tanousf0b59af2024-03-20 13:38:04 -07006#include <boost/beast/http/verb.hpp>
Ed Tanousfaf100f2023-05-25 10:03:14 -07007#include <nlohmann/json.hpp>
Nan Zhou322204a2022-07-03 06:07:21 +00008
Ed Tanousf0b59af2024-03-20 13:38:04 -07009#include <memory>
10#include <system_error>
11
Nan Zhou322204a2022-07-03 06:07:21 +000012#include <gtest/gtest.h>
13
14namespace crow::google_api
15{
16namespace
17{
18
19void 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
33TEST(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
Patrick Williams89492a12023-05-10 07:51:34 -050045} // namespace crow::google_api