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

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

Issue 2848203002: Add a platform implementation of QuicTest and QuicTestWithParam (Closed)
Patch Set: net/quic/platform/impl/quic_test_impl.cc Created 3 years, 7 months 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_connection_test.cc ('k') | net/quic/core/quic_crypto_server_stream_test.cc » ('j') | 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"
11 #include "net/quic/core/crypto/quic_encrypter.h" 11 #include "net/quic/core/crypto/quic_encrypter.h"
12 #include "net/quic/core/quic_packets.h" 12 #include "net/quic/core/quic_packets.h"
13 #include "net/quic/core/quic_server_id.h" 13 #include "net/quic/core/quic_server_id.h"
14 #include "net/quic/core/quic_utils.h" 14 #include "net/quic/core/quic_utils.h"
15 #include "net/quic/platform/api/quic_flags.h" 15 #include "net/quic/platform/api/quic_flags.h"
16 #include "net/quic/platform/api/quic_test.h"
16 #include "net/quic/test_tools/crypto_test_utils.h" 17 #include "net/quic/test_tools/crypto_test_utils.h"
17 #include "net/quic/test_tools/quic_stream_peer.h" 18 #include "net/quic/test_tools/quic_stream_peer.h"
18 #include "net/quic/test_tools/quic_stream_sequencer_peer.h" 19 #include "net/quic/test_tools/quic_stream_sequencer_peer.h"
19 #include "net/quic/test_tools/quic_test_utils.h" 20 #include "net/quic/test_tools/quic_test_utils.h"
20 #include "net/quic/test_tools/simple_quic_framer.h" 21 #include "net/quic/test_tools/simple_quic_framer.h"
21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h"
23 22
24 using std::string; 23 using std::string;
25 24
26 using testing::_; 25 using testing::_;
27 26
28 namespace net { 27 namespace net {
29 namespace test { 28 namespace test {
30 namespace { 29 namespace {
31 30
32 const char kServerHostname[] = "test.example.com"; 31 const char kServerHostname[] = "test.example.com";
33 const uint16_t kServerPort = 443; 32 const uint16_t kServerPort = 443;
34 33
35 class QuicCryptoClientStreamTest : public ::testing::Test { 34 class QuicCryptoClientStreamTest : public QuicTest {
36 public: 35 public:
37 QuicCryptoClientStreamTest() 36 QuicCryptoClientStreamTest()
38 : server_id_(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED), 37 : server_id_(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED),
39 crypto_config_(crypto_test_utils::ProofVerifierForTesting()) { 38 crypto_config_(crypto_test_utils::ProofVerifierForTesting()) {
40 CreateConnection(); 39 CreateConnection();
41 } 40 }
42 41
43 void CreateConnection() { 42 void CreateConnection() {
44 connection_ = new PacketSavingConnection(&client_helper_, &alarm_factory_, 43 connection_ = new PacketSavingConnection(&client_helper_, &alarm_factory_,
45 Perspective::IS_CLIENT); 44 Perspective::IS_CLIENT);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 crypto_config_.tb_key_params = QuicTagVector{kTB10}; 344 crypto_config_.tb_key_params = QuicTagVector{kTB10};
346 server_id_ = QuicServerId(kServerHostname, kServerPort, PRIVACY_MODE_ENABLED); 345 server_id_ = QuicServerId(kServerHostname, kServerPort, PRIVACY_MODE_ENABLED);
347 CreateConnection(); 346 CreateConnection();
348 347
349 CompleteCryptoHandshake(); 348 CompleteCryptoHandshake();
350 EXPECT_TRUE(stream()->encryption_established()); 349 EXPECT_TRUE(stream()->encryption_established());
351 EXPECT_TRUE(stream()->handshake_confirmed()); 350 EXPECT_TRUE(stream()->handshake_confirmed());
352 EXPECT_EQ(0u, stream()->crypto_negotiated_params().token_binding_key_param); 351 EXPECT_EQ(0u, stream()->crypto_negotiated_params().token_binding_key_param);
353 } 352 }
354 353
355 class QuicCryptoClientStreamStatelessTest : public ::testing::Test { 354 class QuicCryptoClientStreamStatelessTest : public QuicTest {
356 public: 355 public:
357 QuicCryptoClientStreamStatelessTest() 356 QuicCryptoClientStreamStatelessTest()
358 : client_crypto_config_(crypto_test_utils::ProofVerifierForTesting()), 357 : client_crypto_config_(crypto_test_utils::ProofVerifierForTesting()),
359 server_crypto_config_(QuicCryptoServerConfig::TESTING, 358 server_crypto_config_(QuicCryptoServerConfig::TESTING,
360 QuicRandom::GetInstance(), 359 QuicRandom::GetInstance(),
361 crypto_test_utils::ProofSourceForTesting()), 360 crypto_test_utils::ProofSourceForTesting()),
362 server_compressed_certs_cache_( 361 server_compressed_certs_cache_(
363 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), 362 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize),
364 server_id_(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED) { 363 server_id_(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED) {
365 TestQuicSpdyClientSession* client_session = nullptr; 364 TestQuicSpdyClientSession* client_session = nullptr;
(...skipping 28 matching lines...) Expand all
394 &server_connection_, &server_session); 393 &server_connection_, &server_session);
395 CHECK(server_session); 394 CHECK(server_session);
396 server_session_.reset(server_session); 395 server_session_.reset(server_session);
397 crypto_test_utils::FakeServerOptions options; 396 crypto_test_utils::FakeServerOptions options;
398 crypto_test_utils::SetupCryptoServerConfigForTest( 397 crypto_test_utils::SetupCryptoServerConfigForTest(
399 server_connection_->clock(), server_connection_->random_generator(), 398 server_connection_->clock(), server_connection_->random_generator(),
400 &server_crypto_config_, options); 399 &server_crypto_config_, options);
401 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support = true; 400 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support = true;
402 } 401 }
403 402
404 QuicFlagSaver flags_; // Save/restore all QUIC flag values.
405
406 MockQuicConnectionHelper helper_; 403 MockQuicConnectionHelper helper_;
407 MockAlarmFactory alarm_factory_; 404 MockAlarmFactory alarm_factory_;
408 405
409 // Client crypto stream state 406 // Client crypto stream state
410 PacketSavingConnection* client_connection_; 407 PacketSavingConnection* client_connection_;
411 std::unique_ptr<TestQuicSpdyClientSession> client_session_; 408 std::unique_ptr<TestQuicSpdyClientSession> client_session_;
412 QuicCryptoClientConfig client_crypto_config_; 409 QuicCryptoClientConfig client_crypto_config_;
413 410
414 // Server crypto stream state 411 // Server crypto stream state
415 PacketSavingConnection* server_connection_; 412 PacketSavingConnection* server_connection_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 client_state->GetNextServerDesignatedConnectionId(); 444 client_state->GetNextServerDesignatedConnectionId();
448 QuicConnectionId expected_id = 445 QuicConnectionId expected_id =
449 server_session_->connection()->random_generator()->RandUint64(); 446 server_session_->connection()->random_generator()->RandUint64();
450 EXPECT_EQ(GetPeerInMemoryConnectionId(expected_id), server_designated_id); 447 EXPECT_EQ(GetPeerInMemoryConnectionId(expected_id), server_designated_id);
451 EXPECT_FALSE(client_state->has_server_designated_connection_id()); 448 EXPECT_FALSE(client_state->has_server_designated_connection_id());
452 } 449 }
453 450
454 } // namespace 451 } // namespace
455 } // namespace test 452 } // namespace test
456 } // namespace net 453 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_connection_test.cc ('k') | net/quic/core/quic_crypto_server_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698