proxygen
fizz::test::AsyncFizzBaseTest Class Reference
Inheritance diagram for fizz::test::AsyncFizzBaseTest:
testing::Test fizz::AsyncFizzBase folly::WriteChainAsyncTransportWrapper< folly::AsyncTransportWrapper > folly::AsyncWriter::WriteCallback folly::AsyncReader::ReadCallback folly::DecoratedAsyncTransportWrapper< folly::AsyncTransportWrapper > folly::AsyncTransportWrapper folly::AsyncTransport folly::AsyncReader folly::AsyncWriter folly::DelayedDestruction folly::AsyncSocketBase folly::DelayedDestructionBase

Public Member Functions

 AsyncFizzBaseTest ()
 
void TearDown () override
 
 MOCK_CONST_METHOD0 (good, bool())
 
 MOCK_CONST_METHOD0 (readable, bool())
 
 MOCK_CONST_METHOD0 (connecting, bool())
 
 MOCK_CONST_METHOD0 (error, bool())
 
 MOCK_CONST_METHOD0 (getPeerCert, folly::ssl::X509UniquePtr())
 
 MOCK_CONST_METHOD0 (getSelfCert, const X509 *())
 
 MOCK_CONST_METHOD0 (isReplaySafe, bool())
 
 MOCK_METHOD1 (setReplaySafetyCallback, void(folly::AsyncTransport::ReplaySafetyCallback *callback))
 
 MOCK_CONST_METHOD0 (getSelfCertificate, const Cert *())
 
 MOCK_CONST_METHOD0 (getPeerCertificate, const Cert *())
 
 MOCK_CONST_METHOD0 (getApplicationProtocol_, std::string())
 
std::string getApplicationProtocol () const noexceptoverride
 
 MOCK_CONST_METHOD0 (getCipher, folly::Optional< CipherSuite >())
 
 MOCK_CONST_METHOD0 (getSupportedSigSchemes, std::vector< SignatureScheme >())
 
 MOCK_CONST_METHOD3 (getEkm, Buf(folly::StringPiece, const Buf &, uint16_t))
 
 MOCK_METHOD3 (writeAppDataInternal, void(folly::AsyncTransportWrapper::WriteCallback *, std::shared_ptr< folly::IOBuf >, folly::WriteFlags))
 
void writeAppData (folly::AsyncTransportWrapper::WriteCallback *callback, std::unique_ptr< folly::IOBuf > &&buf, folly::WriteFlags flags=folly::WriteFlags::NONE) override
 
 MOCK_METHOD1 (transportError, void(const folly::AsyncSocketException &))
 
 MOCK_METHOD0 (transportDataAvailable, void())
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 
- Public Member Functions inherited from fizz::AsyncFizzBase
 AsyncFizzBase (folly::AsyncTransportWrapper::UniquePtr transport)
 
 ~AsyncFizzBase () override
 
ReadCallbackgetReadCallback () const override
 
void setReadCB (ReadCallback *callback) override
 
void writeChain (folly::AsyncTransportWrapper::WriteCallback *callback, std::unique_ptr< folly::IOBuf > &&buf, folly::WriteFlags flags=folly::WriteFlags::NONE) override
 
size_t getAppBytesWritten () const override
 
size_t getAppBytesReceived () const override
 
bool good () const override=0
 
bool readable () const override=0
 
bool connecting () const override=0
 
bool error () const override=0
 
folly::ssl::X509UniquePtr getPeerCert () const override=0
 
const X509 * getSelfCert () const override=0
 
const CertgetPeerCertificate () const override=0
 
const CertgetSelfCertificate () const override=0
 
bool isReplaySafe () const override=0
 
void setReplaySafetyCallback (folly::AsyncTransport::ReplaySafetyCallback *callback) override=0
 
virtual folly::Optional< CipherSuitegetCipher () const =0
 
virtual std::vector< SignatureSchemegetSupportedSigSchemes () const =0
 
virtual Buf getEkm (folly::StringPiece label, const Buf &context, uint16_t length) const =0
 
void destroy () override
 
std::string getSecurityProtocol () const override
 
void attachTimeoutManager (folly::TimeoutManager *manager)
 
void detachTimeoutManager ()
 
void attachEventBase (folly::EventBase *eventBase) override
 
void detachEventBase () override
 
bool isDetachable () const override
 
- Public Member Functions inherited from folly::WriteChainAsyncTransportWrapper< folly::AsyncTransportWrapper >
void write (folly::AsyncTransportWrapper::WriteCallback *callback, const void *buf, size_t bytes, folly::WriteFlags flags=folly::WriteFlags::NONE) override
 
void writev (folly::AsyncTransportWrapper::WriteCallback *callback, const iovec *vec, size_t count, folly::WriteFlags flags=folly::WriteFlags::NONE) override
 
- Public Member Functions inherited from folly::DecoratedAsyncTransportWrapper< folly::AsyncTransportWrapper >
 DecoratedAsyncTransportWrapper (typename folly::AsyncTransportWrapper::UniquePtr transport)
 
const AsyncTransportWrappergetWrappedTransport () const override
 
ReadCallbackgetReadCallback () const override
 
void setReadCB (folly::AsyncTransportWrapper::ReadCallback *callback) override
 
folly::EventBasegetEventBase () const override
 
void attachEventBase (folly::EventBase *eventBase) override
 
void close () override
 
void closeNow () override
 
void closeWithReset () override
 
bool connecting () const override
 
void detachEventBase () override
 
bool error () const override
 
size_t getAppBytesReceived () const override
 
size_t getAppBytesWritten () const override
 
void getLocalAddress (folly::SocketAddress *address) const override
 
void getPeerAddress (folly::SocketAddress *address) const override
 
folly::ssl::X509UniquePtr getPeerCert () const override
 
size_t getRawBytesReceived () const override
 
size_t getRawBytesWritten () const override
 
uint32_t getSendTimeout () const override
 
bool good () const override
 
bool isDetachable () const override
 
bool isEorTrackingEnabled () const override
 
bool readable () const override
 
bool writable () const override
 
void setEorTracking (bool track) override
 
void setSendTimeout (uint32_t timeoutInMs) override
 
void shutdownWrite () override
 
void shutdownWriteNow () override
 
std::string getApplicationProtocol () const noexceptoverride
 
std::string getSecurityProtocol () const override
 
bool isReplaySafe () const override
 
void setReplaySafetyCallback (folly::AsyncTransport::ReplaySafetyCallback *callback) override
 
const AsyncTransportCertificategetPeerCertificate () const override
 
const AsyncTransportCertificategetSelfCertificate () const override
 
- Public Member Functions inherited from folly::AsyncTransportWrapper
template<class T >
const TgetUnderlyingTransport () const
 
template<class T >
TgetUnderlyingTransport ()
 
- Public Member Functions inherited from folly::AsyncTransport
virtual bool isPending () const
 
SocketAddress getLocalAddress () const
 
void getAddress (SocketAddress *address) const override
 
SocketAddress getPeerAddress () const
 
- Public Member Functions inherited from folly::DelayedDestruction
bool getDestroyPending () const
 
- Public Member Functions inherited from folly::DelayedDestructionBase
virtual ~DelayedDestructionBase ()=default
 
- Public Member Functions inherited from folly::AsyncSocketBase
virtual ~AsyncSocketBase ()=default
 

Protected Member Functions

void expectReadBufRequest (size_t sizeToGive)
 
void expectReadData (const std::string &data)
 
void expectTransportReadCallback ()
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void SetUp ()
 
 Test ()
 
virtual void SetUp ()
 
 Test ()
 
virtual void SetUp ()
 
- Protected Member Functions inherited from fizz::AsyncFizzBase
virtual void startTransportReads ()
 
virtual void startHandshakeTimeout (std::chrono::milliseconds)
 
virtual void cancelHandshakeTimeout ()
 
virtual void deliverAppData (std::unique_ptr< folly::IOBuf > buf)
 
virtual void deliverError (const folly::AsyncSocketException &ex, bool closeTransport=true)
 
virtual void transportError (const folly::AsyncSocketException &ex)=0
 
virtual void transportDataAvailable ()=0
 
- Protected Member Functions inherited from folly::DecoratedAsyncTransportWrapper< folly::AsyncTransportWrapper >
 ~DecoratedAsyncTransportWrapper () override
 
- Protected Member Functions inherited from folly::AsyncTransport
 ~AsyncTransport () override=default
 
- Protected Member Functions inherited from folly::DelayedDestruction
 ~DelayedDestruction () override=default
 
 DelayedDestruction ()
 
- Protected Member Functions inherited from folly::DelayedDestructionBase
 DelayedDestructionBase ()
 
uint32_t getDestructorGuardCount () const
 
- Protected Member Functions inherited from folly::AsyncReader
virtual ~AsyncReader ()=default
 
- Protected Member Functions inherited from folly::AsyncWriter
virtual ~AsyncWriter ()=default
 
- Protected Member Functions inherited from folly::AsyncWriter::WriteCallback
virtual ~WriteCallback ()=default
 

Protected Attributes

MockAsyncTransportsocket_
 
StrictMock< folly::test::MockReadCallbackreadCallback_
 
ReadCallbacktransportReadCallback_
 
AsyncSocketException ase_ {AsyncSocketException::UNKNOWN, "unit test"}
 
AsyncSocketException eof_ {AsyncSocketException::END_OF_FILE, "unit test eof"}
 
Sequence readBufSeq_
 
std::vector< uint8_treadBuf_
 
- Protected Attributes inherited from fizz::AsyncFizzBase
folly::IOBufQueue transportReadBuf_ {folly::IOBufQueue::cacheChainLength()}
 
- Protected Attributes inherited from folly::DecoratedAsyncTransportWrapper< folly::AsyncTransportWrapper >
folly::AsyncTransportWrapper::UniquePtr transport_
 

Additional Inherited Members

- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
- Public Types inherited from fizz::AsyncFizzBase
using UniquePtr = std::unique_ptr< AsyncFizzBase, folly::DelayedDestruction::Destructor >
 
using ReadCallback = folly::AsyncTransportWrapper::ReadCallback
 
- Public Types inherited from folly::AsyncTransportWrapper
using UniquePtr = std::unique_ptr< AsyncTransportWrapper, Destructor >
 
using ReadCallback = AsyncReader::ReadCallback
 
using WriteCallback = AsyncWriter::WriteCallback
 
- Public Types inherited from folly::AsyncTransport
typedef std::unique_ptr< AsyncTransport, DestructorUniquePtr
 
- Static Public Member Functions inherited from testing::Test
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 

Detailed Description

The test class itself implements AsyncFizzBase so that it has access to the app data interfaces.

Definition at line 28 of file AsyncFizzBaseTest.cpp.

Constructor & Destructor Documentation

fizz::test::AsyncFizzBaseTest::AsyncFizzBaseTest ( )
inline

Definition at line 30 of file AsyncFizzBaseTest.cpp.

References ON_CALL, testing::Return(), and socket_.

31  : testing::Test(),
34  socket_ = getUnderlyingTransport<MockAsyncTransport>();
35  ON_CALL(*this, good()).WillByDefault(Return(true));
36  }
AsyncFizzBase(folly::AsyncTransportWrapper::UniquePtr transport)
bool good() const override=0
std::unique_ptr< AsyncTransportWrapper, Destructor > UniquePtr
#define ON_CALL(obj, call)
internal::ReturnAction< R > Return(R value)

Member Function Documentation

void fizz::test::AsyncFizzBaseTest::expectReadBufRequest ( size_t  sizeToGive)
inlineprotected

Definition at line 83 of file AsyncFizzBaseTest.cpp.

References testing::_, testing::DoAll(), EXPECT_CALL, and readBuf_.

83  {
84  readBuf_.resize(sizeToGive);
86  .InSequence(readBufSeq_)
87  .WillOnce(DoAll(
88  SetArgPointee<0>(readBuf_.data()),
89  SetArgPointee<1>(readBuf_.size())));
90  }
std::vector< uint8_t > readBuf_
StrictMock< folly::test::MockReadCallback > readCallback_
void getReadBuffer(void **bufReturn, size_t *lenReturn) override
internal::DoBothAction< Action1, Action2 > DoAll(Action1 a1, Action2 a2)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void fizz::test::AsyncFizzBaseTest::expectReadData ( const std::string data)
inlineprotected

Definition at line 92 of file AsyncFizzBaseTest.cpp.

References EXPECT_CALL, EXPECT_TRUE, testing::Invoke(), and readBuf_.

92  {
93  EXPECT_CALL(readCallback_, readDataAvailable_(data.size()))
94  .InSequence(readBufSeq_)
95  .WillOnce(Invoke([this, data](size_t len) {
96  EXPECT_TRUE(std::memcmp(readBuf_.data(), data.data(), len) == 0);
97  }));
98  }
std::vector< uint8_t > readBuf_
StrictMock< folly::test::MockReadCallback > readCallback_
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
void fizz::test::AsyncFizzBaseTest::expectTransportReadCallback ( )
inlineprotected

Definition at line 100 of file AsyncFizzBaseTest.cpp.

References testing::_, EXPECT_CALL, and socket_.

100  {
102  .WillOnce(SaveArg<0>(&transportReadCallback_));
103  }
void setReadCB(ReadCallback *callback) override
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
std::string fizz::test::AsyncFizzBaseTest::getApplicationProtocol ( ) const
inlineoverridevirtualnoexcept

Return the application protocol being used by the underlying transport protocol. This is useful for transports which are used to tunnel other protocols.

Implements fizz::AsyncFizzBase.

Definition at line 56 of file AsyncFizzBaseTest.cpp.

References fizz::test::getCipher(), MOCK_CONST_METHOD0, MOCK_CONST_METHOD3, MOCK_METHOD3, and uint16_t.

56  {
57  return getApplicationProtocol_();
58  }
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( good  ,
bool()   
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( readable  ,
bool()   
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( connecting  ,
bool()   
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( error  ,
bool()   
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( getPeerCert  ,
folly::ssl::X509UniquePtr()   
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( getSelfCert  ,
const X509 *  () 
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( isReplaySafe  ,
bool()   
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( getSelfCertificate  ,
const Cert () 
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( getPeerCertificate  ,
const Cert () 
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( getApplicationProtocol_  ,
std::string()   
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( getCipher  ,
folly::Optional< CipherSuite () 
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD0 ( getSupportedSigSchemes  ,
std::vector< SignatureScheme () 
)
fizz::test::AsyncFizzBaseTest::MOCK_CONST_METHOD3 ( getEkm  ,
Buf(folly::StringPiece, const Buf &, uint16_t  
)
fizz::test::AsyncFizzBaseTest::MOCK_METHOD0 ( transportDataAvailable  ,
void()   
)
fizz::test::AsyncFizzBaseTest::MOCK_METHOD1 ( setReplaySafetyCallback  ,
void(folly::AsyncTransport::ReplaySafetyCallback *callback)   
)
fizz::test::AsyncFizzBaseTest::MOCK_METHOD1 ( transportError  ,
void(const folly::AsyncSocketException &)   
)
fizz::test::AsyncFizzBaseTest::MOCK_METHOD3 ( writeAppDataInternal  ,
void(folly::AsyncTransportWrapper::WriteCallback *, std::shared_ptr< folly::IOBuf >, folly::WriteFlags  
)
void fizz::test::AsyncFizzBaseTest::TearDown ( )
inlineoverridevirtual

Reimplemented from testing::Test.

Definition at line 38 of file AsyncFizzBaseTest.cpp.

References folly::pushmi::operators::error(), EXPECT_CALL, fizz::test::getPeerCert(), MOCK_CONST_METHOD0, MOCK_METHOD1, socket_, and string.

38  {
39  EXPECT_CALL(*socket_, setReadCB(nullptr));
40  }
void setReadCB(ReadCallback *callback) override
#define EXPECT_CALL(obj, call)
void fizz::test::AsyncFizzBaseTest::writeAppData ( folly::AsyncTransportWrapper::WriteCallback callback,
std::unique_ptr< folly::IOBuf > &&  buf,
folly::WriteFlags  flags = folly::WriteFlags::NONE 
)
inlineoverridevirtual

Interface for the derived class to implement to receive app data from the app layer.

Implements fizz::AsyncFizzBase.

Definition at line 71 of file AsyncFizzBaseTest.cpp.

References MOCK_METHOD0, and MOCK_METHOD1.

74  {
75  writeAppDataInternal(
76  callback, std::shared_ptr<folly::IOBuf>(buf.release()), flags);
77  }
flags
Definition: http_parser.h:127

Member Data Documentation

AsyncSocketException fizz::test::AsyncFizzBaseTest::ase_ {AsyncSocketException::UNKNOWN, "unit test"}
protected

Definition at line 108 of file AsyncFizzBaseTest.cpp.

AsyncSocketException fizz::test::AsyncFizzBaseTest::eof_ {AsyncSocketException::END_OF_FILE, "unit test eof"}
protected

Definition at line 109 of file AsyncFizzBaseTest.cpp.

std::vector<uint8_t> fizz::test::AsyncFizzBaseTest::readBuf_
protected

Definition at line 111 of file AsyncFizzBaseTest.cpp.

Sequence fizz::test::AsyncFizzBaseTest::readBufSeq_
protected

Definition at line 110 of file AsyncFizzBaseTest.cpp.

StrictMock<folly::test::MockReadCallback> fizz::test::AsyncFizzBaseTest::readCallback_
protected

Definition at line 106 of file AsyncFizzBaseTest.cpp.

MockAsyncTransport* fizz::test::AsyncFizzBaseTest::socket_
protected

Definition at line 105 of file AsyncFizzBaseTest.cpp.

ReadCallback* fizz::test::AsyncFizzBaseTest::transportReadCallback_
protected

Definition at line 107 of file AsyncFizzBaseTest.cpp.


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