proxygen
folly::HandshakeErrorCallback Class Reference

#include <AsyncSSLSocketTest.h>

Inheritance diagram for folly::HandshakeErrorCallback:
folly::SSLServerAcceptCallbackBase folly::AsyncServerSocket::AcceptCallback

Public Member Functions

 HandshakeErrorCallback (HandshakeCallback *hcb)
 
void connAccepted (const std::shared_ptr< folly::AsyncSSLSocket > &s) noexceptoverride
 
- Public Member Functions inherited from folly::SSLServerAcceptCallbackBase
 SSLServerAcceptCallbackBase (HandshakeCallback *hcb)
 
 ~SSLServerAcceptCallbackBase () override
 
void acceptError (const std::exception &ex) noexceptoverride
 
void connectionAccepted (int fd, const SocketAddress &) noexceptoverride
 
void detach ()
 
- Public Member Functions inherited from folly::AsyncServerSocket::AcceptCallback
virtual ~AcceptCallback ()=default
 
virtual void acceptStarted () noexcept
 
virtual void acceptStopped () noexcept
 

Additional Inherited Members

- Public Attributes inherited from folly::SSLServerAcceptCallbackBase
StateEnum state
 
HandshakeCallbackhcb_
 
std::shared_ptr< SSLContextctx_
 
std::shared_ptr< AsyncSSLSocketsocket_
 
EventBasebase_
 

Detailed Description

Definition at line 635 of file AsyncSSLSocketTest.h.

Constructor & Destructor Documentation

folly::HandshakeErrorCallback::HandshakeErrorCallback ( HandshakeCallback hcb)
inlineexplicit

Definition at line 637 of file AsyncSSLSocketTest.h.

SSLServerAcceptCallbackBase(HandshakeCallback *hcb)
Definition: TestSSLServer.h:51

Member Function Documentation

void folly::HandshakeErrorCallback::connAccepted ( const std::shared_ptr< folly::AsyncSSLSocket > &  s)
inlineoverridevirtualnoexcept

Implements folly::SSLServerAcceptCallbackBase.

Definition at line 640 of file AsyncSSLSocketTest.h.

References EXPECT_EQ, s, folly::AsyncSSLSocket::sslAccept(), folly::AsyncSSLSocket::STATE_ACCEPTING, folly::AsyncSSLSocket::STATE_ERROR, folly::STATE_FAILED, and folly::STATE_SUCCEEDED.

641  {
642  auto sock = std::static_pointer_cast<AsyncSSLSocket>(s);
643 
644  std::cerr << "HandshakeErrorCallback::connAccepted" << std::endl;
645 
646  // The first call to sslAccept() should succeed.
647  hcb_->setSocket(sock);
648  sock->sslAccept(hcb_);
649  EXPECT_EQ(sock->getSSLState(), AsyncSSLSocket::STATE_ACCEPTING);
650 
651  // The second call to sslAccept() should fail.
652  HandshakeCallback callback2(hcb_->rcb_);
653  callback2.setSocket(sock);
654  sock->sslAccept(&callback2);
655  EXPECT_EQ(sock->getSSLState(), AsyncSSLSocket::STATE_ERROR);
656 
657  // Both callbacks should be in the error state.
659  EXPECT_EQ(callback2.state, STATE_FAILED);
660 
663  callback2.setState(STATE_SUCCEEDED);
664  }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void setSocket(const std::shared_ptr< AsyncSSLSocket > &socket)
static set< string > s
state
Definition: http_parser.c:272

The documentation for this class was generated from the following file: