18 #include <glog/logging.h> 19 #include <gtest/gtest.h> 24 using std::shared_ptr;
25 using namespace folly;
31 using SSLContextManager::SSLContextManager;
32 using SSLContextManager::insertSSLCtxByDomainName;
35 TEST(SSLContextManagerTest, Test1)
39 "vip_ssl_context_manager_test_",
42 auto www_facebook_com_ctx = std::make_shared<SSLContext>();
43 auto start_facebook_com_ctx = std::make_shared<SSLContext>();
44 auto start_abc_facebook_com_ctx = std::make_shared<SSLContext>();
45 auto www_facebook_com_ctx_sha1 = std::make_shared<SSLContext>();
46 auto start_facebook_com_ctx_sha1 = std::make_shared<SSLContext>();
47 auto www_bookface_com_ctx_sha1 = std::make_shared<SSLContext>();
51 strlen(
"*.facebook.com"),
52 start_facebook_com_ctx_sha1,
53 CertCrypto::SHA1_SIGNATURE);
56 strlen(
"www.facebook.com"),
57 www_facebook_com_ctx);
60 strlen(
"www.facebook.com"),
61 www_facebook_com_ctx);
64 strlen(
"*.facebook.com"),
65 start_facebook_com_ctx);
68 strlen(
"*.abc.facebook.com"),
69 start_abc_facebook_com_ctx);
72 strlen(
"www.facebook.com"),
73 www_facebook_com_ctx_sha1,
74 CertCrypto::SHA1_SIGNATURE);
77 strlen(
"www.bookface.com"),
78 www_bookface_com_ctx_sha1,
79 CertCrypto::SHA1_SIGNATURE);
82 shared_ptr<SSLContext> retCtx;
91 EXPECT_EQ(retCtx, start_facebook_com_ctx);
93 EXPECT_EQ(retCtx, start_facebook_com_ctx);
96 EXPECT_EQ(retCtx, start_abc_facebook_com_ctx);
107 CertCrypto::SHA1_SIGNATURE));
108 EXPECT_EQ(retCtx, www_facebook_com_ctx_sha1);
110 CertCrypto::SHA1_SIGNATURE));
111 EXPECT_EQ(retCtx, start_facebook_com_ctx_sha1);
113 CertCrypto::SHA1_SIGNATURE));
117 CertCrypto::SHA1_SIGNATURE));
118 EXPECT_EQ(retCtx, www_bookface_com_ctx_sha1);
120 EXPECT_EQ(retCtx, www_bookface_com_ctx_sha1);
127 #if !(FOLLY_OPENSSL_IS_110) && !defined(OPENSSL_IS_BORINGSSL) 129 TEST(SSLContextManagerTest, DISABLED_TestSessionContextIfSupplied)
133 "vip_ssl_context_manager_test_",
139 "wangle/ssl/test/certs/test.cert.pem",
140 "wangle/ssl/test/certs/test.key.pem",
147 ctxConfig, cacheOptions,
nullptr, addr,
nullptr);
153 reinterpret_cast<char*>(ctx->getSSLCtx()->sid_ctx),
154 ctx->getSSLCtx()->sid_ctx_length);
160 TEST(SSLContextManagerTest, DISABLED_TestSessionContextIfSessionCacheAbsent)
164 "vip_ssl_context_manager_test_",
171 "wangle/ssl/test/certs/test.cert.pem",
172 "wangle/ssl/test/certs/test.key.pem",
179 ctxConfig, cacheOptions,
nullptr, addr,
nullptr);
185 reinterpret_cast<char*>(ctx->getSSLCtx()->sid_ctx),
186 ctx->getSSLCtx()->sid_ctx_length);
void addSSLContextConfig(const SSLContextConfig &ctxConfig, const SSLCacheOptions &cacheOptions, const TLSTicketKeySeeds *ticketSeeds, const folly::SocketAddress &vipAddress, const std::shared_ptr< SSLCacheProvider > &externalCache, SslContexts *contexts=nullptr)
#define EXPECT_EQ(val1, val2)
folly::Optional< std::string > sessionContext
—— Concurrent Priority Queue Implementation ——
void insertSSLCtxByDomainName(const char *dn, size_t len, std::shared_ptr< folly::SSLContext > sslCtx, SslContexts &contexts, CertCrypto certCrypto=CertCrypto::BEST_AVAILABLE)
std::shared_ptr< folly::SSLContext > getSSLCtxByExactDomain(const SSLContextKey &key) const
std::shared_ptr< folly::SSLContext > getSSLCtxBySuffix(const SSLContextKey &key) const
void addCertificate(const std::string &certPath, const std::string &keyPath, const std::string &passwordPath)
std::shared_ptr< folly::SSLContext > getSSLCtx(const SSLContextKey &key) const
#define ASSERT_NE(val1, val2)
#define EXPECT_FALSE(condition)
ThreadPoolListHook * addr
TEST(SequencedExecutor, CPUThreadPoolExecutor)