summaryrefslogtreecommitdiff
path: root/test/include/google/google_service_root_test.cpp
blob: daeb657bfdf228d1e593a665d890921fa2a82291 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "async_resp.hpp"
#include "google/google_service_root.hpp"
#include "http_request.hpp"
#include "http_response.hpp"

#include <boost/beast/http/verb.hpp>
#include <nlohmann/json.hpp>

#include <memory>
#include <system_error>

#include <gtest/gtest.h>

namespace crow::google_api
{
namespace
{

void validateServiceRootGet(crow::Response& res)
{
    nlohmann::json& json = res.jsonValue;
    EXPECT_EQ(json["@odata.id"], "/google/v1");
    EXPECT_EQ(json["@odata.type"],
              "#GoogleServiceRoot.v1_0_0.GoogleServiceRoot");
    EXPECT_EQ(json["@odata.id"], "/google/v1");
    EXPECT_EQ(json["Id"], "Google Rest RootService");
    EXPECT_EQ(json["Name"], "Google Service Root");
    EXPECT_EQ(json["Version"], "1.0.0");
    EXPECT_EQ(json["RootOfTrustCollection"]["@odata.id"],
              "/google/v1/RootOfTrustCollection");
}

TEST(HandleGoogleV1Get, OnSuccess)
{
    std::error_code ec;
    auto asyncResp = std::make_shared<bmcweb::AsyncResp>();

    asyncResp->res.setCompleteRequestHandler(validateServiceRootGet);

    crow::Request dummyRequest{{boost::beast::http::verb::get, "", 11}, ec};
    handleGoogleV1Get(dummyRequest, asyncResp);
}

} // namespace
} // namespace crow::google_api