proxygen
PeekingAcceptorHandshakeHelperTest.cpp File Reference

Go to the source code of this file.

Classes

class  MockPeekingCallback
 
class  PeekingAcceptorHandshakeHelperTest
 

Functions

 TEST_F (PeekingAcceptorHandshakeHelperTest, TestPeekSuccess)
 
 TEST_F (PeekingAcceptorHandshakeHelperTest, TestPeekNonSuccess)
 
 TEST_F (PeekingAcceptorHandshakeHelperTest, TestPeek2ndSuccess)
 
 TEST_F (PeekingAcceptorHandshakeHelperTest, TestEOFDuringPeek)
 
 TEST_F (PeekingAcceptorHandshakeHelperTest, TestPeekErr)
 
 TEST_F (PeekingAcceptorHandshakeHelperTest, TestDropDuringPeek)
 
 TEST_F (PeekingAcceptorHandshakeHelperTest, TestDropAfterPeek)
 

Function Documentation

TEST_F ( PeekingAcceptorHandshakeHelperTest  ,
TestPeekSuccess   
)

Definition at line 95 of file PeekingAcceptorHandshakeHelperTest.cpp.

References testing::_, callback_, EXPECT_CALL, folly::gen::move, and testing::Return().

95  {
96  helper_->start(std::move(sockPtr_), &callback_);
97  // first 2 bytes of SSL3+.
98  std::vector<uint8_t> buf(2);
99  buf[0] = 0x16;
100  buf[1] = 0x03;
101  EXPECT_CALL(mockPeekCallback1_, getHelperInternal(_, _, _, _))
102  .WillOnce(Return(helperPtr_.release()));
103  EXPECT_CALL(*innerHelper_, startInternal(_, _));
104  helper_->peekSuccess(buf);
105 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
folly::Function< void()> callback_
internal::ReturnAction< R > Return(R value)
TEST_F ( PeekingAcceptorHandshakeHelperTest  ,
TestPeekNonSuccess   
)

Definition at line 107 of file PeekingAcceptorHandshakeHelperTest.cpp.

References testing::_, callback_, EXPECT_CALL, folly::gen::move, and testing::Return().

107  {
108  helper_->start(std::move(sockPtr_), &callback_);
109  // first 2 bytes of SSL3+.
110  std::vector<uint8_t> buf(2);
111  buf[0] = 0x16;
112  buf[1] = 0x03;
113  EXPECT_CALL(mockPeekCallback1_, getHelperInternal(_, _, _, _))
114  .WillOnce(Return(nullptr));
115  EXPECT_CALL(mockPeekCallback2_, getHelperInternal(_, _, _, _))
116  .WillOnce(Return(nullptr));
117  EXPECT_CALL(callback_, connectionError_(_, _, _));
118  helper_->peekSuccess(buf);
119 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
folly::Function< void()> callback_
internal::ReturnAction< R > Return(R value)
TEST_F ( PeekingAcceptorHandshakeHelperTest  ,
TestPeek2ndSuccess   
)

Definition at line 121 of file PeekingAcceptorHandshakeHelperTest.cpp.

References testing::_, callback_, EXPECT_CALL, folly::gen::move, and testing::Return().

121  {
122  helper_->start(std::move(sockPtr_), &callback_);
123  // first 2 bytes of SSL3+.
124  std::vector<uint8_t> buf(2);
125  buf[0] = 0x16;
126  buf[1] = 0x03;
127  EXPECT_CALL(mockPeekCallback1_, getHelperInternal(_, _, _, _))
128  .WillOnce(Return(nullptr));
129  EXPECT_CALL(mockPeekCallback2_, getHelperInternal(_, _, _, _))
130  .WillOnce(Return(helperPtr_.release()));
131  EXPECT_CALL(*innerHelper_, startInternal(_, _));
132  helper_->peekSuccess(buf);
133 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
folly::Function< void()> callback_
internal::ReturnAction< R > Return(R value)
TEST_F ( PeekingAcceptorHandshakeHelperTest  ,
TestEOFDuringPeek   
)

Definition at line 136 of file PeekingAcceptorHandshakeHelperTest.cpp.

References testing::_, ASSERT_TRUE, callback_, EXPECT_CALL, folly::gen::move, and folly::AsyncReader::ReadCallback::readEOF().

136  {
138  EXPECT_CALL(*sslSock_, setReadCB(_))
139  .WillOnce(SaveArg<0>(&rcb));
140  EXPECT_CALL(*sslSock_, setReadCB(nullptr));
141  EXPECT_CALL(callback_, connectionError_(_, _, _));
142  helper_->start(std::move(sockPtr_), &callback_);
143  ASSERT_TRUE(rcb);
144  rcb->readEOF();
145 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
folly::Function< void()> callback_
virtual void readEOF() noexcept=0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
TEST_F ( PeekingAcceptorHandshakeHelperTest  ,
TestPeekErr   
)

Definition at line 147 of file PeekingAcceptorHandshakeHelperTest.cpp.

References testing::_, callback_, EXPECT_CALL, and folly::gen::move.

147  {
148  helper_->start(std::move(sockPtr_), &callback_);
149  EXPECT_CALL(callback_, connectionError_(_, _, _));
150  helper_->peekError(AsyncSocketException(
151  AsyncSocketException::AsyncSocketExceptionType::END_OF_FILE,
152  "Unit test"));
153 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
folly::Function< void()> callback_
TEST_F ( PeekingAcceptorHandshakeHelperTest  ,
TestDropDuringPeek   
)

Definition at line 155 of file PeekingAcceptorHandshakeHelperTest.cpp.

References testing::_, testing::AtLeast(), callback_, EXPECT_CALL, testing::Invoke(), folly::gen::move, and cpp.tokenize::UNKNOWN.

155  {
156  helper_->start(std::move(sockPtr_), &callback_);
157 
158  EXPECT_CALL(*sslSock_, closeNow()).Times(AtLeast(1)).WillOnce(Invoke([&] {
159  helper_->peekError(AsyncSocketException(
161  }));
162  EXPECT_CALL(callback_, connectionError_(_, _, _));
163  helper_->dropConnection();
164 }
GTEST_API_ Cardinality AtLeast(int n)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
string UNKNOWN
Definition: tokenize.py:53
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
folly::Function< void()> callback_
TEST_F ( PeekingAcceptorHandshakeHelperTest  ,
TestDropAfterPeek   
)

Definition at line 166 of file PeekingAcceptorHandshakeHelperTest.cpp.

References testing::_, callback_, EXPECT_CALL, folly::gen::move, and testing::Return().

166  {
167  helper_->start(std::move(sockPtr_), &callback_);
168  std::vector<uint8_t> buf(2);
169  // first 2 bytes of SSL3+.
170  buf[0] = 0x16;
171  buf[1] = 0x03;
172 
173  EXPECT_CALL(mockPeekCallback1_, getHelperInternal(_, _, _, _))
174  .WillOnce(Return(helperPtr_.release()));
175  EXPECT_CALL(*innerHelper_, startInternal(_, _));
176  helper_->peekSuccess(buf);
177 
178  EXPECT_CALL(*innerHelper_, dropConnection(_));
179  helper_->dropConnection();
180 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
folly::Function< void()> callback_
internal::ReturnAction< R > Return(R value)