proxygen
fizz::client::test::AsyncFizzClientTest Class Reference
Inheritance diagram for fizz::client::test::AsyncFizzClientTest:
testing::Test

Public Member Functions

void SetUp () override
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 

Protected Member Functions

void expectTransportReadCallback ()
 
void expectAppClose ()
 
void connect ()
 
void fullHandshakeSuccess (bool acceptEarlyData, std::string alpn="h2", std::shared_ptr< const Cert > clientCert=nullptr, std::shared_ptr< const Cert > serverCert=nullptr, bool pskResumed=false)
 
void completeHandshake ()
 
void completeEarlyHandshake (EarlyDataParams params=getEarlyDataParams())
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 

Static Protected Member Functions

static EarlyDataParams getEarlyDataParams ()
 

Protected Attributes

AsyncFizzClientT< MockClientStateMachineInstance >::UniquePtr client_
 
std::shared_ptr< FizzClientContextcontext_
 
std::shared_ptr< MockPskCachemockPskCache_
 
MockAsyncTransportsocket_
 
MockClientStateMachineInstancemachine_
 
AsyncTransportWrapper::ReadCallbacksocketReadCallback_
 
MockHandshakeCallbackT< MockClientStateMachineInstancehandshakeCallback_
 
MockReadCallback readCallback_
 
MockWriteCallback writeCallback_
 
EventBase evb_
 
MockReplaySafetyCallback mockReplayCallback_
 
folly::Optional< std::stringpskIdentity_ {"pskIdentity"}
 

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
 
- 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

Definition at line 52 of file AsyncFizzClientTest.cpp.

Member Function Documentation

void fizz::client::test::AsyncFizzClientTest::completeEarlyHandshake ( EarlyDataParams  params = getEarlyDataParams())
inlineprotected

Definition at line 145 of file AsyncFizzClientTest.cpp.

References testing::_, fizz::client::detail::actions(), folly::netops::connect(), folly::IOBuf::copyBuffer(), EXPECT_CALL, EXPECT_FALSE, testing::InvokeWithoutArgs(), fizz::client::ReportEarlyHandshakeSuccess::maxEarlyDataSize, folly::gen::move, and params.

145  {
146  connect();
147  EXPECT_CALL(*machine_, _processSocketData(_, _))
148  .WillOnce(InvokeWithoutArgs([&params]() {
149  auto addParamsToState =
150  [params = std::move(params)](State& newState) mutable {
151  newState.earlyDataParams() = std::move(params);
152  };
153  ReportEarlyHandshakeSuccess reportSuccess;
154  reportSuccess.maxEarlyDataSize = 1000;
155  return detail::actions(
156  std::move(addParamsToState),
157  std::move(reportSuccess),
158  WaitForData());
159  }));
160  EXPECT_CALL(handshakeCallback_, _fizzHandshakeSuccess());
162  EXPECT_FALSE(client_->isReplaySafe());
163  }
virtual void readBufferAvailable(std::unique_ptr< IOBuf >) noexcept
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
MockHandshakeCallbackT< MockClientStateMachineInstance > handshakeCallback_
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
constexpr Params params[]
AsyncTransportWrapper::ReadCallback * socketReadCallback_
MockClientStateMachineInstance * machine_
Actions actions(Args &&...act)
Definition: Actions.h:86
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
AsyncFizzClientT< MockClientStateMachineInstance >::UniquePtr client_
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
void fizz::client::test::AsyncFizzClientTest::completeHandshake ( )
inlineprotected

Definition at line 131 of file AsyncFizzClientTest.cpp.

References folly::netops::connect(), and EXPECT_CALL.

131  {
132  connect();
133  EXPECT_CALL(handshakeCallback_, _fizzHandshakeSuccess());
134  fullHandshakeSuccess(false);
135  }
void fullHandshakeSuccess(bool acceptEarlyData, std::string alpn="h2", std::shared_ptr< const Cert > clientCert=nullptr, std::shared_ptr< const Cert > serverCert=nullptr, bool pskResumed=false)
MockHandshakeCallbackT< MockClientStateMachineInstance > handshakeCallback_
#define EXPECT_CALL(obj, call)
void fizz::client::test::AsyncFizzClientTest::connect ( )
inlineprotected

Definition at line 89 of file AsyncFizzClientTest.cpp.

References testing::_, EXPECT_CALL, testing::InvokeWithoutArgs(), sni, and string.

89  {
91  EXPECT_CALL(*machine_, _processConnect(_, _, _, _, _, _))
92  .WillOnce(InvokeWithoutArgs([]() { return Actions(); }));
93  const auto sni = std::string("www.example.com");
94  client_->connect(&handshakeCallback_, nullptr, sni, pskIdentity_);
95  }
MockHandshakeCallbackT< MockClientStateMachineInstance > handshakeCallback_
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
std::vector< Action > Actions
Definition: Actions.h:81
folly::Optional< std::string > pskIdentity_
MockClientStateMachineInstance * machine_
StringPiece sni
const char * string
Definition: Conv.cpp:212
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
AsyncFizzClientT< MockClientStateMachineInstance >::UniquePtr client_
void fizz::client::test::AsyncFizzClientTest::expectAppClose ( )
inlineprotected

Definition at line 74 of file AsyncFizzClientTest.cpp.

References testing::_, fizz::client::detail::actions(), fizz::WriteToSocket::contents, fizz::TLSContent::contentType, folly::IOBuf::copyBuffer(), fizz::TLSContent::data, fizz::TLSContent::encryptionLevel, fizz::client::Error, EXPECT_CALL, fizz::Handshake, fizz::handshake, testing::InvokeWithoutArgs(), folly::gen::move, fizz::test::State::state(), and fizz::detail::write().

74  {
75  EXPECT_CALL(*machine_, _processAppClose(_))
76  .WillOnce(InvokeWithoutArgs([]() {
77  TLSContent record;
78  record.contentType = ContentType::handshake;
79  record.data = IOBuf::copyBuffer("closenotify");
80  record.encryptionLevel = EncryptionLevel::Handshake;
81  WriteToSocket write;
82  write.contents.emplace_back(std::move(record));
83  return detail::actions(
84  [](State& newState) { newState.state() = StateEnum::Error; },
85  std::move(write));
86  }));
87  }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
MockClientStateMachineInstance * machine_
Actions actions(Args &&...act)
Definition: Actions.h:86
StateEnum state() const
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
void fizz::client::test::AsyncFizzClientTest::expectTransportReadCallback ( )
inlineprotected

Definition at line 69 of file AsyncFizzClientTest.cpp.

References testing::_, EXPECT_CALL, and socket_.

69  {
70  EXPECT_CALL(*socket_, setReadCB(_))
71  .WillRepeatedly(SaveArg<0>(&socketReadCallback_));
72  }
AsyncTransportWrapper::ReadCallback * socketReadCallback_
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void fizz::client::test::AsyncFizzClientTest::fullHandshakeSuccess ( bool  acceptEarlyData,
std::string  alpn = "h2",
std::shared_ptr< const Cert clientCert = nullptr,
std::shared_ptr< const Cert serverCert = nullptr,
bool  pskResumed = false 
)
inlineprotected

Definition at line 97 of file AsyncFizzClientTest.cpp.

References testing::_, fizz::client::detail::actions(), alpn, clientCert, folly::IOBuf::copyBuffer(), fizz::client::ReportHandshakeSuccess::earlyDataAccepted, folly::Range< Iter >::empty(), EXPECT_CALL, testing::InvokeWithoutArgs(), folly::gen::move, folly::none, fizz::psk_ke, fizz::Resumption, serverCert, fizz::tls_1_3, and fizz::TLS_AES_128_GCM_SHA256.

102  {
103  EXPECT_CALL(*machine_, _processSocketData(_, _))
104  .WillOnce(InvokeWithoutArgs([=]() {
105  auto addToState = [=](State& newState) {
106  newState.exporterMasterSecret() =
107  folly::IOBuf::copyBuffer("12345678901234567890123456789012");
108  newState.cipher() = CipherSuite::TLS_AES_128_GCM_SHA256;
109  newState.version() = ProtocolVersion::tls_1_3;
110  if (alpn.empty()) {
111  newState.alpn() = none;
112  } else {
113  newState.alpn() = alpn;
114  }
115  newState.clientCert() = clientCert;
116  newState.serverCert() = serverCert;
117 
118  if (acceptEarlyData || pskResumed) {
119  newState.pskMode() = PskKeyExchangeMode::psk_ke;
120  newState.pskType() = PskType::Resumption;
121  }
122  };
123  ReportHandshakeSuccess reportSuccess;
124  reportSuccess.earlyDataAccepted = acceptEarlyData;
125  return detail::actions(
126  std::move(addToState), std::move(reportSuccess), WaitForData());
127  }));
129  }
virtual void readBufferAvailable(std::unique_ptr< IOBuf >) noexcept
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece alpn
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
constexpr bool empty() const
Definition: Range.h:443
AsyncTransportWrapper::ReadCallback * socketReadCallback_
std::shared_ptr< const Cert > serverCert
MockClientStateMachineInstance * machine_
Actions actions(Args &&...act)
Definition: Actions.h:86
std::shared_ptr< const Cert > clientCert
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
constexpr None none
Definition: Optional.h:87
static EarlyDataParams fizz::client::test::AsyncFizzClientTest::getEarlyDataParams ( )
inlinestaticprotected
void fizz::client::test::AsyncFizzClientTest::SetUp ( )
inlineoverridevirtual

Reimplemented from testing::Test.

Definition at line 54 of file AsyncFizzClientTest.cpp.

References fizz::client::test::MockClientStateMachineInstance::instance, folly::gen::move, ON_CALL, testing::Return(), and socket_.

54  {
55  context_ = std::make_shared<FizzClientContext>();
56  context_->setSendEarlyData(true);
57  mockPskCache_ = std::make_shared<MockPskCache>();
58  context_->setPskCache(mockPskCache_);
60  auto transport = AsyncTransportWrapper::UniquePtr(socket_);
61  client_.reset(new AsyncFizzClientT<MockClientStateMachineInstance>(
62  std::move(transport), context_));
64  ON_CALL(*socket_, good()).WillByDefault(Return(true));
65  ON_CALL(readCallback_, isBufferMovable_()).WillByDefault(Return(true));
66  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< AsyncTransportWrapper, Destructor > UniquePtr
MockClientStateMachineInstance * machine_
#define ON_CALL(obj, call)
std::shared_ptr< MockPskCache > mockPskCache_
AsyncFizzClientT< MockClientStateMachineInstance >::UniquePtr client_
static MockClientStateMachineInstance * instance
std::shared_ptr< FizzClientContext > context_
internal::ReturnAction< R > Return(R value)

Member Data Documentation

AsyncFizzClientT<MockClientStateMachineInstance>::UniquePtr fizz::client::test::AsyncFizzClientTest::client_
protected

Definition at line 165 of file AsyncFizzClientTest.cpp.

std::shared_ptr<FizzClientContext> fizz::client::test::AsyncFizzClientTest::context_
protected

Definition at line 166 of file AsyncFizzClientTest.cpp.

EventBase fizz::client::test::AsyncFizzClientTest::evb_
protected

Definition at line 174 of file AsyncFizzClientTest.cpp.

MockHandshakeCallbackT<MockClientStateMachineInstance> fizz::client::test::AsyncFizzClientTest::handshakeCallback_
protected

Definition at line 171 of file AsyncFizzClientTest.cpp.

MockClientStateMachineInstance* fizz::client::test::AsyncFizzClientTest::machine_
protected

Definition at line 169 of file AsyncFizzClientTest.cpp.

std::shared_ptr<MockPskCache> fizz::client::test::AsyncFizzClientTest::mockPskCache_
protected

Definition at line 167 of file AsyncFizzClientTest.cpp.

MockReplaySafetyCallback fizz::client::test::AsyncFizzClientTest::mockReplayCallback_
protected

Definition at line 175 of file AsyncFizzClientTest.cpp.

folly::Optional<std::string> fizz::client::test::AsyncFizzClientTest::pskIdentity_ {"pskIdentity"}
protected

Definition at line 176 of file AsyncFizzClientTest.cpp.

MockReadCallback fizz::client::test::AsyncFizzClientTest::readCallback_
protected

Definition at line 172 of file AsyncFizzClientTest.cpp.

MockAsyncTransport* fizz::client::test::AsyncFizzClientTest::socket_
protected

Definition at line 168 of file AsyncFizzClientTest.cpp.

AsyncTransportWrapper::ReadCallback* fizz::client::test::AsyncFizzClientTest::socketReadCallback_
protected

Definition at line 170 of file AsyncFizzClientTest.cpp.

MockWriteCallback fizz::client::test::AsyncFizzClientTest::writeCallback_
protected

Definition at line 173 of file AsyncFizzClientTest.cpp.


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