mirror of
https://github.com/XRPLF/clio.git
synced 2026-07-23 15:10:23 +00:00
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of clio: https://github.com/XRPLF/clio
|
|
Copyright (c) 2024, the clio developers.
|
|
|
|
Permission to use, copy, modify, and distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
//==============================================================================
|
|
|
|
#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"));
|
|
}
|