Nan Zhou | 322204a | 2022-07-03 06:07:21 +0000 | [diff] [blame] | 1 | #include "async_resp.hpp" |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 2 | #include "google/google_service_root.hpp" |
Nan Zhou | 322204a | 2022-07-03 06:07:21 +0000 | [diff] [blame] | 3 | #include "http_request.hpp" |
Ed Tanous | faf100f | 2023-05-25 10:03:14 -0700 | [diff] [blame] | 4 | |
| 5 | #include <nlohmann/json.hpp> |
Nan Zhou | 322204a | 2022-07-03 06:07:21 +0000 | [diff] [blame] | 6 | |
| 7 | #include <gtest/gtest.h> |
| 8 | |
| 9 | namespace crow::google_api |
| 10 | { |
| 11 | namespace |
| 12 | { |
| 13 | |
| 14 | void 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 | |
| 28 | TEST(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 Williams | 89492a1 | 2023-05-10 07:51:34 -0500 | [diff] [blame] | 40 | } // namespace crow::google_api |