proxygen
fizz::server::test::AsyncFizzServerTest Class Reference
Inheritance diagram for fizz::server::test::AsyncFizzServerTest:
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 accept ()
 
void fullHandshakeSuccess (std::shared_ptr< const Cert > clientCert=nullptr, std::shared_ptr< const Cert > serverCert=nullptr)
 
void completeHandshake ()
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 

Protected Attributes

AsyncFizzServerT< MockServerStateMachineInstance >::UniquePtr server_
 
std::shared_ptr< FizzServerContextcontext_
 
MockAsyncTransportsocket_
 
MockServerStateMachineInstancemachine_
 
AsyncTransportWrapper::ReadCallbacksocketReadCallback_
 
MockHandshakeCallbackT< MockServerStateMachineInstancehandshakeCallback_
 
MockReadCallback readCallback_
 
MockWriteCallback writeCallback_
 
EventBase evb_
 
CipherSuite negotiatedCipher_ = CipherSuite::TLS_AES_128_GCM_SHA256
 
ProtocolVersion protocolVersion_ = ProtocolVersion::tls_1_3
 

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 41 of file AsyncFizzServerTest.cpp.

Member Function Documentation

void fizz::server::test::AsyncFizzServerTest::accept ( )
inlineprotected

Definition at line 77 of file AsyncFizzServerTest.cpp.

References testing::_, fizz::server::test::actions(), evb_, EXPECT_CALL, folly::getEventBase(), testing::InvokeWithoutArgs(), testing::Return(), and socket_.

77  {
79  EXPECT_CALL(*socket_, getEventBase()).WillOnce(Return(&evb_));
80  EXPECT_CALL(*machine_, _processAccept(_, &evb_, _, _))
81  .WillOnce(InvokeWithoutArgs([]() { return actions(); }));
82  server_->accept(&handshakeCallback_);
83  }
MockServerStateMachineInstance * machine_
EventBase * getEventBase()
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
AsyncActions actions(Args &&...act)
MockHandshakeCallbackT< MockServerStateMachineInstance > handshakeCallback_
AsyncFizzServerT< MockServerStateMachineInstance >::UniquePtr server_
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
internal::ReturnAction< R > Return(R value)
void fizz::server::test::AsyncFizzServerTest::completeHandshake ( )
inlineprotected

Definition at line 110 of file AsyncFizzServerTest.cpp.

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

110  {
111  accept();
112  EXPECT_CALL(handshakeCallback_, _fizzHandshakeSuccess());
114  }
void fullHandshakeSuccess(std::shared_ptr< const Cert > clientCert=nullptr, std::shared_ptr< const Cert > serverCert=nullptr)
MockHandshakeCallbackT< MockServerStateMachineInstance > handshakeCallback_
#define EXPECT_CALL(obj, call)
void fizz::server::test::AsyncFizzServerTest::expectAppClose ( )
inlineprotected

Definition at line 62 of file AsyncFizzServerTest.cpp.

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

62  {
63  EXPECT_CALL(*machine_, _processAppClose(_))
64  .WillOnce(InvokeWithoutArgs([]() {
65  WriteToSocket write;
66  TLSContent record;
67  record.contentType = ContentType::alert;
68  record.encryptionLevel = EncryptionLevel::Handshake;
69  record.data = IOBuf::copyBuffer("closenotify");
70  write.contents.emplace_back(std::move(record));
71  return detail::actions(
72  [](State& newState) { newState.state() = StateEnum::Error; },
73  std::move(write));
74  }));
75  }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
Actions actions(Args &&...act)
Definition: Actions.h:57
MockServerStateMachineInstance * machine_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
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::server::test::AsyncFizzServerTest::expectTransportReadCallback ( )
inlineprotected

Definition at line 57 of file AsyncFizzServerTest.cpp.

References testing::_, EXPECT_CALL, and socket_.

57  {
58  EXPECT_CALL(*socket_, setReadCB(_))
59  .WillRepeatedly(SaveArg<0>(&socketReadCallback_));
60  }
AsyncTransportWrapper::ReadCallback * socketReadCallback_
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void fizz::server::test::AsyncFizzServerTest::fullHandshakeSuccess ( std::shared_ptr< const Cert clientCert = nullptr,
std::shared_ptr< const Cert serverCert = nullptr 
)
inlineprotected

Definition at line 85 of file AsyncFizzServerTest.cpp.

References testing::_, fizz::server::test::actions(), cipher, clientCert, folly::IOBuf::copyBuffer(), EXPECT_CALL, testing::InvokeWithoutArgs(), folly::gen::move, and serverCert.

87  {
88  EXPECT_CALL(*machine_, _processSocketData(_, _))
89  .WillOnce(InvokeWithoutArgs([clientCert,
90  serverCert,
92  protocolVersion = protocolVersion_]() {
93  auto addExporterToState = [=](State& newState) {
94  auto exporterMaster =
95  folly::IOBuf::copyBuffer("12345678901234567890123456789012");
96  newState.exporterMasterSecret() = std::move(exporterMaster);
97  newState.cipher() = cipher;
98  newState.version() = protocolVersion;
99  newState.clientCert() = clientCert;
100  newState.serverCert() = serverCert;
101  };
102  return actions(
103  std::move(addExporterToState),
104  ReportHandshakeSuccess(),
105  WaitForData());
106  }));
108  }
virtual void readBufferAvailable(std::unique_ptr< IOBuf >) noexcept
MockServerStateMachineInstance * machine_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
CipherSuite cipher
AsyncActions actions(Args &&...act)
std::shared_ptr< const Cert > serverCert
AsyncTransportWrapper::ReadCallback * socketReadCallback_
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
void fizz::server::test::AsyncFizzServerTest::SetUp ( )
inlineoverridevirtual

Reimplemented from testing::Test.

Definition at line 43 of file AsyncFizzServerTest.cpp.

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

43  {
44  context_ = std::make_shared<FizzServerContext>();
46  auto transport = AsyncTransportWrapper::UniquePtr(socket_);
47  server_.reset(new AsyncFizzServerT<MockServerStateMachineInstance>(
48  std::move(transport),
49  context_,
50  std::make_shared<MockServerExtensions>()));
52  ON_CALL(*socket_, good()).WillByDefault(Return(true));
53  ON_CALL(readCallback_, isBufferMovable_()).WillByDefault(Return(true));
54  }
MockServerStateMachineInstance * machine_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static MockServerStateMachineInstance * instance
std::unique_ptr< AsyncTransportWrapper, Destructor > UniquePtr
std::shared_ptr< FizzServerContext > context_
#define ON_CALL(obj, call)
AsyncFizzServerT< MockServerStateMachineInstance >::UniquePtr server_
internal::ReturnAction< R > Return(R value)

Member Data Documentation

std::shared_ptr<FizzServerContext> fizz::server::test::AsyncFizzServerTest::context_
protected

Definition at line 117 of file AsyncFizzServerTest.cpp.

EventBase fizz::server::test::AsyncFizzServerTest::evb_
protected

Definition at line 124 of file AsyncFizzServerTest.cpp.

MockHandshakeCallbackT<MockServerStateMachineInstance> fizz::server::test::AsyncFizzServerTest::handshakeCallback_
protected

Definition at line 121 of file AsyncFizzServerTest.cpp.

MockServerStateMachineInstance* fizz::server::test::AsyncFizzServerTest::machine_
protected

Definition at line 119 of file AsyncFizzServerTest.cpp.

CipherSuite fizz::server::test::AsyncFizzServerTest::negotiatedCipher_ = CipherSuite::TLS_AES_128_GCM_SHA256
protected

Definition at line 125 of file AsyncFizzServerTest.cpp.

ProtocolVersion fizz::server::test::AsyncFizzServerTest::protocolVersion_ = ProtocolVersion::tls_1_3
protected

Definition at line 126 of file AsyncFizzServerTest.cpp.

MockReadCallback fizz::server::test::AsyncFizzServerTest::readCallback_
protected

Definition at line 122 of file AsyncFizzServerTest.cpp.

AsyncFizzServerT<MockServerStateMachineInstance>::UniquePtr fizz::server::test::AsyncFizzServerTest::server_
protected

Definition at line 116 of file AsyncFizzServerTest.cpp.

MockAsyncTransport* fizz::server::test::AsyncFizzServerTest::socket_
protected

Definition at line 118 of file AsyncFizzServerTest.cpp.

AsyncTransportWrapper::ReadCallback* fizz::server::test::AsyncFizzServerTest::socketReadCallback_
protected

Definition at line 120 of file AsyncFizzServerTest.cpp.

MockWriteCallback fizz::server::test::AsyncFizzServerTest::writeCallback_
protected

Definition at line 123 of file AsyncFizzServerTest.cpp.


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