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

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

Issue 1411063004: Remove insecure QUIC support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enough! Created 5 years, 1 month 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.cc ('k') | net/quic/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/quic_crypto_client_stream.h" 5 #include "net/quic/quic_crypto_client_stream.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" 8 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
9 #include "net/quic/crypto/quic_decrypter.h" 9 #include "net/quic/crypto/quic_decrypter.h"
10 #include "net/quic/crypto/quic_encrypter.h" 10 #include "net/quic/crypto/quic_encrypter.h"
11 #include "net/quic/quic_flags.h" 11 #include "net/quic/quic_flags.h"
12 #include "net/quic/quic_protocol.h" 12 #include "net/quic/quic_protocol.h"
13 #include "net/quic/quic_server_id.h" 13 #include "net/quic/quic_server_id.h"
14 #include "net/quic/quic_utils.h" 14 #include "net/quic/quic_utils.h"
15 #include "net/quic/test_tools/crypto_test_utils.h" 15 #include "net/quic/test_tools/crypto_test_utils.h"
16 #include "net/quic/test_tools/quic_test_utils.h" 16 #include "net/quic/test_tools/quic_test_utils.h"
17 #include "net/quic/test_tools/simple_quic_framer.h" 17 #include "net/quic/test_tools/simple_quic_framer.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 using std::string; 21 using std::string;
22 22
23 namespace net { 23 namespace net {
24 namespace test { 24 namespace test {
25 namespace { 25 namespace {
26 26
27 const char kServerHostname[] = "example.com"; 27 #if defined(USE_OPENSSL)
28 const uint16 kServerPort = 80; 28
29 const char kServerHostname[] = "test.example.com";
30 const uint16 kServerPort = 443;
29 31
30 class QuicCryptoClientStreamTest : public ::testing::Test { 32 class QuicCryptoClientStreamTest : public ::testing::Test {
31 public: 33 public:
32 QuicCryptoClientStreamTest() 34 QuicCryptoClientStreamTest()
33 : server_id_(kServerHostname, kServerPort, false, PRIVACY_MODE_DISABLED) { 35 : server_id_(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED),
36 crypto_config_(CryptoTestUtils::ProofVerifierForTesting()) {
34 CreateConnection(); 37 CreateConnection();
35 } 38 }
36 39
37 void CreateConnection() { 40 void CreateConnection() {
38 connection_ = new PacketSavingConnection(&helper_, Perspective::IS_CLIENT); 41 connection_ = new PacketSavingConnection(&helper_, Perspective::IS_CLIENT);
39 // Advance the time, because timers do not like uninitialized times. 42 // Advance the time, because timers do not like uninitialized times.
40 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 43 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
41 44
42 session_.reset(new TestQuicSpdyClientSession( 45 session_.reset(new TestQuicSpdyClientSession(
43 connection_, DefaultQuicConfig(), server_id_, &crypto_config_)); 46 connection_, DefaultQuicConfig(), server_id_, &crypto_config_));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 config->IdleConnectionStateLifetime().ToSeconds()); 111 config->IdleConnectionStateLifetime().ToSeconds());
109 EXPECT_EQ(kDefaultMaxStreamsPerConnection, 112 EXPECT_EQ(kDefaultMaxStreamsPerConnection,
110 config->MaxStreamsPerConnection()); 113 config->MaxStreamsPerConnection());
111 114
112 const QuicCryptoNegotiatedParameters& crypto_params( 115 const QuicCryptoNegotiatedParameters& crypto_params(
113 stream()->crypto_negotiated_params()); 116 stream()->crypto_negotiated_params());
114 EXPECT_EQ(crypto_config_.aead[0], crypto_params.aead); 117 EXPECT_EQ(crypto_config_.aead[0], crypto_params.aead);
115 EXPECT_EQ(crypto_config_.kexs[0], crypto_params.key_exchange); 118 EXPECT_EQ(crypto_config_.kexs[0], crypto_params.key_exchange);
116 } 119 }
117 120
118 TEST_F(QuicCryptoClientStreamTest, InvalidHostname) {
119 server_id_ =
120 QuicServerId("invalid", kServerPort, false, PRIVACY_MODE_DISABLED);
121
122 CreateConnection();
123
124 CompleteCryptoHandshake();
125 EXPECT_TRUE(stream()->encryption_established());
126 EXPECT_TRUE(stream()->handshake_confirmed());
127 }
128
129 TEST_F(QuicCryptoClientStreamTest, ExpiredServerConfig) { 121 TEST_F(QuicCryptoClientStreamTest, ExpiredServerConfig) {
130 // Seed the config with a cached server config. 122 // Seed the config with a cached server config.
131 CompleteCryptoHandshake(); 123 CompleteCryptoHandshake();
132 124
133 // Recreate connection with the new config. 125 // Recreate connection with the new config.
134 CreateConnection(); 126 CreateConnection();
135 127
136 // Advance time 5 years to ensure that we pass the expiry time of the cached 128 // Advance time 5 years to ensure that we pass the expiry time of the cached
137 // server config. 129 // server config.
138 connection_->AdvanceTime( 130 connection_->AdvanceTime(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 server_config_update.set_tag(kSCUP); 193 server_config_update.set_tag(kSCUP);
202 scoped_ptr<QuicData> data( 194 scoped_ptr<QuicData> data(
203 CryptoFramer::ConstructHandshakeMessage(server_config_update)); 195 CryptoFramer::ConstructHandshakeMessage(server_config_update));
204 stream()->OnStreamFrame(QuicStreamFrame(kCryptoStreamId, /*fin=*/false, 196 stream()->OnStreamFrame(QuicStreamFrame(kCryptoStreamId, /*fin=*/false,
205 /*offset=*/0, data->AsStringPiece())); 197 /*offset=*/0, data->AsStringPiece()));
206 } 198 }
207 199
208 class QuicCryptoClientStreamStatelessTest : public ::testing::Test { 200 class QuicCryptoClientStreamStatelessTest : public ::testing::Test {
209 public: 201 public:
210 QuicCryptoClientStreamStatelessTest() 202 QuicCryptoClientStreamStatelessTest()
211 : server_crypto_config_(QuicCryptoServerConfig::TESTING, 203 : client_crypto_config_(CryptoTestUtils::ProofVerifierForTesting()),
212 QuicRandom::GetInstance()), 204 server_crypto_config_(QuicCryptoServerConfig::TESTING,
213 server_id_(kServerHostname, kServerPort, false, PRIVACY_MODE_DISABLED) { 205 QuicRandom::GetInstance(),
206 CryptoTestUtils::ProofSourceForTesting()),
207 server_id_(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED) {
214 TestQuicSpdyClientSession* client_session = nullptr; 208 TestQuicSpdyClientSession* client_session = nullptr;
215 CreateClientSessionForTest(server_id_, 209 CreateClientSessionForTest(server_id_,
216 /* supports_stateless_rejects= */ true, 210 /* supports_stateless_rejects= */ true,
217 QuicTime::Delta::FromSeconds(100000), &helper_, 211 QuicTime::Delta::FromSeconds(100000), &helper_,
218 &client_crypto_config_, &client_connection_, 212 &client_crypto_config_, &client_connection_,
219 &client_session); 213 &client_session);
220 CHECK(client_session); 214 CHECK(client_session);
221 client_session_.reset(client_session); 215 client_session_.reset(client_session);
222 } 216 }
223 217
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 ASSERT_FALSE(client_state->GetNextServerNonce().empty()); 280 ASSERT_FALSE(client_state->GetNextServerNonce().empty());
287 ASSERT_TRUE(client_state->has_server_designated_connection_id()); 281 ASSERT_TRUE(client_state->has_server_designated_connection_id());
288 QuicConnectionId server_designated_id = 282 QuicConnectionId server_designated_id =
289 client_state->GetNextServerDesignatedConnectionId(); 283 client_state->GetNextServerDesignatedConnectionId();
290 QuicConnectionId expected_id = 284 QuicConnectionId expected_id =
291 server_session_->connection()->random_generator()->RandUint64(); 285 server_session_->connection()->random_generator()->RandUint64();
292 EXPECT_EQ(expected_id, server_designated_id); 286 EXPECT_EQ(expected_id, server_designated_id);
293 EXPECT_FALSE(client_state->has_server_designated_connection_id()); 287 EXPECT_FALSE(client_state->has_server_designated_connection_id());
294 } 288 }
295 289
290 #endif
291
296 } // namespace 292 } // namespace
297 } // namespace test 293 } // namespace test
298 } // namespace net 294 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_client_stream.cc ('k') | net/quic/quic_crypto_server_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698