blob: c104494f019660e3f09b5c30d1dbacef9f0e86d5 [file] [log] [blame]
Ed Tanous40e9b922024-09-10 13:50:16 -07001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright OpenBMC Authors
Nan Zhou322204a2022-07-03 06:07:21 +00003#include "async_resp.hpp"
Ed Tanous3b28fa22024-09-23 14:51:55 -07004#include "google_service_root.hpp"
Nan Zhou322204a2022-07-03 06:07:21 +00005#include "http_request.hpp"
Ed Tanousf0b59af2024-03-20 13:38:04 -07006#include "http_response.hpp"
Ed Tanousfaf100f2023-05-25 10:03:14 -07007
Ed Tanousf0b59af2024-03-20 13:38:04 -07008#include <boost/beast/http/verb.hpp>
Ed Tanousfaf100f2023-05-25 10:03:14 -07009#include <nlohmann/json.hpp>
Nan Zhou322204a2022-07-03 06:07:21 +000010
Ed Tanousf0b59af2024-03-20 13:38:04 -070011#include <memory>
12#include <system_error>
13
Nan Zhou322204a2022-07-03 06:07:21 +000014#include <gtest/gtest.h>
15
16namespace crow::google_api
17{
18namespace
19{
20
21void validateServiceRootGet(crow::Response& res)
22{
23 nlohmann::json& json = res.jsonValue;
24 EXPECT_EQ(json["@odata.id"], "/google/v1");
25 EXPECT_EQ(json["@odata.type"],
26 "#GoogleServiceRoot.v1_0_0.GoogleServiceRoot");
27 EXPECT_EQ(json["@odata.id"], "/google/v1");
28 EXPECT_EQ(json["Id"], "Google Rest RootService");
29 EXPECT_EQ(json["Name"], "Google Service Root");
30 EXPECT_EQ(json["Version"], "1.0.0");
31 EXPECT_EQ(json["RootOfTrustCollection"]["@odata.id"],
32 "/google/v1/RootOfTrustCollection");
33}
34
35TEST(HandleGoogleV1Get, OnSuccess)
36{
37 std::error_code ec;
38 auto asyncResp = std::make_shared<bmcweb::AsyncResp>();
39
40 asyncResp->res.setCompleteRequestHandler(validateServiceRootGet);
41
42 crow::Request dummyRequest{{boost::beast::http::verb::get, "", 11}, ec};
43 handleGoogleV1Get(dummyRequest, asyncResp);
44}
45
46} // namespace
Patrick Williams89492a12023-05-10 07:51:34 -050047} // namespace crow::google_api