Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Unified Diff: net/quic/quic_connection_test.cc

Issue 693943003: Update from https://crrev.com/302630 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_server_stream.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection_test.cc
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
index 4dbbe13a578da3b0612750abc6ca28f6f1200e61..b230fd50eb209ff8a1775a564479346d94f49d82 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -2447,6 +2447,63 @@ TEST_P(QuicConnectionTest, RetransmitPacketsWithInitialEncryption) {
connection_.RetransmitUnackedPackets(ALL_INITIAL_RETRANSMISSION);
}
+TEST_P(QuicConnectionTest, DelayForwardSecureEncryptionUntilClientIsReady) {
+ ValueRestore<bool> old_flag(&FLAGS_enable_quic_delay_forward_security, true);
+
+ // A TaggingEncrypter puts kTagSize copies of the given byte (0x02 here) at
+ // the end of the packet. We can test this to check which encrypter was used.
+ use_tagging_decrypter();
+ connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02));
+ connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL);
+ SendAckPacketToPeer();
+ EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
+
+ // Set a forward-secure encrypter but do not make it the default, and verify
+ // that it is not yet used.
+ connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE,
+ new TaggingEncrypter(0x03));
+ SendAckPacketToPeer();
+ EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
+
+ // Now simulate receipt of a forward-secure packet and verify that the
+ // forward-secure encrypter is now used.
+ connection_.OnDecryptedPacket(ENCRYPTION_FORWARD_SECURE);
+ SendAckPacketToPeer();
+ EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet());
+}
+
+TEST_P(QuicConnectionTest, DelayForwardSecureEncryptionUntilManyPacketSent) {
+ ValueRestore<bool> old_flag(&FLAGS_enable_quic_delay_forward_security, true);
+
+ // Set a congestion window of 10 packets.
+ QuicPacketCount congestion_window = 10;
+ EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
+ Return(congestion_window * kDefaultMaxPacketSize));
+
+ // A TaggingEncrypter puts kTagSize copies of the given byte (0x02 here) at
+ // the end of the packet. We can test this to check which encrypter was used.
+ use_tagging_decrypter();
+ connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02));
+ connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL);
+ SendAckPacketToPeer();
+ EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
+
+ // Set a forward-secure encrypter but do not make it the default, and
+ // verify that it is not yet used.
+ connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE,
+ new TaggingEncrypter(0x03));
+ SendAckPacketToPeer();
+ EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
+
+ // Now send a packet "Far enough" after the encrypter was set and verify that
+ // the forward-secure encrypter is now used.
+ for (uint64 i = 0; i < 3 * congestion_window - 1; ++i) {
+ EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
+ SendAckPacketToPeer();
+ }
+ EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet());
+}
+
TEST_P(QuicConnectionTest, BufferNonDecryptablePackets) {
// SetFromConfig is always called after construction from InitializeSession.
EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
@@ -4012,7 +4069,9 @@ TEST_P(QuicConnectionTest, NetworkChangeVisitorCallbacksChangeFecState) {
EXPECT_TRUE(visitor);
// Increase FEC group size by increasing congestion window to a large number.
- visitor->OnCongestionWindowChange(1000 * kDefaultTCPMSS);
+ EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
+ Return(1000 * kDefaultTCPMSS));
+ visitor->OnCongestionWindowChange();
EXPECT_LT(max_packets_per_fec_group, creator->max_packets_per_fec_group());
}
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_server_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698