1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-25 15:43:13 +03:00

Functionality to encode/decode retry tokens

Summary: This diff defines functionality to encode and decode un-encrypted retry tokens.

Reviewed By: mjoras

Differential Revision: D21073343

fbshipit-source-id: 79c2e8ba3c743441edd4b162da69cc5e69873dd2
This commit is contained in:
Aman Sharma
2020-04-21 22:34:15 -07:00
committed by Facebook GitHub Bot
parent 04c6d70a3b
commit 84c1ed50f0
5 changed files with 72 additions and 0 deletions

View File

@@ -737,5 +737,31 @@ TEST_F(DecodeTest, DecodeExpiredStreamDataFrame) {
EXPECT_EQ(result.minimumStreamOffset, 100);
}
TEST_F(DecodeTest, ParsePlaintextRetryToken) {
ConnectionId odcid = getTestConnectionId();
folly::IPAddress clientIp("109.115.3.49");
uint16_t clientPort = 42069;
RetryToken retryToken(odcid, clientIp, clientPort);
Buf plaintextRetryToken = retryToken.getPlaintextToken();
folly::io::Cursor cursor(plaintextRetryToken.get());
auto parseResult = parsePlaintextRetryToken(cursor);
EXPECT_TRUE(parseResult.hasValue());
EXPECT_EQ(parseResult->originalDstConnId, odcid);
EXPECT_EQ(parseResult->clientIp, clientIp);
EXPECT_EQ(parseResult->clientPort, clientPort);
}
TEST_F(DecodeTest, ParsePlaintextRetryTokenMalformed) {
Buf plaintextRetryToken = folly::IOBuf::copyBuffer("This is some garbage");
folly::io::Cursor cursor(plaintextRetryToken.get());
auto parseResult = parsePlaintextRetryToken(cursor);
EXPECT_TRUE(parseResult.hasError());
EXPECT_EQ(parseResult.error(), TransportErrorCode::INVALID_TOKEN);
}
} // namespace test
} // namespace quic