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

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

Issue 1397983007: relnote: remove insecure QUIC support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rch_insecure_quic
Patch Set: Compile fix 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
« no previous file with comments | « net/quic/quic_crypto_client_stream_test.cc ('k') | net/quic/quic_end_to_end_unittest.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/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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 namespace { 61 namespace {
62 62
63 const char kServerHostname[] = "test.example.com"; 63 const char kServerHostname[] = "test.example.com";
64 const uint16 kServerPort = 443; 64 const uint16 kServerPort = 443;
65 65
66 class QuicCryptoServerStreamTest : public ::testing::TestWithParam<bool> { 66 class QuicCryptoServerStreamTest : public ::testing::TestWithParam<bool> {
67 public: 67 public:
68 QuicCryptoServerStreamTest() 68 QuicCryptoServerStreamTest()
69 : server_crypto_config_(QuicCryptoServerConfig::TESTING, 69 : server_crypto_config_(QuicCryptoServerConfig::TESTING,
70 QuicRandom::GetInstance()), 70 QuicRandom::GetInstance(),
71 server_id_(kServerHostname, kServerPort, true, PRIVACY_MODE_DISABLED) { 71 CryptoTestUtils::ProofSourceForTesting()),
72 #if defined(USE_OPENSSL) 72 server_id_(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED),
73 server_crypto_config_.SetProofSource( 73 client_crypto_config_(CryptoTestUtils::ProofVerifierForTesting()) {
74 CryptoTestUtils::ProofSourceForTesting());
75 #else
76 // TODO(rch): Implement a NSS proof source.
77 server_crypto_config_.SetProofSource(
78 CryptoTestUtils::FakeProofSourceForTesting());
79 #endif
80 server_crypto_config_.set_strike_register_no_startup_period(); 74 server_crypto_config_.set_strike_register_no_startup_period();
81 75
82 InitializeServer(); 76 InitializeServer();
83 77
84 if (AsyncStrikeRegisterVerification()) { 78 if (AsyncStrikeRegisterVerification()) {
85 string orbit = 79 string orbit =
86 QuicCryptoServerConfigPeer::GetPrimaryOrbit(server_crypto_config_); 80 QuicCryptoServerConfigPeer::GetPrimaryOrbit(server_crypto_config_);
87 strike_register_client_ = new DelayedVerifyStrikeRegisterClient( 81 strike_register_client_ = new DelayedVerifyStrikeRegisterClient(
88 10000, // strike_register_max_entries 82 10000, // strike_register_max_entries
89 static_cast<uint32>( 83 static_cast<uint32>(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Initializes a fake client, and all its associated state, for 115 // Initializes a fake client, and all its associated state, for
122 // testing. May be called multiple times. 116 // testing. May be called multiple times.
123 void InitializeFakeClient(bool supports_stateless_rejects) { 117 void InitializeFakeClient(bool supports_stateless_rejects) {
124 TestQuicSpdyClientSession* client_session = nullptr; 118 TestQuicSpdyClientSession* client_session = nullptr;
125 CreateClientSessionForTest(server_id_, supports_stateless_rejects, 119 CreateClientSessionForTest(server_id_, supports_stateless_rejects,
126 QuicTime::Delta::FromSeconds(100000), 120 QuicTime::Delta::FromSeconds(100000),
127 &client_crypto_config_, &client_connection_, 121 &client_crypto_config_, &client_connection_,
128 &client_session); 122 &client_session);
129 CHECK(client_session); 123 CHECK(client_session);
130 client_session_.reset(client_session); 124 client_session_.reset(client_session);
131 if (!client_options_.dont_verify_certs) {
132 #if defined(USE_OPENSSL)
133 client_crypto_config_.SetProofVerifier(
134 CryptoTestUtils::ProofVerifierForTesting());
135 #else
136 // TODO(rch): Implement a NSS proof source.
137 client_crypto_config_.SetProofVerifier(
138 CryptoTestUtils::FakeProofVerifierForTesting());
139 #endif
140 }
141 } 125 }
142 126
143 bool AsyncStrikeRegisterVerification() { 127 bool AsyncStrikeRegisterVerification() {
144 return GetParam(); 128 return GetParam();
145 } 129 }
146 130
147 void ConstructHandshakeMessage() { 131 void ConstructHandshakeMessage() {
148 CryptoFramer framer; 132 CryptoFramer framer;
149 message_data_.reset(framer.ConstructHandshakeMessage(message_)); 133 message_data_.reset(framer.ConstructHandshakeMessage(message_));
150 } 134 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 TEST_P(QuicCryptoServerStreamTest, BadMessageType) { 361 TEST_P(QuicCryptoServerStreamTest, BadMessageType) {
378 message_.set_tag(kSHLO); 362 message_.set_tag(kSHLO);
379 ConstructHandshakeMessage(); 363 ConstructHandshakeMessage();
380 EXPECT_CALL(*server_connection_, 364 EXPECT_CALL(*server_connection_,
381 SendConnectionClose(QUIC_INVALID_CRYPTO_MESSAGE_TYPE)); 365 SendConnectionClose(QUIC_INVALID_CRYPTO_MESSAGE_TYPE));
382 server_stream()->OnStreamFrame( 366 server_stream()->OnStreamFrame(
383 QuicStreamFrame(kCryptoStreamId, /*fin=*/false, /*offset=*/0, 367 QuicStreamFrame(kCryptoStreamId, /*fin=*/false, /*offset=*/0,
384 message_data_->AsStringPiece())); 368 message_data_->AsStringPiece()));
385 } 369 }
386 370
387 TEST_P(QuicCryptoServerStreamTest, WithoutCertificates) {
388 server_crypto_config_.SetProofSource(nullptr);
389 server_id_ =
390 QuicServerId(kServerHostname, kServerPort, false, PRIVACY_MODE_DISABLED);
391 client_options_.dont_verify_certs = true;
392
393 // Only 2 client hellos need to be sent in the no-certs case: one to get the
394 // source-address token and the second to finish.
395 EXPECT_EQ(2, CompleteCryptoHandshake());
396 EXPECT_TRUE(server_stream()->encryption_established());
397 EXPECT_TRUE(server_stream()->handshake_confirmed());
398 }
399
400 TEST_P(QuicCryptoServerStreamTest, ChannelID) { 371 TEST_P(QuicCryptoServerStreamTest, ChannelID) {
401 client_options_.channel_id_enabled = true; 372 client_options_.channel_id_enabled = true;
402 client_options_.channel_id_source_async = false; 373 client_options_.channel_id_source_async = false;
403 // CompleteCryptoHandshake verifies 374 // CompleteCryptoHandshake verifies
404 // server_stream()->crypto_negotiated_params().channel_id is correct. 375 // server_stream()->crypto_negotiated_params().channel_id is correct.
405 EXPECT_EQ(2, CompleteCryptoHandshake()); 376 EXPECT_EQ(2, CompleteCryptoHandshake());
406 EXPECT_TRUE(server_stream()->encryption_established()); 377 EXPECT_TRUE(server_stream()->encryption_established());
407 EXPECT_TRUE(server_stream()->handshake_confirmed()); 378 EXPECT_TRUE(server_stream()->handshake_confirmed());
408 } 379 }
409 380
(...skipping 23 matching lines...) Expand all
433 message_.Clear(); 404 message_.Clear();
434 QuicConfig stateful_reject_config = DefaultQuicConfig(); 405 QuicConfig stateful_reject_config = DefaultQuicConfig();
435 stateful_reject_config.ToHandshakeMessage(&message_); 406 stateful_reject_config.ToHandshakeMessage(&message_);
436 EXPECT_FALSE( 407 EXPECT_FALSE(
437 QuicCryptoServerStreamPeer::DoesPeerSupportStatelessRejects(message_)); 408 QuicCryptoServerStreamPeer::DoesPeerSupportStatelessRejects(message_));
438 } 409 }
439 410
440 } // namespace 411 } // namespace
441 } // namespace test 412 } // namespace test
442 } // namespace net 413 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_client_stream_test.cc ('k') | net/quic/quic_end_to_end_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698