9 #include <gmock/gmock.h> 10 #include <gtest/gtest.h> 20 using namespace folly;
34 socket_ = getUnderlyingTransport<MockAsyncTransport>();
50 setReplaySafetyCallback,
57 return getApplicationProtocol_();
68 std::shared_ptr<folly::IOBuf>,
73 std::unique_ptr<folly::IOBuf>&& buf,
76 callback, std::shared_ptr<folly::IOBuf>(buf.release()),
flags);
86 .InSequence(readBufSeq_)
93 EXPECT_CALL(readCallback_, readDataAvailable_(data.size()))
94 .InSequence(readBufSeq_)
95 .WillOnce(
Invoke([
this, data](
size_t len) {
102 .WillOnce(SaveArg<0>(&transportReadCallback_));
116 return eq(*arg, *expected);
120 EXPECT_EQ(getSecurityProtocol(),
"Fizz");
159 setReadCB(&readCallback_);
177 setReadCB(&readCallback_);
182 setReadCB(&readCallback_);
196 setReadCB(&readCallback_);
199 EXPECT_CALL(readCallback_, readBufferAvailable_(BufMatches(buf.get())));
200 deliverAppData(buf->clone());
203 EXPECT_CALL(readCallback_, readBufferAvailable_(BufMatches(buf2.get())));
204 deliverAppData(buf2->clone());
217 EXPECT_CALL(readCallback_, readBufferAvailable_(BufMatches(expected.get())));
218 setReadCB(&readCallback_);
221 EXPECT_CALL(readCallback_, readBufferAvailable_(BufMatches(buf3.get())));
222 deliverAppData(buf3->clone());
228 setReadCB(&readCallback_);
231 expectReadBufRequest(20);
232 expectReadData(
"sup");
239 setReadCB(&readCallback_);
242 expectReadBufRequest(3);
243 expectReadData(
"sup");
250 setReadCB(&readCallback_);
253 expectReadBufRequest(3);
254 expectReadData(
"hel");
255 expectReadBufRequest(3);
256 expectReadData(
"lo");
268 expectReadBufRequest(20);
269 expectReadData(
"buf1buf2");
270 setReadCB(&readCallback_);
273 expectReadBufRequest(20);
274 expectReadData(
"buf3");
281 setReadCB(&readCallback_);
284 expectReadBufRequest(0);
293 setReadCB(&readCallback_);
296 expectReadBufRequest(3);
298 .InSequence(readBufSeq_)
299 .WillOnce(
Invoke([
this](
size_t len) {
301 this->setReadCB(
nullptr);
305 expectReadBufRequest(20);
306 expectReadData(
"lo");
307 setReadCB(&readCallback_);
311 expectTransportReadCallback();
312 startTransportReads();
313 EXPECT_TRUE(transportReadCallback_->isBufferMovable());
318 expectTransportReadCallback();
319 startTransportReads();
323 transportReadCallback_->readBufferAvailable(buf->clone());
335 expectTransportReadCallback();
336 startTransportReads();
339 transportReadCallback_->getReadBuffer(&buf, &len);
343 std::memcpy(buf,
"hello", 5);
344 transportReadCallback_->readDataAvailable(5);
348 transportReadCallback_->getReadBuffer(&buf, &len);
349 std::memcpy(buf,
"goodbye", 7);
350 transportReadCallback_->readDataAvailable(7);
356 expectTransportReadCallback();
357 startTransportReads();
360 transportReadCallback_->readErr(ase_);
364 expectTransportReadCallback();
365 startTransportReads();
371 transportReadCallback_->readEOF();
375 expectTransportReadCallback();
376 startTransportReads();
379 bigBuf->append(1024 * 1024);
380 expectTransportReadCallback();
382 transportReadCallback_->readBufferAvailable(
std::move(bigBuf));
383 EXPECT_EQ(transportReadCallback_,
nullptr);
385 expectTransportReadCallback();
386 setReadCB(&readCallback_);
387 EXPECT_NE(transportReadCallback_,
nullptr);
392 expectTransportReadCallback();
393 startTransportReads();
396 bigBuf->append(1024 * 1024);
397 expectTransportReadCallback();
399 EXPECT_EQ(transportReadCallback_,
nullptr);
401 expectTransportReadCallback();
403 setReadCB(&readCallback_);
404 EXPECT_NE(transportReadCallback_,
nullptr);
420 ON_CALL(manager, isInTimeoutManagerThread()).WillByDefault(
Return(
true));
421 attachTimeoutManager(&manager);
424 EXPECT_CALL(manager, scheduleTimeout(
_, std::chrono::milliseconds(2)))
425 .WillOnce(
DoAll(SaveArg<0>(&timeout),
Return(
true)));
426 startHandshakeTimeout(std::chrono::milliseconds(2));
437 expectTransportReadCallback();
438 startTransportReads();
448 attachEventBase(&evb);
453 expectTransportReadCallback();
454 startTransportReads();
462 expectTransportReadCallback();
463 setReadCB(&readCallback_);
466 attachEventBase(&evb);
#define EXPECT_LE(val1, val2)
void writeAppData(folly::AsyncTransportWrapper::WriteCallback *callback, std::unique_ptr< folly::IOBuf > &&buf, folly::WriteFlags flags=folly::WriteFlags::NONE) override
MockAsyncTransport * socket_
std::vector< uint8_t > readBuf_
MATCHER_P(WriteNewSessionTicketMatches, expected,"")
std::unique_ptr< X509, X509Deleter > X509UniquePtr
static std::unique_ptr< IOBuf > create(std::size_t capacity)
std::array< char, 8192 > readBuf_
StrictMock< folly::test::MockReadCallback > readCallback_
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
void expectReadData(const std::string &data)
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
#define EXPECT_GE(val1, val2)
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
void expectReadBufRequest(size_t sizeToGive)
ReadCallback * transportReadCallback_
void expectTransportReadCallback()
#define MOCK_METHOD3(m,...)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
AsyncServerSocket::UniquePtr socket_
#define MOCK_CONST_METHOD3(m,...)
virtual void timeoutExpired() noexcept=0
std::shared_ptr< PeerCert > getPeerCert(const CertAndKey &cert)
#define EXPECT_TRUE(condition)
#define ON_CALL(obj, call)
std::unique_ptr< AsyncFizzBase, folly::DelayedDestruction::Destructor > UniquePtr
std::unique_ptr< Aead > getCipher(const CipherParams ¶ms)
TEST_F(RSAPSSTest, TestSignVerify)
#define MOCK_METHOD1(m,...)
std::unique_ptr< folly::IOBuf > Buf
#define EXPECT_NE(val1, val2)
#define MOCK_CONST_METHOD0(m,...)
internal::DoBothAction< Action1, Action2 > DoAll(Action1 a1, Action2 a2)
std::string getApplicationProtocol() const noexceptoverride
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
virtual void writeSuccess() noexcept=0
virtual void writeErr(size_t bytesWritten, const AsyncSocketException &ex) noexcept=0
AsyncSocketExceptionType getType() const noexcept
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
int close(NetworkSocket s)
static constexpr uint64_t data[1]
internal::ReturnAction< R > Return(R value)
#define MOCK_METHOD0(m,...)