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

Side by Side Diff: net/quic/quic_crypto_server_stream_test.cc

Issue 1411063004: Remove insecure QUIC support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
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/quic_crypto_server_stream.h" 5 #include "net/quic/quic_crypto_server_stream.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 namespace { 62 namespace {
63 63
64 const char kServerHostname[] = "test.example.com"; 64 const char kServerHostname[] = "test.example.com";
65 const uint16 kServerPort = 443; 65 const uint16 kServerPort = 443;
66 66
67 class QuicCryptoServerStreamTest : public ::testing::TestWithParam<bool> { 67 class QuicCryptoServerStreamTest : public ::testing::TestWithParam<bool> {
68 public: 68 public:
69 QuicCryptoServerStreamTest() 69 QuicCryptoServerStreamTest()
70 : server_crypto_config_(QuicCryptoServerConfig::TESTING, 70 : server_crypto_config_(QuicCryptoServerConfig::TESTING,
71 QuicRandom::GetInstance()), 71 QuicRandom::GetInstance(),
72 server_id_(kServerHostname, kServerPort, true, PRIVACY_MODE_DISABLED) { 72 CryptoTestUtils::ProofSourceForTesting()),
73 #if defined(USE_OPENSSL) 73 server_id_(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED),
74 server_crypto_config_.SetProofSource( 74 client_crypto_config_(CryptoTestUtils::ProofVerifierForTesting()) {
75 CryptoTestUtils::ProofSourceForTesting());
76 #else
77 // TODO(rch): Implement a NSS proof source.
78 server_crypto_config_.SetProofSource(
79 CryptoTestUtils::FakeProofSourceForTesting());
80 #endif
81 server_crypto_config_.set_strike_register_no_startup_period(); 75 server_crypto_config_.set_strike_register_no_startup_period();
82 76
83 InitializeServer(); 77 InitializeServer();
84 78
85 if (AsyncStrikeRegisterVerification()) { 79 if (AsyncStrikeRegisterVerification()) {
86 string orbit = 80 string orbit =
87 QuicCryptoServerConfigPeer::GetPrimaryOrbit(server_crypto_config_); 81 QuicCryptoServerConfigPeer::GetPrimaryOrbit(server_crypto_config_);
88 strike_register_client_ = new DelayedVerifyStrikeRegisterClient( 82 strike_register_client_ = new DelayedVerifyStrikeRegisterClient(
89 10000, // strike_register_max_entries 83 10000, // strike_register_max_entries
90 static_cast<uint32>( 84 static_cast<uint32>(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // testing. May be called multiple times. 120 // testing. May be called multiple times.
127 void InitializeFakeClient(bool supports_stateless_rejects) { 121 void InitializeFakeClient(bool supports_stateless_rejects) {
128 TestQuicSpdyClientSession* client_session = nullptr; 122 TestQuicSpdyClientSession* client_session = nullptr;
129 helpers_.push_back(new MockHelper); 123 helpers_.push_back(new MockHelper);
130 CreateClientSessionForTest(server_id_, supports_stateless_rejects, 124 CreateClientSessionForTest(server_id_, supports_stateless_rejects,
131 QuicTime::Delta::FromSeconds(100000), 125 QuicTime::Delta::FromSeconds(100000),
132 helpers_.back(), &client_crypto_config_, 126 helpers_.back(), &client_crypto_config_,
133 &client_connection_, &client_session); 127 &client_connection_, &client_session);
134 CHECK(client_session); 128 CHECK(client_session);
135 client_session_.reset(client_session); 129 client_session_.reset(client_session);
136 if (!client_options_.dont_verify_certs) {
137 #if defined(USE_OPENSSL)
138 client_crypto_config_.SetProofVerifier(
139 CryptoTestUtils::ProofVerifierForTesting());
140 #else
141 // TODO(rch): Implement a NSS proof source.
142 client_crypto_config_.SetProofVerifier(
143 CryptoTestUtils::FakeProofVerifierForTesting());
144 #endif
145 }
146 } 130 }
147 131
148 bool AsyncStrikeRegisterVerification() { 132 bool AsyncStrikeRegisterVerification() {
149 if (server_connection_->version() > QUIC_VERSION_26) { 133 if (server_connection_->version() > QUIC_VERSION_26) {
150 return false; 134 return false;
151 } 135 }
152 return GetParam(); 136 return GetParam();
153 } 137 }
154 138
155 void ConstructHandshakeMessage() { 139 void ConstructHandshakeMessage() {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 TEST_P(QuicCryptoServerStreamTest, BadMessageType) { 372 TEST_P(QuicCryptoServerStreamTest, BadMessageType) {
389 message_.set_tag(kSHLO); 373 message_.set_tag(kSHLO);
390 ConstructHandshakeMessage(); 374 ConstructHandshakeMessage();
391 EXPECT_CALL(*server_connection_, 375 EXPECT_CALL(*server_connection_,
392 SendConnectionClose(QUIC_INVALID_CRYPTO_MESSAGE_TYPE)); 376 SendConnectionClose(QUIC_INVALID_CRYPTO_MESSAGE_TYPE));
393 server_stream()->OnStreamFrame( 377 server_stream()->OnStreamFrame(
394 QuicStreamFrame(kCryptoStreamId, /*fin=*/false, /*offset=*/0, 378 QuicStreamFrame(kCryptoStreamId, /*fin=*/false, /*offset=*/0,
395 message_data_->AsStringPiece())); 379 message_data_->AsStringPiece()));
396 } 380 }
397 381
398 TEST_P(QuicCryptoServerStreamTest, WithoutCertificates) {
399 server_crypto_config_.SetProofSource(nullptr);
400 server_id_ =
401 QuicServerId(kServerHostname, kServerPort, false, PRIVACY_MODE_DISABLED);
402 client_options_.dont_verify_certs = true;
403
404 // Only 2 client hellos need to be sent in the no-certs case: one to get the
405 // source-address token and the second to finish.
406 EXPECT_EQ(2, CompleteCryptoHandshake());
407 EXPECT_TRUE(server_stream()->encryption_established());
408 EXPECT_TRUE(server_stream()->handshake_confirmed());
409 }
410
411 TEST_P(QuicCryptoServerStreamTest, ChannelID) { 382 TEST_P(QuicCryptoServerStreamTest, ChannelID) {
412 client_options_.channel_id_enabled = true; 383 client_options_.channel_id_enabled = true;
413 client_options_.channel_id_source_async = false; 384 client_options_.channel_id_source_async = false;
414 // CompleteCryptoHandshake verifies 385 // CompleteCryptoHandshake verifies
415 // server_stream()->crypto_negotiated_params().channel_id is correct. 386 // server_stream()->crypto_negotiated_params().channel_id is correct.
416 EXPECT_EQ(2, CompleteCryptoHandshake()); 387 EXPECT_EQ(2, CompleteCryptoHandshake());
417 EXPECT_TRUE(server_stream()->encryption_established()); 388 EXPECT_TRUE(server_stream()->encryption_established());
418 EXPECT_TRUE(server_stream()->handshake_confirmed()); 389 EXPECT_TRUE(server_stream()->handshake_confirmed());
419 } 390 }
420 391
(...skipping 23 matching lines...) Expand all
444 message_.Clear(); 415 message_.Clear();
445 QuicConfig stateful_reject_config = DefaultQuicConfig(); 416 QuicConfig stateful_reject_config = DefaultQuicConfig();
446 stateful_reject_config.ToHandshakeMessage(&message_); 417 stateful_reject_config.ToHandshakeMessage(&message_);
447 EXPECT_FALSE( 418 EXPECT_FALSE(
448 QuicCryptoServerStreamPeer::DoesPeerSupportStatelessRejects(message_)); 419 QuicCryptoServerStreamPeer::DoesPeerSupportStatelessRejects(message_));
449 } 420 }
450 421
451 } // namespace 422 } // namespace
452 } // namespace test 423 } // namespace test
453 } // namespace net 424 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698