| Index: net/quic/quic_stream_factory_test.cc
|
| diff --git a/net/quic/quic_stream_factory_test.cc b/net/quic/quic_stream_factory_test.cc
|
| index ef056be66ec7a0d81f4edd1dc298276f71a7f718..4b4a2fb5e959473ee84e2573a7ad67375018ee37 100644
|
| --- a/net/quic/quic_stream_factory_test.cc
|
| +++ b/net/quic/quic_stream_factory_test.cc
|
| @@ -320,16 +320,16 @@ class QuicStreamFactoryTestBase {
|
| disable_quic_on_timeout_with_open_streams_(false),
|
| idle_connection_timeout_seconds_(kIdleConnectionTimeoutSeconds),
|
| migrate_sessions_on_network_change_(false),
|
| - migrate_sessions_early_(false) {
|
| + migrate_sessions_early_(false),
|
| + race_cert_verification_(false) {
|
| clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
|
| }
|
|
|
| ~QuicStreamFactoryTestBase() {
|
| // If |factory_| was initialized, then it took over ownership of |clock_|.
|
| // If |factory_| was not initialized, then |clock_| needs to be destroyed.
|
| - if (!factory_) {
|
| + if (!factory_)
|
| delete clock_;
|
| - }
|
| }
|
|
|
| void Initialize() {
|
| @@ -352,7 +352,7 @@ class QuicStreamFactoryTestBase {
|
| close_sessions_on_ip_change_,
|
| disable_quic_on_timeout_with_open_streams_,
|
| idle_connection_timeout_seconds_, migrate_sessions_on_network_change_,
|
| - migrate_sessions_early_, QuicTagVector(),
|
| + migrate_sessions_early_, race_cert_verification_, QuicTagVector(),
|
| /*enable_token_binding*/ false));
|
| factory_->set_require_confirmation(false);
|
| EXPECT_FALSE(factory_->has_quic_server_info_factory());
|
| @@ -378,6 +378,11 @@ class QuicStreamFactoryTestBase {
|
| return QuicStreamFactoryPeer::HasActiveSession(factory_.get(), server_id);
|
| }
|
|
|
| + bool HasActiveCertVerifierJob(const QuicServerId& server_id) {
|
| + return QuicStreamFactoryPeer::HasActiveCertVerifierJob(factory_.get(),
|
| + server_id);
|
| + }
|
| +
|
| QuicChromiumClientSession* GetActiveSession(
|
| const HostPortPair& host_port_pair) {
|
| QuicServerId server_id(host_port_pair, PRIVACY_MODE_DISABLED);
|
| @@ -545,6 +550,7 @@ class QuicStreamFactoryTestBase {
|
| int idle_connection_timeout_seconds_;
|
| bool migrate_sessions_on_network_change_;
|
| bool migrate_sessions_early_;
|
| + bool race_cert_verification_;
|
| };
|
|
|
| class QuicStreamFactoryTest : public QuicStreamFactoryTestBase,
|
| @@ -4134,6 +4140,64 @@ TEST_P(QuicStreamFactoryTest, MaybeInitialize) {
|
| EXPECT_EQ(test_cert2, cached2->certs()[0]);
|
| }
|
|
|
| +TEST_P(QuicStreamFactoryTest, StartCertVerifyJob) {
|
| + Initialize();
|
| +
|
| + MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)};
|
| + SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0);
|
| + socket_factory_.AddSocketDataProvider(&socket_data);
|
| +
|
| + // Save current state of |race_cert_verification|.
|
| + bool race_cert_verification =
|
| + QuicStreamFactoryPeer::GetRaceCertVerification(factory_.get());
|
| +
|
| + // Load server config.
|
| + HostPortPair host_port_pair("test.example.com", kDefaultServerPort);
|
| + QuicServerId quic_server_id(host_port_pair_, privacy_mode_);
|
| + QuicStreamFactoryPeer::CacheDummyServerConfig(factory_.get(), quic_server_id);
|
| +
|
| + QuicStreamFactoryPeer::SetRaceCertVerification(factory_.get(), true);
|
| +
|
| + // Start CertVerifyJob.
|
| + QuicAsyncStatus status = QuicStreamFactoryPeer::StartCertVerifyJob(
|
| + factory_.get(), quic_server_id, /*cert_verify_flags=*/0, net_log_);
|
| + EXPECT_NE(QUIC_FAILURE, status);
|
| +
|
| + if (status == QUIC_PENDING) {
|
| + // Verify CertVerifierJob has started.
|
| + EXPECT_TRUE(HasActiveCertVerifierJob(quic_server_id));
|
| +
|
| + while (HasActiveCertVerifierJob(quic_server_id)) {
|
| + base::RunLoop().RunUntilIdle();
|
| + }
|
| + }
|
| + // Verify CertVerifierJob has finished.
|
| + EXPECT_FALSE(HasActiveCertVerifierJob(quic_server_id));
|
| +
|
| + // Start a QUIC request.
|
| + QuicStreamRequest request(factory_.get());
|
| + EXPECT_EQ(ERR_IO_PENDING,
|
| + request.Request(host_port_pair_, privacy_mode_,
|
| + /*cert_verify_flags=*/0, url_, "GET", net_log_,
|
| + callback_.callback()));
|
| +
|
| + EXPECT_EQ(OK, callback_.WaitForResult());
|
| +
|
| + std::unique_ptr<QuicHttpStream> stream = request.CreateStream();
|
| + EXPECT_TRUE(stream.get());
|
| +
|
| + // Restore |race_cert_verification|.
|
| + QuicStreamFactoryPeer::SetRaceCertVerification(factory_.get(),
|
| + race_cert_verification);
|
| +
|
| + EXPECT_TRUE(socket_data.AllReadDataConsumed());
|
| + EXPECT_TRUE(socket_data.AllWriteDataConsumed());
|
| +
|
| + // Verify there are no outstanding CertVerifierJobs after request has
|
| + // finished.
|
| + EXPECT_FALSE(HasActiveCertVerifierJob(quic_server_id));
|
| +}
|
| +
|
| TEST_P(QuicStreamFactoryTest, QuicDoingZeroRTT) {
|
| Initialize();
|
|
|
|
|