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

Side by Side Diff: net/quic/core/quic_crypto_client_stream_test.cc

Issue 2538923003: Write a regression test demonstrating that a QuicCryptoClientStream can receive and use a server co… (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
« no previous file with comments | « net/quic/core/quic_crypto_client_stream.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/core/quic_crypto_client_stream.h" 5 #include "net/quic/core/quic_crypto_client_stream.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" 9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h"
10 #include "net/quic/core/crypto/quic_decrypter.h" 10 #include "net/quic/core/crypto/quic_decrypter.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 const string& cached_scfg = state->server_config(); 227 const string& cached_scfg = state->server_config();
228 test::CompareCharArraysWithHexError( 228 test::CompareCharArraysWithHexError(
229 "scfg", cached_scfg.data(), cached_scfg.length(), 229 "scfg", cached_scfg.data(), cached_scfg.length(),
230 reinterpret_cast<char*>(scfg), arraysize(scfg)); 230 reinterpret_cast<char*>(scfg), arraysize(scfg));
231 231
232 QuicStreamSequencer* sequencer = QuicStreamPeer::sequencer(stream()); 232 QuicStreamSequencer* sequencer = QuicStreamPeer::sequencer(stream());
233 EXPECT_NE(FLAGS_quic_release_crypto_stream_buffer, 233 EXPECT_NE(FLAGS_quic_release_crypto_stream_buffer,
234 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); 234 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer));
235 } 235 }
236 236
237 TEST_F(QuicCryptoClientStreamTest, ServerConfigUpdateWithCert) {
238 // Test that the crypto client stream can receive and use server config
239 // updates with certificates after the connection has been established.
240 CompleteCryptoHandshake();
241
242 // Build a server config update message with certificates
243 QuicCryptoServerConfig crypto_config(
244 QuicCryptoServerConfig::TESTING, QuicRandom::GetInstance(),
245 CryptoTestUtils::ProofSourceForTesting());
246 CryptoTestUtils::FakeServerOptions options;
247 CryptoTestUtils::SetupCryptoServerConfigForTest(
248 connection_->clock(), QuicRandom::GetInstance(), &crypto_config, options);
249 SourceAddressTokens tokens;
250 QuicCompressedCertsCache cache(1);
251 CachedNetworkParameters network_params;
252 CryptoHandshakeMessage server_config_update;
253 EXPECT_TRUE(crypto_config.BuildServerConfigUpdateMessage(
254 session_->connection()->version(), stream()->chlo_hash(), tokens,
255 QuicIpAddress::Loopback6(), QuicIpAddress::Loopback6(),
256 connection_->clock(), QuicRandom::GetInstance(), &cache,
257 stream()->crypto_negotiated_params(), &network_params, QuicTagVector(),
258 &server_config_update));
259
260 std::unique_ptr<QuicData> data(
261 CryptoFramer::ConstructHandshakeMessage(server_config_update));
262 stream()->OnStreamFrame(QuicStreamFrame(kCryptoStreamId, /*fin=*/false,
263 /*offset=*/0, data->AsStringPiece()));
264
265 // Recreate connection with the new config and verify a 0-RTT attempt.
266 CreateConnection();
267
268 stream()->CryptoConnect();
269 EXPECT_TRUE(session_->IsEncryptionEstablished());
270 }
271
237 TEST_F(QuicCryptoClientStreamTest, ServerConfigUpdateBeforeHandshake) { 272 TEST_F(QuicCryptoClientStreamTest, ServerConfigUpdateBeforeHandshake) {
238 EXPECT_CALL( 273 EXPECT_CALL(
239 *connection_, 274 *connection_,
240 CloseConnection(QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE, _, _)); 275 CloseConnection(QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE, _, _));
241 CryptoHandshakeMessage server_config_update; 276 CryptoHandshakeMessage server_config_update;
242 server_config_update.set_tag(kSCUP); 277 server_config_update.set_tag(kSCUP);
243 std::unique_ptr<QuicData> data( 278 std::unique_ptr<QuicData> data(
244 CryptoFramer::ConstructHandshakeMessage(server_config_update)); 279 CryptoFramer::ConstructHandshakeMessage(server_config_update));
245 stream()->OnStreamFrame(QuicStreamFrame(kCryptoStreamId, /*fin=*/false, 280 stream()->OnStreamFrame(QuicStreamFrame(kCryptoStreamId, /*fin=*/false,
246 /*offset=*/0, data->AsStringPiece())); 281 /*offset=*/0, data->AsStringPiece()));
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 client_state->GetNextServerDesignatedConnectionId(); 424 client_state->GetNextServerDesignatedConnectionId();
390 QuicConnectionId expected_id = 425 QuicConnectionId expected_id =
391 server_session_->connection()->random_generator()->RandUint64(); 426 server_session_->connection()->random_generator()->RandUint64();
392 EXPECT_EQ(expected_id, server_designated_id); 427 EXPECT_EQ(expected_id, server_designated_id);
393 EXPECT_FALSE(client_state->has_server_designated_connection_id()); 428 EXPECT_FALSE(client_state->has_server_designated_connection_id());
394 } 429 }
395 430
396 } // namespace 431 } // namespace
397 } // namespace test 432 } // namespace test
398 } // namespace net 433 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_crypto_client_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698