mirror of
https://github.com/XRPLF/clio.git
synced 2026-07-23 15:10:23 +00:00
37 lines
833 B
C++
37 lines
833 B
C++
#include "util/requests/impl/SslContext.hpp"
|
|
|
|
#include <gmock/gmock.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <optional>
|
|
|
|
using namespace util::requests::impl;
|
|
|
|
TEST(SslContext, Create)
|
|
{
|
|
auto& ctx = getClientSslContext();
|
|
EXPECT_NE(ctx.native_handle(), nullptr);
|
|
}
|
|
|
|
TEST(SslContext, IsCached)
|
|
{
|
|
auto& first = getClientSslContext();
|
|
auto& second = getClientSslContext();
|
|
|
|
// Same shared instance is returned on every call
|
|
EXPECT_EQ(&first, &second);
|
|
}
|
|
|
|
TEST(SslContext, InitSucceedsWithSystemCertificates)
|
|
{
|
|
EXPECT_TRUE(initClientSslContext().has_value());
|
|
}
|
|
|
|
TEST(SslContext, MakeWithoutRootCertificateReturnsError)
|
|
{
|
|
auto const ctx = makeClientSslContext(std::nullopt);
|
|
|
|
ASSERT_FALSE(ctx.has_value());
|
|
EXPECT_THAT(ctx.error().message(), testing::HasSubstr("could not find root certificate"));
|
|
}
|