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

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

Issue 23279011: Require handshake confirmation until a QUIC connection is created succesfully when using a new netw… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added test Created 7 years, 4 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 | Annotate | Revision Log
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_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "net/cert/cert_verifier.h" 9 #include "net/cert/cert_verifier.h"
10 #include "net/dns/mock_host_resolver.h" 10 #include "net/dns/mock_host_resolver.h"
(...skipping 17 matching lines...) Expand all
28 protected: 28 protected:
29 QuicStreamFactoryTest() 29 QuicStreamFactoryTest()
30 : clock_(new MockClock()), 30 : clock_(new MockClock()),
31 factory_(&host_resolver_, &socket_factory_, 31 factory_(&host_resolver_, &socket_factory_,
32 &crypto_client_stream_factory_, 32 &crypto_client_stream_factory_,
33 &random_generator_, clock_), 33 &random_generator_, clock_),
34 host_port_proxy_pair_(HostPortPair("www.google.com", 443), 34 host_port_proxy_pair_(HostPortPair("www.google.com", 443),
35 ProxyServer::Direct()), 35 ProxyServer::Direct()),
36 is_https_(false), 36 is_https_(false),
37 cert_verifier_(CertVerifier::CreateDefault()) { 37 cert_verifier_(CertVerifier::CreateDefault()) {
38 factory_.set_require_confirmation(false);
38 } 39 }
39 40
40 scoped_ptr<QuicEncryptedPacket> ConstructRstPacket( 41 scoped_ptr<QuicEncryptedPacket> ConstructRstPacket(
41 QuicPacketSequenceNumber num, 42 QuicPacketSequenceNumber num,
42 QuicStreamId stream_id) { 43 QuicStreamId stream_id) {
43 QuicPacketHeader header; 44 QuicPacketHeader header;
44 header.public_header.guid = 0xDEADBEEF; 45 header.public_header.guid = 0xDEADBEEF;
45 header.public_header.reset_flag = false; 46 header.public_header.reset_flag = false;
46 header.public_header.version_flag = true; 47 header.public_header.version_flag = true;
47 header.packet_sequence_number = num; 48 header.packet_sequence_number = num;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); 336 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream();
336 HttpRequestInfo request_info; 337 HttpRequestInfo request_info;
337 EXPECT_EQ(OK, stream->InitializeStream(&request_info, 338 EXPECT_EQ(OK, stream->InitializeStream(&request_info,
338 DEFAULT_PRIORITY, 339 DEFAULT_PRIORITY,
339 net_log_, CompletionCallback())); 340 net_log_, CompletionCallback()));
340 341
341 // Change the IP address and verify that stream saw the error. 342 // Change the IP address and verify that stream saw the error.
342 factory_.OnIPAddressChanged(); 343 factory_.OnIPAddressChanged();
343 EXPECT_EQ(ERR_NETWORK_CHANGED, 344 EXPECT_EQ(ERR_NETWORK_CHANGED,
344 stream->ReadResponseHeaders(callback_.callback())); 345 stream->ReadResponseHeaders(callback_.callback()));
346 EXPECT_TRUE(factory_.require_confirmation());
345 347
346 // Now attempting to request a stream to the same origin should create 348 // Now attempting to request a stream to the same origin should create
347 // a new session. 349 // a new session.
348 350
349 QuicStreamRequest request2(&factory_); 351 QuicStreamRequest request2(&factory_);
350 EXPECT_EQ(ERR_IO_PENDING, request2.Request(host_port_proxy_pair_, is_https_, 352 EXPECT_EQ(ERR_IO_PENDING, request2.Request(host_port_proxy_pair_, is_https_,
351 cert_verifier_.get(), net_log_, 353 cert_verifier_.get(), net_log_,
352 callback_.callback())); 354 callback_.callback()));
353 355
354 EXPECT_EQ(OK, callback_.WaitForResult()); 356 EXPECT_EQ(OK, callback_.WaitForResult());
355 stream = request2.ReleaseStream(); 357 stream = request2.ReleaseStream();
356 stream.reset(); // Will reset stream 3. 358 stream.reset(); // Will reset stream 3.
357 359
358 EXPECT_TRUE(socket_data.at_read_eof()); 360 EXPECT_TRUE(socket_data.at_read_eof());
359 EXPECT_TRUE(socket_data.at_write_eof()); 361 EXPECT_TRUE(socket_data.at_write_eof());
360 EXPECT_TRUE(socket_data2.at_read_eof()); 362 EXPECT_TRUE(socket_data2.at_read_eof());
361 EXPECT_TRUE(socket_data2.at_write_eof()); 363 EXPECT_TRUE(socket_data2.at_write_eof());
362 } 364 }
363 365
364 } // namespace test 366 } // namespace test
365 } // namespace net 367 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698