src/net/quic/quic_network_transaction_unittest.cc
// Verify that when an origin has two alt-svc advertisements, one local and one
// remote, that when the local is broken the request will go over QUIC via
// the remote Alt-Svc.
// This is a regression test for crbug/825646.
Verify that when an origin has two alt-svc advertisements, one local and one
remote, that when the local is broken the request will go over QUIC via
the remote Alt-Svc.
This is a regression test for crbug/825646.
Verify that when an origin has two alt - svc advertisements one local and one remote that when the local is broken the request will go over QUIC via the remote Alt - Svc . This is a regression test for crbug / 825646 .
TEST_P(QuicNetworkTransactionTest, RemoteAltSvcWorkingWhileLocalAltSvcBroken) {
  context_.params()->allow_remote_alt_svc = true;
  GURL origin1 = request_.url;  
  GURL origin2("https://www.example.org/");
  ASSERT_NE(origin1.host(), origin2.host());
  scoped_refptr<X509Certificate> cert(
      ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem"));
  ASSERT_TRUE(cert->VerifyNameMatch("www.example.org"));
  ASSERT_TRUE(cert->VerifyNameMatch("mail.example.org"));
  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);
  MockQuicData mock_quic_data(version_);
  int packet_num = 1;
  if (VersionUsesHttp3(version_.transport_version)) {
    mock_quic_data.AddWrite(SYNCHRONOUS,
                            ConstructInitialSettingsPacket(packet_num++));
  }
  mock_quic_data.AddWrite(
      SYNCHRONOUS,
      ConstructClientRequestHeadersPacket(
          packet_num++, GetNthClientInitiatedBidirectionalStreamId(0), true,
          true, GetRequestHeaders("GET", "https", "/")));
  mock_quic_data.AddRead(
      ASYNC, ConstructServerResponseHeadersPacket(
                 1, GetNthClientInitiatedBidirectionalStreamId(0), false, false,
                 GetResponseHeaders("200 OK")));
  std::string header = ConstructDataHeader(6);
  mock_quic_data.AddRead(
      ASYNC, ConstructServerDataPacket(
                 2, GetNthClientInitiatedBidirectionalStreamId(0), false, true,
                 header + "hello!"));
  mock_quic_data.AddWrite(SYNCHRONOUS,
                          ConstructClientAckPacket(packet_num++, 2, 1, 1));
  mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING);  
  mock_quic_data.AddRead(ASYNC, 0);               
  mock_quic_data.AddSocketDataToFactory(&socket_factory_);
  MockQuicData mock_quic_data2(version_);
  mock_quic_data2.AddSocketDataToFactory(&socket_factory_);
  AddHangingNonAlternateProtocolSocketData();
  CreateSession();
  AlternativeService local_alternative(kProtoQUIC, "mail.example.org", 443);
  AlternativeService remote_alternative(kProtoQUIC, "www.example.org", 443);
  base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
  AlternativeServiceInfoVector alternative_services;
  alternative_services.push_back(
      AlternativeServiceInfo::CreateQuicAlternativeServiceInfo(
          local_alternative, expiration,
          context_.params()->supported_versions));
  alternative_services.push_back(
      AlternativeServiceInfo::CreateQuicAlternativeServiceInfo(
          remote_alternative, expiration,
          context_.params()->supported_versions));
  http_server_properties_->SetAlternativeServices(url::SchemeHostPort(origin1),
                                                  NetworkIsolationKey(),
                                                  alternative_services);
  http_server_properties_->MarkAlternativeServiceBroken(local_alternative,
                                                        NetworkIsolationKey());
  SendRequestAndExpectQuicResponse("hello!");
}
TEST_P ( QuicNetworkTransactionTest , RemoteAltSvcWorkingWhileLocalAltSvcBroken ) { context_ . params ( ) -> allow_remote_alt_svc = true ; GURL origin1 = request_ . url ; GURL origin2 ( " " ) ; ASSERT_NE ( origin1 . host ( ) , origin2 . host ( ) ) ; scoped_refptr < X509Certificate > cert ( ImportCertFromFile ( GetTestCertsDirectory ( ) , " " ) ) ; ASSERT_TRUE ( cert -> VerifyNameMatch ( " " ) ) ; ASSERT_TRUE ( cert -> VerifyNameMatch ( " " ) ) ; 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 ) ; MockQuicData mock_quic_data ( version_ ) ; int packet_num = 1 ; if ( VersionUsesHttp3 ( version_ . transport_version ) ) { mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructInitialSettingsPacket ( packet_num ++ ) ) ; } mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientRequestHeadersPacket ( packet_num ++ , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , true , true , GetRequestHeaders ( " " , " " , " " ) ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerResponseHeadersPacket ( 1 , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , false , false , GetResponseHeaders ( " " ) ) ) ; std :: string header = ConstructDataHeader ( 6 ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerDataPacket ( 2 , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , false , true , header + " " ) ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientAckPacket ( packet_num ++ , 2 , 1 , 1 ) ) ; mock_quic_data . AddRead ( ASYNC , ERR_IO_PENDING ) ; mock_quic_data . AddRead ( ASYNC , 0 ) ; mock_quic_data . AddSocketDataToFactory ( & socket_factory_ ) ; MockQuicData mock_quic_data2 ( version_ ) ; mock_quic_data2 . AddSocketDataToFactory ( & socket_factory_ ) ; AddHangingNonAlternateProtocolSocketData ( ) ; CreateSession ( ) ; AlternativeService local_alternative ( kProtoQUIC , " " , 443 ) ; AlternativeService remote_alternative ( kProtoQUIC , " " , 443 ) ; base :: Time expiration = base :: Time :: Now ( ) + base :: TimeDelta :: FromDays ( 1 ) ; AlternativeServiceInfoVector alternative_services ; alternative_services . push_back ( AlternativeServiceInfo :: CreateQuicAlternativeServiceInfo ( local_alternative , expiration , context_ . params ( ) -> supported_versions ) ) ; alternative_services . push_back ( AlternativeServiceInfo :: CreateQuicAlternativeServiceInfo ( remote_alternative , expiration , context_ . params ( ) -> supported_versions ) ) ; http_server_properties_ -> SetAlternativeServices ( url :: SchemeHostPort ( origin1 ) , NetworkIsolationKey ( ) , alternative_services ) ; http_server_properties_ -> MarkAlternativeServiceBroken ( local_alternative , NetworkIsolationKey ( ) ) ; SendRequestAndExpectQuicResponse ( " " ) ; }
Verify that when an origin has two alt-svc advertisements, one local and one
remote, that when the local is broken the request will go over QUIC via
the remote Alt-Svc.
Verify that when an origin has two alt - svc advertisements one local and one remote that when the local is broken the request will go over QUIC via the remote Alt - Svc .
// mail.example.org // No more data to read // EOF // Set up alternative service for |origin1|.