1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-08 09:42:06 +03:00

Use unsanitized error message in Quic app callback cancelation

Summary:
Right now we use un-sanitized error message on onConnectionError only.
This also uses it in app callbacks

Reviewed By: lnicco

Differential Revision: D20843327

fbshipit-source-id: c81896d41b712a7165ac6f6b381d3687ecca2a3a
This commit is contained in:
Yang Chi
2020-04-05 09:45:17 -07:00
committed by Facebook GitHub Bot
parent 9801bed716
commit de9c1e137d
2 changed files with 40 additions and 4 deletions

View File

@@ -1030,6 +1030,36 @@ TEST_F(QuicTransportImplTest, ConnectionErrorOnWrite) {
QuicErrorCode(LocalErrorCode::CONNECTION_ABANDONED));
}
TEST_F(QuicTransportImplTest, ReadErrorUnsanitizedErrorMsg) {
transport->setServerConnectionId();
transport->transportConn->oneRttWriteCipher = test::createNoOpAead();
auto stream = transport->createBidirectionalStream().value();
MockReadCallback rcb;
transport->setReadCallback(stream, &rcb);
EXPECT_CALL(rcb, readError(stream, _))
.Times(1)
.WillOnce(Invoke(
[](StreamId,
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>
error) {
EXPECT_EQ("You need to calm down.", *error.second);
}));
EXPECT_CALL(*socketPtr, write(_, _)).WillOnce(Invoke([](auto&, auto&) {
throw std::runtime_error("You need to calm down.");
return 0;
}));
QuicSocket::WriteResult result = transport->writeChain(
stream,
folly::IOBuf::copyBuffer("You are being too loud."),
true,
false,
nullptr);
evb->loopOnce();
EXPECT_TRUE(transport->isClosed());
}
TEST_F(QuicTransportImplTest, ConnectionErrorUnhandledException) {
transport->transportConn->oneRttWriteCipher = test::createNoOpAead();
auto stream = transport->createBidirectionalStream().value();