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

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

Issue 2766603004: QUIC: mark QUIC handshake failed if connection is closed after CryptoConnect (Closed)
Patch Set: Created 3 years, 9 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/chromium/quic_stream_factory.h" 5 #include "net/quic/chromium/quic_stream_factory.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <ostream> 8 #include <ostream>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 migrate_sessions_on_network_change_ = true; 309 migrate_sessions_on_network_change_ = true;
310 migrate_sessions_early_ = true; 310 migrate_sessions_early_ = true;
311 Initialize(); 311 Initialize();
312 } 312 }
313 313
314 bool HasActiveSession(const HostPortPair& host_port_pair) { 314 bool HasActiveSession(const HostPortPair& host_port_pair) {
315 QuicServerId server_id(host_port_pair, PRIVACY_MODE_DISABLED); 315 QuicServerId server_id(host_port_pair, PRIVACY_MODE_DISABLED);
316 return QuicStreamFactoryPeer::HasActiveSession(factory_.get(), server_id); 316 return QuicStreamFactoryPeer::HasActiveSession(factory_.get(), server_id);
317 } 317 }
318 318
319 bool HasActiveJob(const HostPortPair& host_port_pair,
320 const PrivacyMode privacy_mode) {
321 QuicServerId server_id(host_port_pair, privacy_mode);
322 return QuicStreamFactoryPeer::HasActiveJob(factory_.get(), server_id);
323 }
324
319 bool HasActiveCertVerifierJob(const QuicServerId& server_id) { 325 bool HasActiveCertVerifierJob(const QuicServerId& server_id) {
320 return QuicStreamFactoryPeer::HasActiveCertVerifierJob(factory_.get(), 326 return QuicStreamFactoryPeer::HasActiveCertVerifierJob(factory_.get(),
321 server_id); 327 server_id);
322 } 328 }
323 329
324 QuicChromiumClientSession* GetActiveSession( 330 QuicChromiumClientSession* GetActiveSession(
325 const HostPortPair& host_port_pair) { 331 const HostPortPair& host_port_pair) {
326 QuicServerId server_id(host_port_pair, PRIVACY_MODE_DISABLED); 332 QuicServerId server_id(host_port_pair, PRIVACY_MODE_DISABLED);
327 return QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server_id); 333 return QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server_id);
328 } 334 }
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 EXPECT_THAT(callback_.WaitForResult(), IsOk()); 1802 EXPECT_THAT(callback_.WaitForResult(), IsOk());
1797 stream = request2.CreateStream(); 1803 stream = request2.CreateStream();
1798 stream.reset(); // Will reset stream 3. 1804 stream.reset(); // Will reset stream 3.
1799 1805
1800 EXPECT_TRUE(socket_data.AllReadDataConsumed()); 1806 EXPECT_TRUE(socket_data.AllReadDataConsumed());
1801 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); 1807 EXPECT_TRUE(socket_data.AllWriteDataConsumed());
1802 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); 1808 EXPECT_TRUE(socket_data2.AllReadDataConsumed());
1803 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); 1809 EXPECT_TRUE(socket_data2.AllWriteDataConsumed());
1804 } 1810 }
1805 1811
1812 // Regression test for crbug.com/700617. Test a write error during the
1813 // crypto handshake will not hang QuicStreamFactory::Job and should
1814 // report QUIC_HANDSHAKE_FAILED to upper layers.
1815 TEST_P(QuicStreamFactoryTest, WriteErrorInCryptoConnect) {
1816 Initialize();
1817 crypto_client_stream_factory_.set_use_normal_crypto_stream();
1818
1819 MockQuicData socket_data;
1820 socket_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING);
1821 socket_data.AddWrite(SYNCHRONOUS, ERR_ADDRESS_UNREACHABLE);
1822 socket_data.AddSocketDataToFactory(&socket_factory_);
1823
1824 // Create request and QuicHttpStream.
1825 QuicStreamRequest request(factory_.get());
1826 EXPECT_EQ(ERR_IO_PENDING,
Ryan Hamilton 2017/03/22 02:38:48 I'm a bit surprised that this returns ERR_IO_PENDI
Zhongyi Shi 2017/03/22 07:00:11 Done.
1827 request.Request(host_port_pair_, privacy_mode_,
1828 /*cert_verify_flags=*/0, url_, "GET", net_log_,
1829 callback_.callback()));
1830 EXPECT_EQ(ERR_QUIC_HANDSHAKE_FAILED, callback_.WaitForResult());
1831 EXPECT_FALSE(HasActiveSession(host_port_pair_));
1832 EXPECT_FALSE(HasActiveJob(host_port_pair_, privacy_mode_));
Ryan Hamilton 2017/03/22 02:38:48 If I understand the bug correctly, in the old code
Zhongyi Shi 2017/03/22 07:00:11 Done. Good point! I have checked those regressio
Ryan Hamilton 2017/03/22 14:13:01 It looks like this is still testing for an active
Zhongyi Shi 2017/03/22 18:53:09 Done.
1833 }
1834
1806 TEST_P(QuicStreamFactoryTest, OnIPAddressChanged) { 1835 TEST_P(QuicStreamFactoryTest, OnIPAddressChanged) {
1807 close_sessions_on_ip_change_ = true; 1836 close_sessions_on_ip_change_ = true;
1808 Initialize(); 1837 Initialize();
1809 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); 1838 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails();
1810 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); 1839 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details);
1811 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); 1840 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details);
1812 1841
1813 MockQuicData socket_data; 1842 MockQuicData socket_data;
1814 socket_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); 1843 socket_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING);
1815 socket_data.AddWrite( 1844 socket_data.AddWrite(
(...skipping 3865 matching lines...) Expand 10 before | Expand all | Expand 10 after
5681 // Clear all cached states. 5710 // Clear all cached states.
5682 factory_->ClearCachedStatesInCryptoConfig( 5711 factory_->ClearCachedStatesInCryptoConfig(
5683 base::Callback<bool(const GURL&)>()); 5712 base::Callback<bool(const GURL&)>());
5684 EXPECT_TRUE(test_cases[0].state->certs().empty()); 5713 EXPECT_TRUE(test_cases[0].state->certs().empty());
5685 EXPECT_TRUE(test_cases[1].state->certs().empty()); 5714 EXPECT_TRUE(test_cases[1].state->certs().empty());
5686 EXPECT_TRUE(test_cases[2].state->certs().empty()); 5715 EXPECT_TRUE(test_cases[2].state->certs().empty());
5687 } 5716 }
5688 5717
5689 } // namespace test 5718 } // namespace test
5690 } // namespace net 5719 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698