src/net/quic/quic_network_transaction_unittest.cc
// First request opens QUIC session to alternative service.  Second request
// pools to it, because destination matches and certificate is valid, even
// though quic::QuicServerId is different.
First request opens QUIC session to alternative service.  Second request
pools to it, because destination matches and certificate is valid, even
though quic::QuicServerId is different.
First request opens QUIC session to alternative service . Second request pools to it because destination matches and certificate is valid even though quic :: QuicServerId is different .
TEST_P(QuicNetworkTransactionWithDestinationTest, PoolIfCertificateValid) {
  origin1_ = "mail.example.org";
  origin2_ = "news.example.org";
  SetQuicAlternativeService(origin1_);
  SetQuicAlternativeService(origin2_);
  scoped_refptr<X509Certificate> cert(
      ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem"));
  ASSERT_TRUE(cert->VerifyNameMatch(origin1_));
  ASSERT_TRUE(cert->VerifyNameMatch(origin2_));
  ASSERT_FALSE(cert->VerifyNameMatch(kDifferentHostname));
  ProofVerifyDetailsChromium verify_details;
  verify_details.cert_verify_result.verified_cert = cert;
  verify_details.cert_verify_result.is_issued_by_known_root = true;
  crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details);
  QuicTestPacketMaker client_maker(
      version_,
      quic::QuicUtils::CreateRandomConnectionId(context_.random_generator()),
      context_.clock(), origin1_, quic::Perspective::IS_CLIENT,
      client_headers_include_h2_stream_dependency_);
  QuicTestPacketMaker server_maker(
      version_,
      quic::QuicUtils::CreateRandomConnectionId(context_.random_generator()),
      context_.clock(), origin1_, quic::Perspective::IS_SERVER, false);
  MockQuicData mock_quic_data(version_);
  int packet_num = 1;
  if (VersionUsesHttp3(version_.transport_version)) {
    mock_quic_data.AddWrite(SYNCHRONOUS, ConstructInitialSettingsPacket(
                                             packet_num++, &client_maker));
  }
  mock_quic_data.AddWrite(
      SYNCHRONOUS,
      ConstructClientRequestHeadersPacket(
          packet_num++, GetNthClientInitiatedBidirectionalStreamId(0), true,
          &client_maker));
  mock_quic_data.AddRead(
      ASYNC,
      ConstructServerResponseHeadersPacket(
          1, GetNthClientInitiatedBidirectionalStreamId(0), &server_maker));
  mock_quic_data.AddRead(
      ASYNC,
      ConstructServerDataPacket(
          2, GetNthClientInitiatedBidirectionalStreamId(0), &server_maker));
  mock_quic_data.AddWrite(
      SYNCHRONOUS,
      ConstructClientAckPacket(packet_num++, 2, 1, 1, &client_maker));
  client_maker.set_hostname(origin2_);
  server_maker.set_hostname(origin2_);
  mock_quic_data.AddWrite(
      SYNCHRONOUS,
      ConstructClientRequestHeadersPacket(
          packet_num++, GetNthClientInitiatedBidirectionalStreamId(1), false,
          GetNthClientInitiatedBidirectionalStreamId(0), &client_maker));
  mock_quic_data.AddRead(
      ASYNC,
      ConstructServerResponseHeadersPacket(
          3, GetNthClientInitiatedBidirectionalStreamId(1), &server_maker));
  mock_quic_data.AddRead(
      ASYNC,
      ConstructServerDataPacket(
          4, GetNthClientInitiatedBidirectionalStreamId(1), &server_maker));
  mock_quic_data.AddWrite(
      SYNCHRONOUS,
      ConstructClientAckPacket(packet_num++, 4, 3, 1, &client_maker));
  mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING);  
  mock_quic_data.AddRead(ASYNC, 0);               
  mock_quic_data.AddSocketDataToFactory(&socket_factory_);
  AddHangingSocketData();
  AddHangingSocketData();
  scoped_refptr<TestTaskRunner> quic_task_runner(
      new TestTaskRunner(context_.mock_clock()));
  QuicStreamFactoryPeer::SetAlarmFactory(
      session_->quic_stream_factory(),
      std::make_unique<QuicChromiumAlarmFactory>(quic_task_runner.get(),
                                                 context_.clock()));
  SendRequestAndExpectQuicResponse(origin1_);
  SendRequestAndExpectQuicResponse(origin2_);
  EXPECT_TRUE(AllDataConsumed());
}
TEST_P ( QuicNetworkTransactionWithDestinationTest , PoolIfCertificateValid ) { origin1_ = " " ; origin2_ = " " ; SetQuicAlternativeService ( origin1_ ) ; SetQuicAlternativeService ( origin2_ ) ; scoped_refptr < X509Certificate > cert ( ImportCertFromFile ( GetTestCertsDirectory ( ) , " " ) ) ; ASSERT_TRUE ( cert -> VerifyNameMatch ( origin1_ ) ) ; ASSERT_TRUE ( cert -> VerifyNameMatch ( origin2_ ) ) ; ASSERT_FALSE ( cert -> VerifyNameMatch ( kDifferentHostname ) ) ; ProofVerifyDetailsChromium verify_details ; verify_details . cert_verify_result . verified_cert = cert ; verify_details . cert_verify_result . is_issued_by_known_root = true ; crypto_client_stream_factory_ . AddProofVerifyDetails ( & verify_details ) ; QuicTestPacketMaker client_maker ( version_ , quic :: QuicUtils :: CreateRandomConnectionId ( context_ . random_generator ( ) ) , context_ . clock ( ) , origin1_ , quic :: Perspective :: IS_CLIENT , client_headers_include_h2_stream_dependency_ ) ; QuicTestPacketMaker server_maker ( version_ , quic :: QuicUtils :: CreateRandomConnectionId ( context_ . random_generator ( ) ) , context_ . clock ( ) , origin1_ , quic :: Perspective :: IS_SERVER , false ) ; MockQuicData mock_quic_data ( version_ ) ; int packet_num = 1 ; if ( VersionUsesHttp3 ( version_ . transport_version ) ) { mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructInitialSettingsPacket ( packet_num ++ , & client_maker ) ) ; } mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientRequestHeadersPacket ( packet_num ++ , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , true , & client_maker ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerResponseHeadersPacket ( 1 , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , & server_maker ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerDataPacket ( 2 , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , & server_maker ) ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientAckPacket ( packet_num ++ , 2 , 1 , 1 , & client_maker ) ) ; client_maker . set_hostname ( origin2_ ) ; server_maker . set_hostname ( origin2_ ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientRequestHeadersPacket ( packet_num ++ , GetNthClientInitiatedBidirectionalStreamId ( 1 ) , false , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , & client_maker ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerResponseHeadersPacket ( 3 , GetNthClientInitiatedBidirectionalStreamId ( 1 ) , & server_maker ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerDataPacket ( 4 , GetNthClientInitiatedBidirectionalStreamId ( 1 ) , & server_maker ) ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientAckPacket ( packet_num ++ , 4 , 3 , 1 , & client_maker ) ) ; mock_quic_data . AddRead ( ASYNC , ERR_IO_PENDING ) ; mock_quic_data . AddRead ( ASYNC , 0 ) ; mock_quic_data . AddSocketDataToFactory ( & socket_factory_ ) ; AddHangingSocketData ( ) ; AddHangingSocketData ( ) ; scoped_refptr < TestTaskRunner > quic_task_runner ( new TestTaskRunner ( context_ . mock_clock ( ) ) ) ; QuicStreamFactoryPeer :: SetAlarmFactory ( session_ -> quic_stream_factory ( ) , std :: make_unique < QuicChromiumAlarmFactory > ( quic_task_runner . get ( ) , context_ . clock ( ) ) ) ; SendRequestAndExpectQuicResponse ( origin1_ ) ; SendRequestAndExpectQuicResponse ( origin2_ ) ; EXPECT_TRUE ( AllDataConsumed ( ) ) ; }
First request opens QUIC session to alternative service.
First request opens QUIC session to alternative service .
// No more data to read // EOF