Commit c73706ee authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

Shift AsyncSSLSocketTest to use NetworkSocket

Summary: Do it.

Reviewed By: yfeldblum

Differential Revision: D12988464

fbshipit-source-id: b5dd907f24f9064ea7c7e417e0616120339eb452
parent 1d27782a
main v2022.02.14.00 v2022.02.07.00 v2022.01.31.00 v2022.01.24.00 v2022.01.17.00 v2022.01.10.00 v2022.01.03.00 v2021.12.27.00 v2021.12.20.00 v2021.12.13.00 v2021.12.06.00 v2021.11.29.00 v2021.11.15.00 v2021.11.08.00 v2021.11.01.00 v2021.10.25.00 v2021.10.18.00 v2021.10.11.00 v2021.10.04.00 v2021.09.27.00 v2021.09.20.00 v2021.09.13.00 v2021.09.06.00 v2021.08.30.00 v2021.08.23.00 v2021.08.02.00 v2021.07.22.00 v2021.07.20.01 v2021.07.20.00 v2021.06.28.00 v2021.06.14.00 v2021.06.07.00 v2021.05.31.00 v2021.05.24.00 v2021.05.17.00 v2021.05.10.00 v2021.05.03.00 v2021.04.26.00 v2021.04.19.00 v2021.04.12.00 v2021.04.05.00 v2021.03.29.00 v2021.03.22.00 v2021.03.15.00 v2021.03.08.00 v2021.03.01.00 v2021.02.22.00 v2021.02.15.00 v2021.02.08.00 v2021.02.01.00 v2021.01.25.00 v2021.01.18.01 v2021.01.18.00 v2021.01.11.00 v2021.01.04.00 v2020.12.28.00 v2020.12.21.00 v2020.12.14.00 v2020.12.07.00 v2020.11.30.00 v2020.11.23.00 v2020.11.16.00 v2020.11.09.00 v2020.11.02.00 v2020.10.26.00 v2020.10.19.00 v2020.10.12.00 v2020.10.05.00 v2020.09.28.00 v2020.09.21.00 v2020.09.14.00 v2020.09.07.00 v2020.08.31.00 v2020.08.24.00 v2020.08.17.00 v2020.08.10.00 v2020.08.03.00 v2020.07.27.00 v2020.07.20.00 v2020.07.13.00 v2020.07.06.00 v2020.06.29.00 v2020.06.15.00 v2020.06.08.00 v2020.06.01.00 v2020.05.25.00 v2020.05.18.00 v2020.05.11.00 v2020.05.04.00 v2020.04.27.00 v2020.04.20.00 v2020.04.13.00 v2020.04.06.00 v2020.03.30.00 v2020.03.23.00 v2020.03.16.00 v2020.03.09.00 v2020.03.02.00 v2020.02.24.00 v2020.02.17.00 v2020.02.10.00 v2020.02.03.00 v2020.01.27.00 v2020.01.20.00 v2020.01.13.00 v2020.01.06.00 v2019.12.30.00 v2019.12.23.00 v2019.12.16.00 v2019.12.09.00 v2019.12.06.00 v2019.12.02.00 v2019.11.11.00 v2019.11.04.00 v2019.10.28.00 v2019.10.21.00 v2019.10.14.00 v2019.10.07.00 v2019.09.30.00 v2019.09.23.00 v2019.09.16.00 v2019.09.09.00 v2019.09.02.00 v2019.08.26.00 v2019.08.19.00 v2019.08.12.00 v2019.08.05.00 v2019.07.29.00 v2019.07.22.00 v2019.06.17.00 v2019.06.10.00 v2019.06.03.00 v2019.05.27.00 v2019.05.20.00 v2019.05.13.00 v2019.05.06.00 v2019.04.29.00 v2019.04.22.00 v2019.04.15.00 v2019.04.08.00 v2019.04.01.00 v2019.03.25.00 v2019.03.18.00 v2019.03.04.00 v2019.02.25.00 v2019.02.18.00 v2019.02.11.00 v2019.02.04.00 v2019.01.28.00 v2019.01.21.00 v2019.01.14.00 v2019.01.07.00 v2018.12.31.00 v2018.12.24.00 v2018.12.17.00 v2018.12.10.00 v2018.12.03.00 v2018.11.26.00 v2018.11.19.00
No related merge requests found
...@@ -22,10 +22,11 @@ ...@@ -22,10 +22,11 @@
#include <folly/io/async/AsyncSSLSocket.h> #include <folly/io/async/AsyncSSLSocket.h>
#include <folly/io/async/EventBase.h> #include <folly/io/async/EventBase.h>
#include <folly/io/async/ScopedEventBaseThread.h> #include <folly/io/async/ScopedEventBaseThread.h>
#include <folly/net/NetOps.h>
#include <folly/net/NetworkSocket.h>
#include <folly/portability/GMock.h> #include <folly/portability/GMock.h>
#include <folly/portability/GTest.h> #include <folly/portability/GTest.h>
#include <folly/portability/OpenSSL.h> #include <folly/portability/OpenSSL.h>
#include <folly/portability/Sockets.h>
#include <folly/portability/Unistd.h> #include <folly/portability/Unistd.h>
#include <folly/ssl/Init.h> #include <folly/ssl/Init.h>
...@@ -111,17 +112,12 @@ uint32_t TestSSLAsyncCacheServer::lookupDelay_ = 0; ...@@ -111,17 +112,12 @@ uint32_t TestSSLAsyncCacheServer::lookupDelay_ = 0;
constexpr size_t SSLClient::kMaxReadBufferSz; constexpr size_t SSLClient::kMaxReadBufferSz;
constexpr size_t SSLClient::kMaxReadsPerEvent; constexpr size_t SSLClient::kMaxReadsPerEvent;
void getfds(int fds[2]) { void getfds(NetworkSocket fds[2]) {
if (socketpair(PF_LOCAL, SOCK_STREAM, 0, fds) != 0) { if (netops::socketpair(PF_LOCAL, SOCK_STREAM, 0, fds) != 0) {
FAIL() << "failed to create socketpair: " << errnoStr(errno); FAIL() << "failed to create socketpair: " << errnoStr(errno);
} }
for (int idx = 0; idx < 2; ++idx) { for (int idx = 0; idx < 2; ++idx) {
int flags = fcntl(fds[idx], F_GETFL, 0); if (netops::set_socket_non_blocking(fds[idx]) != 0) {
if (flags == -1) {
FAIL() << "failed to get flags for socket " << idx << ": "
<< errnoStr(errno);
}
if (fcntl(fds[idx], F_SETFL, flags | O_NONBLOCK) != 0) {
FAIL() << "failed to put socket " << idx FAIL() << "failed to put socket " << idx
<< " in non-blocking mode: " << errnoStr(errno); << " in non-blocking mode: " << errnoStr(errno);
} }
...@@ -144,7 +140,7 @@ void sslsocketpair( ...@@ -144,7 +140,7 @@ void sslsocketpair(
AsyncSSLSocket::UniquePtr* serverSock) { AsyncSSLSocket::UniquePtr* serverSock) {
auto clientCtx = std::make_shared<folly::SSLContext>(); auto clientCtx = std::make_shared<folly::SSLContext>();
auto serverCtx = std::make_shared<folly::SSLContext>(); auto serverCtx = std::make_shared<folly::SSLContext>();
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
getctx(clientCtx, serverCtx); getctx(clientCtx, serverCtx);
clientSock->reset(new AsyncSSLSocket(clientCtx, eventBase, fds[0], false)); clientSock->reset(new AsyncSSLSocket(clientCtx, eventBase, fds[0], false));
...@@ -258,7 +254,7 @@ TEST(AsyncSSLSocketTest, Renegotiate) { ...@@ -258,7 +254,7 @@ TEST(AsyncSSLSocketTest, Renegotiate) {
EventBase eventBase; EventBase eventBase;
auto clientCtx = std::make_shared<SSLContext>(); auto clientCtx = std::make_shared<SSLContext>();
auto dfServerCtx = std::make_shared<SSLContext>(); auto dfServerCtx = std::make_shared<SSLContext>();
std::array<int, 2> fds; std::array<NetworkSocket, 2> fds;
getfds(fds.data()); getfds(fds.data());
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -495,7 +491,7 @@ class NextProtocolTest : public Test { ...@@ -495,7 +491,7 @@ class NextProtocolTest : public Test {
EventBase eventBase; EventBase eventBase;
std::shared_ptr<SSLContext> clientCtx{std::make_shared<SSLContext>()}; std::shared_ptr<SSLContext> clientCtx{std::make_shared<SSLContext>()};
std::shared_ptr<SSLContext> serverCtx{std::make_shared<SSLContext>()}; std::shared_ptr<SSLContext> serverCtx{std::make_shared<SSLContext>()};
int fds[2]; NetworkSocket fds[2];
std::unique_ptr<AlpnClient> client; std::unique_ptr<AlpnClient> client;
std::unique_ptr<AlpnServer> server; std::unique_ptr<AlpnServer> server;
}; };
...@@ -568,7 +564,7 @@ TEST(AsyncSSLSocketTest, SNITestMatch) { ...@@ -568,7 +564,7 @@ TEST(AsyncSSLSocketTest, SNITestMatch) {
// tlsext_hostname match. // tlsext_hostname match.
std::shared_ptr<SSLContext> hskServerCtx(dfServerCtx); std::shared_ptr<SSLContext> hskServerCtx(dfServerCtx);
const std::string serverName("xyz.newdev.facebook.com"); const std::string serverName("xyz.newdev.facebook.com");
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -602,7 +598,7 @@ TEST(AsyncSSLSocketTest, SNITestNotMatch) { ...@@ -602,7 +598,7 @@ TEST(AsyncSSLSocketTest, SNITestNotMatch) {
const std::string clientRequestingServerName("foo.com"); const std::string clientRequestingServerName("foo.com");
const std::string serverExpectedServerName("xyz.newdev.facebook.com"); const std::string serverExpectedServerName("xyz.newdev.facebook.com");
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -636,7 +632,7 @@ TEST(AsyncSSLSocketTest, SNITestChangeServerName) { ...@@ -636,7 +632,7 @@ TEST(AsyncSSLSocketTest, SNITestChangeServerName) {
// tlsext_hostname match. // tlsext_hostname match.
std::shared_ptr<SSLContext> hskServerCtx(dfServerCtx); std::shared_ptr<SSLContext> hskServerCtx(dfServerCtx);
const std::string serverName("xyz.newdev.facebook.com"); const std::string serverName("xyz.newdev.facebook.com");
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -669,7 +665,7 @@ TEST(AsyncSSLSocketTest, SNITestClientHelloNoHostname) { ...@@ -669,7 +665,7 @@ TEST(AsyncSSLSocketTest, SNITestClientHelloNoHostname) {
std::shared_ptr<SSLContext> hskServerCtx(dfServerCtx); std::shared_ptr<SSLContext> hskServerCtx(dfServerCtx);
const std::string serverExpectedServerName("xyz.newdev.facebook.com"); const std::string serverExpectedServerName("xyz.newdev.facebook.com");
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -915,7 +911,7 @@ TEST(AsyncSSLSocketTest, SSLParseClientHelloSuccess) { ...@@ -915,7 +911,7 @@ TEST(AsyncSSLSocketTest, SSLParseClientHelloSuccess) {
clientCtx->loadCertificate(kTestCert); clientCtx->loadCertificate(kTestCert);
clientCtx->loadTrustedCertificates(kTestCA); clientCtx->loadTrustedCertificates(kTestCA);
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -962,7 +958,7 @@ TEST(AsyncSSLSocketTest, GetClientCertificate) { ...@@ -962,7 +958,7 @@ TEST(AsyncSSLSocketTest, GetClientCertificate) {
clientCtx->loadCertificate(kClientTestCert); clientCtx->loadCertificate(kClientTestCert);
clientCtx->loadTrustedCertificates(kTestCA); clientCtx->loadTrustedCertificates(kTestCA);
std::array<int, 2> fds; std::array<NetworkSocket, 2> fds;
getfds(fds.data()); getfds(fds.data());
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -999,7 +995,7 @@ TEST(AsyncSSLSocketTest, SSLParseClientHelloOnePacket) { ...@@ -999,7 +995,7 @@ TEST(AsyncSSLSocketTest, SSLParseClientHelloOnePacket) {
EventBase eventBase; EventBase eventBase;
auto ctx = std::make_shared<SSLContext>(); auto ctx = std::make_shared<SSLContext>();
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
int bufLen = 42; int bufLen = 42;
...@@ -1041,7 +1037,7 @@ TEST(AsyncSSLSocketTest, SSLParseClientHelloTwoPackets) { ...@@ -1041,7 +1037,7 @@ TEST(AsyncSSLSocketTest, SSLParseClientHelloTwoPackets) {
EventBase eventBase; EventBase eventBase;
auto ctx = std::make_shared<SSLContext>(); auto ctx = std::make_shared<SSLContext>();
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
int bufLen = 42; int bufLen = 42;
...@@ -1100,7 +1096,7 @@ TEST(AsyncSSLSocketTest, SSLParseClientHelloMultiplePackets) { ...@@ -1100,7 +1096,7 @@ TEST(AsyncSSLSocketTest, SSLParseClientHelloMultiplePackets) {
EventBase eventBase; EventBase eventBase;
auto ctx = std::make_shared<SSLContext>(); auto ctx = std::make_shared<SSLContext>();
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
int bufLen = 42; int bufLen = 42;
...@@ -1156,7 +1152,7 @@ TEST(AsyncSSLSocketTest, SSLHandshakeValidationSuccess) { ...@@ -1156,7 +1152,7 @@ TEST(AsyncSSLSocketTest, SSLHandshakeValidationSuccess) {
auto clientCtx = std::make_shared<SSLContext>(); auto clientCtx = std::make_shared<SSLContext>();
auto dfServerCtx = std::make_shared<SSLContext>(); auto dfServerCtx = std::make_shared<SSLContext>();
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -1194,7 +1190,7 @@ TEST(AsyncSSLSocketTest, SSLHandshakeValidationFailure) { ...@@ -1194,7 +1190,7 @@ TEST(AsyncSSLSocketTest, SSLHandshakeValidationFailure) {
auto clientCtx = std::make_shared<SSLContext>(); auto clientCtx = std::make_shared<SSLContext>();
auto dfServerCtx = std::make_shared<SSLContext>(); auto dfServerCtx = std::make_shared<SSLContext>();
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -1234,7 +1230,7 @@ TEST(AsyncSSLSocketTest, OverrideSSLCtxDisableVerify) { ...@@ -1234,7 +1230,7 @@ TEST(AsyncSSLSocketTest, OverrideSSLCtxDisableVerify) {
auto clientCtx = std::make_shared<SSLContext>(); auto clientCtx = std::make_shared<SSLContext>();
auto dfServerCtx = std::make_shared<SSLContext>(); auto dfServerCtx = std::make_shared<SSLContext>();
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -1285,7 +1281,7 @@ TEST(AsyncSSLSocketTest, OverrideSSLCtxEnableVerify) { ...@@ -1285,7 +1281,7 @@ TEST(AsyncSSLSocketTest, OverrideSSLCtxEnableVerify) {
clientCtx->loadCertificate(kTestCert); clientCtx->loadCertificate(kTestCert);
clientCtx->loadTrustedCertificates(kTestCA); clientCtx->loadTrustedCertificates(kTestCA);
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -1317,7 +1313,7 @@ TEST(AsyncSSLSocketTest, SSLHandshakeValidationOverride) { ...@@ -1317,7 +1313,7 @@ TEST(AsyncSSLSocketTest, SSLHandshakeValidationOverride) {
auto clientCtx = std::make_shared<SSLContext>(); auto clientCtx = std::make_shared<SSLContext>();
auto dfServerCtx = std::make_shared<SSLContext>(); auto dfServerCtx = std::make_shared<SSLContext>();
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -1354,7 +1350,7 @@ TEST(AsyncSSLSocketTest, SSLHandshakeValidationSkip) { ...@@ -1354,7 +1350,7 @@ TEST(AsyncSSLSocketTest, SSLHandshakeValidationSkip) {
auto clientCtx = std::make_shared<SSLContext>(); auto clientCtx = std::make_shared<SSLContext>();
auto dfServerCtx = std::make_shared<SSLContext>(); auto dfServerCtx = std::make_shared<SSLContext>();
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -1402,7 +1398,7 @@ TEST(AsyncSSLSocketTest, ClientCertHandshakeSuccess) { ...@@ -1402,7 +1398,7 @@ TEST(AsyncSSLSocketTest, ClientCertHandshakeSuccess) {
clientCtx->loadCertificate(kTestCert); clientCtx->loadCertificate(kTestCert);
clientCtx->loadTrustedCertificates(kTestCA); clientCtx->loadTrustedCertificates(kTestCA);
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -1459,7 +1455,7 @@ TEST(AsyncSSLSocketTest, NoClientCertHandshakeError) { ...@@ -1459,7 +1455,7 @@ TEST(AsyncSSLSocketTest, NoClientCertHandshakeError) {
clientCtx->setVerificationOption(SSLContext::SSLVerifyPeerEnum::NO_VERIFY); clientCtx->setVerificationOption(SSLContext::SSLVerifyPeerEnum::NO_VERIFY);
clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -1684,7 +1680,7 @@ TEST(AsyncSSLSocketTest, OpenSSL110AsyncTest) { ...@@ -1684,7 +1680,7 @@ TEST(AsyncSSLSocketTest, OpenSSL110AsyncTest) {
clientCtx->setVerificationOption(SSLContext::SSLVerifyPeerEnum::NO_VERIFY); clientCtx->setVerificationOption(SSLContext::SSLVerifyPeerEnum::NO_VERIFY);
clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -1722,7 +1718,7 @@ TEST(AsyncSSLSocketTest, OpenSSL110AsyncTestFailure) { ...@@ -1722,7 +1718,7 @@ TEST(AsyncSSLSocketTest, OpenSSL110AsyncTestFailure) {
clientCtx->setVerificationOption(SSLContext::SSLVerifyPeerEnum::NO_VERIFY); clientCtx->setVerificationOption(SSLContext::SSLVerifyPeerEnum::NO_VERIFY);
clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -1761,7 +1757,7 @@ TEST(AsyncSSLSocketTest, OpenSSL110AsyncTestClosedWithCallbackPending) { ...@@ -1761,7 +1757,7 @@ TEST(AsyncSSLSocketTest, OpenSSL110AsyncTestClosedWithCallbackPending) {
clientCtx->setVerificationOption(SSLContext::SSLVerifyPeerEnum::NO_VERIFY); clientCtx->setVerificationOption(SSLContext::SSLVerifyPeerEnum::NO_VERIFY);
clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -1875,7 +1871,7 @@ TEST(AsyncSSLSocketTest, UnencryptedTest) { ...@@ -1875,7 +1871,7 @@ TEST(AsyncSSLSocketTest, UnencryptedTest) {
auto clientCtx = std::make_shared<folly::SSLContext>(); auto clientCtx = std::make_shared<folly::SSLContext>();
auto serverCtx = std::make_shared<folly::SSLContext>(); auto serverCtx = std::make_shared<folly::SSLContext>();
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
getctx(clientCtx, serverCtx); getctx(clientCtx, serverCtx);
auto client = auto client =
...@@ -1892,7 +1888,7 @@ TEST(AsyncSSLSocketTest, UnencryptedTest) { ...@@ -1892,7 +1888,7 @@ TEST(AsyncSSLSocketTest, UnencryptedTest) {
// Check that bytes are unencrypted // Check that bytes are unencrypted
char c; char c;
EXPECT_EQ(1, recv(fds[1], &c, 1, MSG_PEEK)); EXPECT_EQ(1, netops::recv(fds[1], &c, 1, MSG_PEEK));
EXPECT_EQ('a', c); EXPECT_EQ('a', c);
EventBaseAborter eba(&base, 3000); EventBaseAborter eba(&base, 3000);
...@@ -1913,7 +1909,7 @@ TEST(AsyncSSLSocketTest, UnencryptedTest) { ...@@ -1913,7 +1909,7 @@ TEST(AsyncSSLSocketTest, UnencryptedTest) {
// Check that bytes are *not* unencrypted // Check that bytes are *not* unencrypted
char c2; char c2;
EXPECT_EQ(1, recv(fds[1], &c2, 1, MSG_PEEK)); EXPECT_EQ(1, netops::recv(fds[1], &c2, 1, MSG_PEEK));
EXPECT_NE('a', c2); EXPECT_NE('a', c2);
base.loop(); base.loop();
...@@ -1968,7 +1964,7 @@ TEST(AsyncSSLSocketTest, SSLAcceptRunnerBasic) { ...@@ -1968,7 +1964,7 @@ TEST(AsyncSSLSocketTest, SSLAcceptRunnerBasic) {
clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
clientCtx->loadTrustedCertificates(kTestCA); clientCtx->loadTrustedCertificates(kTestCA);
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -2003,7 +1999,7 @@ TEST(AsyncSSLSocketTest, SSLAcceptRunnerAcceptError) { ...@@ -2003,7 +1999,7 @@ TEST(AsyncSSLSocketTest, SSLAcceptRunnerAcceptError) {
clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
clientCtx->loadTrustedCertificates(kTestCA); clientCtx->loadTrustedCertificates(kTestCA);
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -2037,7 +2033,7 @@ TEST(AsyncSSLSocketTest, SSLAcceptRunnerAcceptClose) { ...@@ -2037,7 +2033,7 @@ TEST(AsyncSSLSocketTest, SSLAcceptRunnerAcceptClose) {
clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
clientCtx->loadTrustedCertificates(kTestCA); clientCtx->loadTrustedCertificates(kTestCA);
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -2071,7 +2067,7 @@ TEST(AsyncSSLSocketTest, SSLAcceptRunnerAcceptDestroy) { ...@@ -2071,7 +2067,7 @@ TEST(AsyncSSLSocketTest, SSLAcceptRunnerAcceptDestroy) {
clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); clientCtx->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
clientCtx->loadTrustedCertificates(kTestCA); clientCtx->loadTrustedCertificates(kTestCA);
int fds[2]; NetworkSocket fds[2];
getfds(fds); getfds(fds);
AsyncSSLSocket::UniquePtr clientSock( AsyncSSLSocket::UniquePtr clientSock(
...@@ -2492,7 +2488,7 @@ TEST(AsyncSSLSocketTest, TestPreReceivedData) { ...@@ -2492,7 +2488,7 @@ TEST(AsyncSSLSocketTest, TestPreReceivedData) {
EventBase eventBase; EventBase eventBase;
auto clientCtx = std::make_shared<SSLContext>(); auto clientCtx = std::make_shared<SSLContext>();
auto dfServerCtx = std::make_shared<SSLContext>(); auto dfServerCtx = std::make_shared<SSLContext>();
std::array<int, 2> fds; std::array<NetworkSocket, 2> fds;
getfds(fds.data()); getfds(fds.data());
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -2506,7 +2502,7 @@ TEST(AsyncSSLSocketTest, TestPreReceivedData) { ...@@ -2506,7 +2502,7 @@ TEST(AsyncSSLSocketTest, TestPreReceivedData) {
// Steal some data from the server. // Steal some data from the server.
std::array<uint8_t, 10> buf; std::array<uint8_t, 10> buf;
auto bytesReceived = recv(fds[1], buf.data(), buf.size(), 0); auto bytesReceived = netops::recv(fds[1], buf.data(), buf.size(), 0);
checkUnixError(bytesReceived, "recv failed"); checkUnixError(bytesReceived, "recv failed");
serverSock->setPreReceivedData( serverSock->setPreReceivedData(
...@@ -2526,7 +2522,7 @@ TEST(AsyncSSLSocketTest, TestMoveFromAsyncSocket) { ...@@ -2526,7 +2522,7 @@ TEST(AsyncSSLSocketTest, TestMoveFromAsyncSocket) {
EventBase eventBase; EventBase eventBase;
auto clientCtx = std::make_shared<SSLContext>(); auto clientCtx = std::make_shared<SSLContext>();
auto dfServerCtx = std::make_shared<SSLContext>(); auto dfServerCtx = std::make_shared<SSLContext>();
std::array<int, 2> fds; std::array<NetworkSocket, 2> fds;
getfds(fds.data()); getfds(fds.data());
getctx(clientCtx, dfServerCtx); getctx(clientCtx, dfServerCtx);
...@@ -2539,7 +2535,7 @@ TEST(AsyncSSLSocketTest, TestMoveFromAsyncSocket) { ...@@ -2539,7 +2535,7 @@ TEST(AsyncSSLSocketTest, TestMoveFromAsyncSocket) {
// Steal some data from the server. // Steal some data from the server.
std::array<uint8_t, 10> buf; std::array<uint8_t, 10> buf;
auto bytesReceived = recv(fds[1], buf.data(), buf.size(), 0); auto bytesReceived = netops::recv(fds[1], buf.data(), buf.size(), 0);
checkUnixError(bytesReceived, "recv failed"); checkUnixError(bytesReceived, "recv failed");
serverSock->setPreReceivedData( serverSock->setPreReceivedData(
......
...@@ -776,7 +776,7 @@ class TestSSLAsyncCacheServer : public TestSSLServer { ...@@ -776,7 +776,7 @@ class TestSSLAsyncCacheServer : public TestSSLServer {
} }
}; };
void getfds(int fds[2]); void getfds(NetworkSocket fds[2]);
void getctx( void getctx(
std::shared_ptr<folly::SSLContext> clientCtx, std::shared_ptr<folly::SSLContext> clientCtx,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment