| OLD | NEW |
| 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" |
| 11 #include "net/quic/core/crypto/quic_encrypter.h" | 11 #include "net/quic/core/crypto/quic_encrypter.h" |
| 12 #include "net/quic/core/quic_flags.h" | 12 #include "net/quic/core/quic_flags.h" |
| 13 #include "net/quic/core/quic_protocol.h" | 13 #include "net/quic/core/quic_protocol.h" |
| 14 #include "net/quic/core/quic_server_id.h" | 14 #include "net/quic/core/quic_server_id.h" |
| 15 #include "net/quic/core/quic_utils.h" | 15 #include "net/quic/core/quic_utils.h" |
| 16 #include "net/quic/test_tools/crypto_test_utils.h" | 16 #include "net/quic/test_tools/crypto_test_utils.h" |
| 17 #include "net/quic/test_tools/quic_stream_sequencer_peer.h" |
| 17 #include "net/quic/test_tools/quic_test_utils.h" | 18 #include "net/quic/test_tools/quic_test_utils.h" |
| 19 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
| 18 #include "net/quic/test_tools/simple_quic_framer.h" | 20 #include "net/quic/test_tools/simple_quic_framer.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 23 |
| 22 using std::string; | 24 using std::string; |
| 23 using std::vector; | 25 using std::vector; |
| 24 | 26 |
| 25 using testing::_; | 27 using testing::_; |
| 26 | 28 |
| 27 namespace net { | 29 namespace net { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 stream()->OnStreamFrame(QuicStreamFrame(kCryptoStreamId, /*fin=*/false, | 224 stream()->OnStreamFrame(QuicStreamFrame(kCryptoStreamId, /*fin=*/false, |
| 223 /*offset=*/0, data->AsStringPiece())); | 225 /*offset=*/0, data->AsStringPiece())); |
| 224 | 226 |
| 225 // Make sure that the STK and SCFG are cached correctly. | 227 // Make sure that the STK and SCFG are cached correctly. |
| 226 EXPECT_EQ("xstk", state->source_address_token()); | 228 EXPECT_EQ("xstk", state->source_address_token()); |
| 227 | 229 |
| 228 const string& cached_scfg = state->server_config(); | 230 const string& cached_scfg = state->server_config(); |
| 229 test::CompareCharArraysWithHexError( | 231 test::CompareCharArraysWithHexError( |
| 230 "scfg", cached_scfg.data(), cached_scfg.length(), | 232 "scfg", cached_scfg.data(), cached_scfg.length(), |
| 231 QuicUtils::AsChars(scfg), arraysize(scfg)); | 233 QuicUtils::AsChars(scfg), arraysize(scfg)); |
| 234 QuicStreamSequencer* sequencer = ReliableQuicStreamPeer::sequencer(stream()); |
| 235 EXPECT_NE(FLAGS_quic_release_crypto_stream_buffer && |
| 236 FLAGS_quic_reduce_sequencer_buffer_memory_life_time, |
| 237 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); |
| 232 } | 238 } |
| 233 | 239 |
| 234 TEST_F(QuicCryptoClientStreamTest, ServerConfigUpdateBeforeHandshake) { | 240 TEST_F(QuicCryptoClientStreamTest, ServerConfigUpdateBeforeHandshake) { |
| 235 EXPECT_CALL( | 241 EXPECT_CALL( |
| 236 *connection_, | 242 *connection_, |
| 237 CloseConnection(QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE, _, _)); | 243 CloseConnection(QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE, _, _)); |
| 238 CryptoHandshakeMessage server_config_update; | 244 CryptoHandshakeMessage server_config_update; |
| 239 server_config_update.set_tag(kSCUP); | 245 server_config_update.set_tag(kSCUP); |
| 240 std::unique_ptr<QuicData> data( | 246 std::unique_ptr<QuicData> data( |
| 241 CryptoFramer::ConstructHandshakeMessage(server_config_update)); | 247 CryptoFramer::ConstructHandshakeMessage(server_config_update)); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 client_state->GetNextServerDesignatedConnectionId(); | 380 client_state->GetNextServerDesignatedConnectionId(); |
| 375 QuicConnectionId expected_id = | 381 QuicConnectionId expected_id = |
| 376 server_session_->connection()->random_generator()->RandUint64(); | 382 server_session_->connection()->random_generator()->RandUint64(); |
| 377 EXPECT_EQ(expected_id, server_designated_id); | 383 EXPECT_EQ(expected_id, server_designated_id); |
| 378 EXPECT_FALSE(client_state->has_server_designated_connection_id()); | 384 EXPECT_FALSE(client_state->has_server_designated_connection_id()); |
| 379 } | 385 } |
| 380 | 386 |
| 381 } // namespace | 387 } // namespace |
| 382 } // namespace test | 388 } // namespace test |
| 383 } // namespace net | 389 } // namespace net |
| OLD | NEW |