1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-10 21:22:20 +03:00

QuicServerTest DecryptToken

Summary: - onTokenDecryptFailure expectations, should have been added previously.

Reviewed By: lnicco

Differential Revision: D33172268

fbshipit-source-id: c817318cfd3bfbbe522c1d9224fb2201fb3cbc84
This commit is contained in:
Hani Damlaj
2022-01-07 10:18:19 -08:00
committed by Facebook GitHub Bot
parent ae5bbeac6e
commit 58060ef568

View File

@@ -180,6 +180,7 @@ class QuicServerWorkerTest : public Test {
EXPECT_CALL(*transport_, hasShutdown()) EXPECT_CALL(*transport_, hasShutdown())
.WillRepeatedly(ReturnPointee(&hasShutdown_)); .WillRepeatedly(ReturnPointee(&hasShutdown_));
worker_->setTransportFactory(factory_.get()); worker_->setTransportFactory(factory_.get());
EXPECT_CALL(*quicStats_, onTokenDecryptFailure()).Times(0);
} }
void createQuicConnection( void createQuicConnection(
@@ -735,6 +736,8 @@ TEST_F(QuicServerWorkerTest, UnfinishedHandshakeLimit) {
// Validate that when the worker receives a valid NewToken, it invokes // Validate that when the worker receives a valid NewToken, it invokes
// transportInfo->onNewTokenReceived(). // transportInfo->onNewTokenReceived().
TEST_F(QuicServerWorkerTest, TestNewTokenStatsCallback) { TEST_F(QuicServerWorkerTest, TestNewTokenStatsCallback) {
EXPECT_CALL(*quicStats_, onNewTokenReceived());
NewToken newToken(kClientAddr.getIPAddress()); NewToken newToken(kClientAddr.getIPAddress());
// Create the encrypted retry token // Create the encrypted retry token
TokenGenerator generator(tokenSecret_); TokenGenerator generator(tokenSecret_);
@@ -747,7 +750,6 @@ TEST_F(QuicServerWorkerTest, TestNewTokenStatsCallback) {
auto dstConnId = getTestConnectionId(hostId_); auto dstConnId = getTestConnectionId(hostId_);
auto srcConnId = getTestConnectionId(0); auto srcConnId = getTestConnectionId(0);
EXPECT_CALL(*quicStats_, onNewTokenReceived());
// we piggyback the retrytoken logic with a new token // we piggyback the retrytoken logic with a new token
testSendInitialWithRetryToken( testSendInitialWithRetryToken(
encryptedTokenStr, srcConnId, dstConnId, kClientAddr); encryptedTokenStr, srcConnId, dstConnId, kClientAddr);
@@ -756,6 +758,7 @@ TEST_F(QuicServerWorkerTest, TestNewTokenStatsCallback) {
TEST_F(QuicServerWorkerTest, TestRetryValidInitial) { TEST_F(QuicServerWorkerTest, TestRetryValidInitial) {
// The second client initial packet with the retry token is valid // The second client initial packet with the retry token is valid
// as the client IP is the same as the one stored in the retry token // as the client IP is the same as the one stored in the retry token
auto dstConnId = getTestConnectionId(hostId_); auto dstConnId = getTestConnectionId(hostId_);
auto srcConnId = getTestConnectionId(0); auto srcConnId = getTestConnectionId(0);
auto retryToken = testSendRetry(srcConnId, dstConnId, kClientAddr); auto retryToken = testSendRetry(srcConnId, dstConnId, kClientAddr);
@@ -783,14 +786,14 @@ TEST_F(QuicServerWorkerTest, TestRetryInvalidInitialClientIp) {
std::string encryptedRetryToken; std::string encryptedRetryToken;
expectServerRetryPacketWrite(encryptedRetryToken, dstConnId, kClientAddr2); expectServerRetryPacketWrite(encryptedRetryToken, dstConnId, kClientAddr2);
EXPECT_CALL(*quicStats_, onTokenDecryptFailure()); EXPECT_CALL(*quicStats_, onTokenDecryptFailure()).Times(1);
testSendInitialWithRetryToken(retryToken, srcConnId, dstConnId, kClientAddr2); testSendInitialWithRetryToken(retryToken, srcConnId, dstConnId, kClientAddr2);
} }
TEST_F(QuicServerWorkerTest, TestRetryUnfinishedInvalidInitialClientIp) { TEST_F(QuicServerWorkerTest, TestRetryUnfinishedInvalidInitialClientIp) {
// The second client initial packet with the retry token is invalid // The second client initial packet with the retry token is invalid
// as the client IP is different from the one stored in the retry token // as the client IP is different from the one stored in the retry token
EXPECT_CALL(*quicStats_, onTokenDecryptFailure()); EXPECT_CALL(*quicStats_, onTokenDecryptFailure()).Times(1);
auto dstConnId = getTestConnectionId(hostId_); auto dstConnId = getTestConnectionId(hostId_);
auto srcConnId = getTestConnectionId(0); auto srcConnId = getTestConnectionId(0);
@@ -804,6 +807,7 @@ TEST_F(QuicServerWorkerTest, TestRetryUnfinishedInvalidInitialClientIp) {
TEST_F(QuicServerWorkerTest, TestRetryInvalidInitialDstConnId) { TEST_F(QuicServerWorkerTest, TestRetryInvalidInitialDstConnId) {
// Dest conn ID is invalid as it is different from the original dst conn ID // Dest conn ID is invalid as it is different from the original dst conn ID
EXPECT_CALL(*quicStats_, onTokenDecryptFailure()).Times(1);
auto dstConnId = getTestConnectionId(hostId_); auto dstConnId = getTestConnectionId(hostId_);
auto srcConnId = getTestConnectionId(0); auto srcConnId = getTestConnectionId(0);
auto retryToken = testSendRetry(srcConnId, dstConnId, kClientAddr); auto retryToken = testSendRetry(srcConnId, dstConnId, kClientAddr);