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

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

Issue 2966563003: Fix QuicNetworkTransaction*Tests to set QuicAlternativeService with (Closed)
Patch Set: Re #7 Created 3 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 5 #include <algorithm>
6 #include <memory> 6 #include <memory>
7 #include <ostream> 7 #include <ostream>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 DISALLOW_COPY_AND_ASSIGN(TestSocketPerformanceWatcherFactory); 233 DISALLOW_COPY_AND_ASSIGN(TestSocketPerformanceWatcherFactory);
234 }; 234 };
235 235
236 class QuicNetworkTransactionTest 236 class QuicNetworkTransactionTest
237 : public PlatformTest, 237 : public PlatformTest,
238 public ::testing::WithParamInterface<QuicVersion> { 238 public ::testing::WithParamInterface<QuicVersion> {
239 protected: 239 protected:
240 QuicNetworkTransactionTest() 240 QuicNetworkTransactionTest()
241 : version_(GetParam()), 241 : version_(GetParam()),
242 supported_versions_(SupportedVersions(version_)),
242 client_maker_(version_, 243 client_maker_(version_,
243 0, 244 0,
244 &clock_, 245 &clock_,
245 kDefaultServerHostName, 246 kDefaultServerHostName,
246 Perspective::IS_CLIENT), 247 Perspective::IS_CLIENT),
247 server_maker_(version_, 248 server_maker_(version_,
248 0, 249 0,
249 &clock_, 250 &clock_,
250 kDefaultServerHostName, 251 kDefaultServerHostName,
251 Perspective::IS_SERVER), 252 Perspective::IS_SERVER),
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 session_context_.proxy_service = proxy_service_.get(); 532 session_context_.proxy_service = proxy_service_.get();
532 session_context_.ssl_config_service = ssl_config_service_.get(); 533 session_context_.ssl_config_service = ssl_config_service_.get();
533 session_context_.http_auth_handler_factory = auth_handler_factory_.get(); 534 session_context_.http_auth_handler_factory = auth_handler_factory_.get();
534 session_context_.http_server_properties = &http_server_properties_; 535 session_context_.http_server_properties = &http_server_properties_;
535 session_context_.net_log = net_log_.bound().net_log(); 536 session_context_.net_log = net_log_.bound().net_log();
536 537
537 session_.reset(new HttpNetworkSession(session_params_, session_context_)); 538 session_.reset(new HttpNetworkSession(session_params_, session_context_));
538 session_->quic_stream_factory()->set_require_confirmation(false); 539 session_->quic_stream_factory()->set_require_confirmation(false);
539 } 540 }
540 541
541 void CreateSession() { return CreateSession(SupportedVersions(version_)); } 542 void CreateSession() { return CreateSession(supported_versions_); }
542 543
543 void CheckWasQuicResponse(HttpNetworkTransaction* trans) { 544 void CheckWasQuicResponse(HttpNetworkTransaction* trans) {
544 const HttpResponseInfo* response = trans->GetResponseInfo(); 545 const HttpResponseInfo* response = trans->GetResponseInfo();
545 ASSERT_TRUE(response != nullptr); 546 ASSERT_TRUE(response != nullptr);
546 ASSERT_TRUE(response->headers.get() != nullptr); 547 ASSERT_TRUE(response->headers.get() != nullptr);
547 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 548 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
548 EXPECT_TRUE(response->was_fetched_via_spdy); 549 EXPECT_TRUE(response->was_fetched_via_spdy);
549 EXPECT_TRUE(response->was_alpn_negotiated); 550 EXPECT_TRUE(response->was_alpn_negotiated);
550 EXPECT_EQ(QuicHttpStream::ConnectionInfoFromQuicVersion(version_), 551 EXPECT_EQ(QuicHttpStream::ConnectionInfoFromQuicVersion(version_),
551 response->connection_info); 552 response->connection_info);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, true, port); 620 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, true, port);
620 } 621 }
621 622
622 void AddQuicAlternateProtocolMapping( 623 void AddQuicAlternateProtocolMapping(
623 MockCryptoClientStream::HandshakeMode handshake_mode) { 624 MockCryptoClientStream::HandshakeMode handshake_mode) {
624 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); 625 crypto_client_stream_factory_.set_handshake_mode(handshake_mode);
625 url::SchemeHostPort server(request_.url); 626 url::SchemeHostPort server(request_.url);
626 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 627 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
627 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 628 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
628 http_server_properties_.SetQuicAlternativeService( 629 http_server_properties_.SetQuicAlternativeService(
629 server, alternative_service, expiration, 630 server, alternative_service, expiration, supported_versions_);
630 HttpNetworkSession::Params().quic_supported_versions);
631 } 631 }
632 632
633 void AddQuicRemoteAlternativeServiceMapping( 633 void AddQuicRemoteAlternativeServiceMapping(
634 MockCryptoClientStream::HandshakeMode handshake_mode, 634 MockCryptoClientStream::HandshakeMode handshake_mode,
635 const HostPortPair& alternative) { 635 const HostPortPair& alternative) {
636 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); 636 crypto_client_stream_factory_.set_handshake_mode(handshake_mode);
637 url::SchemeHostPort server(request_.url); 637 url::SchemeHostPort server(request_.url);
638 AlternativeService alternative_service(kProtoQUIC, alternative.host(), 638 AlternativeService alternative_service(kProtoQUIC, alternative.host(),
639 alternative.port()); 639 alternative.port());
640 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 640 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
641 http_server_properties_.SetQuicAlternativeService( 641 http_server_properties_.SetQuicAlternativeService(
642 server, alternative_service, expiration, 642 server, alternative_service, expiration, supported_versions_);
643 HttpNetworkSession::Params().quic_supported_versions);
644 } 643 }
645 644
646 void ExpectBrokenAlternateProtocolMapping() { 645 void ExpectBrokenAlternateProtocolMapping() {
647 const url::SchemeHostPort server(request_.url); 646 const url::SchemeHostPort server(request_.url);
648 const AlternativeServiceInfoVector alternative_service_info_vector = 647 const AlternativeServiceInfoVector alternative_service_info_vector =
649 http_server_properties_.GetAlternativeServiceInfos(server); 648 http_server_properties_.GetAlternativeServiceInfos(server);
650 EXPECT_EQ(1u, alternative_service_info_vector.size()); 649 EXPECT_EQ(1u, alternative_service_info_vector.size());
651 EXPECT_TRUE(http_server_properties_.IsAlternativeServiceBroken( 650 EXPECT_TRUE(http_server_properties_.IsAlternativeServiceBroken(
652 alternative_service_info_vector[0].alternative_service())); 651 alternative_service_info_vector[0].alternative_service()));
653 } 652 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 740
742 QuicStreamId GetNthClientInitiatedStreamId(int n) { 741 QuicStreamId GetNthClientInitiatedStreamId(int n) {
743 return test::GetNthClientInitiatedStreamId(version_, n); 742 return test::GetNthClientInitiatedStreamId(version_, n);
744 } 743 }
745 744
746 QuicStreamId GetNthServerInitiatedStreamId(int n) { 745 QuicStreamId GetNthServerInitiatedStreamId(int n) {
747 return test::GetNthServerInitiatedStreamId(version_, n); 746 return test::GetNthServerInitiatedStreamId(version_, n);
748 } 747 }
749 748
750 const QuicVersion version_; 749 const QuicVersion version_;
750 QuicVersionVector supported_versions_;
751 QuicFlagSaver flags_; // Save/restore all QUIC flag values. 751 QuicFlagSaver flags_; // Save/restore all QUIC flag values.
752 MockClock clock_; 752 MockClock clock_;
753 QuicTestPacketMaker client_maker_; 753 QuicTestPacketMaker client_maker_;
754 QuicTestPacketMaker server_maker_; 754 QuicTestPacketMaker server_maker_;
755 std::unique_ptr<HttpNetworkSession> session_; 755 std::unique_ptr<HttpNetworkSession> session_;
756 MockClientSocketFactory socket_factory_; 756 MockClientSocketFactory socket_factory_;
757 ProofVerifyDetailsChromium verify_details_; 757 ProofVerifyDetailsChromium verify_details_;
758 MockCryptoClientStreamFactory crypto_client_stream_factory_; 758 MockCryptoClientStreamFactory crypto_client_stream_factory_;
759 MockHostResolver host_resolver_; 759 MockHostResolver host_resolver_;
760 MockCertVerifier cert_verifier_; 760 MockCertVerifier cert_verifier_;
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 // alternative services. 1197 // alternative services.
1198 TEST_P(QuicNetworkTransactionTest, RetryMisdirectedRequest) { 1198 TEST_P(QuicNetworkTransactionTest, RetryMisdirectedRequest) {
1199 // Set up alternative service to use QUIC. 1199 // Set up alternative service to use QUIC.
1200 // Note that |origins_to_force_quic_on| cannot be used in this test, because 1200 // Note that |origins_to_force_quic_on| cannot be used in this test, because
1201 // that overrides |enable_alternative_services|. 1201 // that overrides |enable_alternative_services|.
1202 url::SchemeHostPort server(request_.url); 1202 url::SchemeHostPort server(request_.url);
1203 AlternativeService alternative_service(kProtoQUIC, kDefaultServerHostName, 1203 AlternativeService alternative_service(kProtoQUIC, kDefaultServerHostName,
1204 443); 1204 443);
1205 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 1205 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
1206 http_server_properties_.SetQuicAlternativeService( 1206 http_server_properties_.SetQuicAlternativeService(
1207 server, alternative_service, expiration, 1207 server, alternative_service, expiration, supported_versions_);
1208 HttpNetworkSession::Params().quic_supported_versions);
1209 1208
1210 // First try: The alternative job uses QUIC and reports an HTTP 421 1209 // First try: The alternative job uses QUIC and reports an HTTP 421
1211 // Misdirected Request error. The main job uses TCP, but |http_data| below is 1210 // Misdirected Request error. The main job uses TCP, but |http_data| below is
1212 // paused at Connect(), so it will never exit the socket pool. This ensures 1211 // paused at Connect(), so it will never exit the socket pool. This ensures
1213 // that the alternate job always wins the race and keeps whether the 1212 // that the alternate job always wins the race and keeps whether the
1214 // |http_data| exits the socket pool before the main job is aborted 1213 // |http_data| exits the socket pool before the main job is aborted
1215 // deterministic. The first main job gets aborted without the socket pool ever 1214 // deterministic. The first main job gets aborted without the socket pool ever
1216 // dispensing the socket, making it available for the second try. 1215 // dispensing the socket, making it available for the second try.
1217 MockQuicData mock_quic_data; 1216 MockQuicData mock_quic_data;
1218 QuicStreamOffset request_header_offset = 0; 1217 QuicStreamOffset request_header_offset = 0;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 http_server_properties->GetAlternativeServiceInfos(https_server).size()); 1459 http_server_properties->GetAlternativeServiceInfos(https_server).size());
1461 1460
1462 // Send http request to the same origin but with diffrent scheme, should not 1461 // Send http request to the same origin but with diffrent scheme, should not
1463 // use QUIC. 1462 // use QUIC.
1464 request_.url = GURL("http://mail.example.org:443"); 1463 request_.url = GURL("http://mail.example.org:443");
1465 SendRequestAndExpectHttpResponse("hello world"); 1464 SendRequestAndExpectHttpResponse("hello world");
1466 } 1465 }
1467 1466
1468 TEST_P(QuicNetworkTransactionTest, 1467 TEST_P(QuicNetworkTransactionTest,
1469 StoreMutuallySupportedVersionsWhenProcessAltSvc) { 1468 StoreMutuallySupportedVersionsWhenProcessAltSvc) {
1469 // Add support for another QUIC version besides |version_|.
1470 for (const QuicVersion& version : AllSupportedVersions()) {
1471 if (version == version_)
1472 continue;
1473 supported_versions_.push_back(version);
1474 break;
1475 }
1476
1470 std::string advertised_versions_list_str = 1477 std::string advertised_versions_list_str =
1471 GenerateQuicVersionsListForAltSvcHeader(AllSupportedVersions()); 1478 GenerateQuicVersionsListForAltSvcHeader(AllSupportedVersions());
1472 std::string altsvc_header = 1479 std::string altsvc_header =
1473 base::StringPrintf("Alt-Svc: quic=\":443\"; v=\"%s\"\r\n\r\n", 1480 base::StringPrintf("Alt-Svc: quic=\":443\"; v=\"%s\"\r\n\r\n",
1474 advertised_versions_list_str.c_str()); 1481 advertised_versions_list_str.c_str());
1475 MockRead http_reads[] = { 1482 MockRead http_reads[] = {
1476 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(altsvc_header.c_str()), 1483 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(altsvc_header.c_str()),
1477 MockRead("hello world"), 1484 MockRead("hello world"),
1478 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), 1485 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
1479 MockRead(ASYNC, OK)}; 1486 MockRead(ASYNC, OK)};
(...skipping 16 matching lines...) Expand all
1496 mock_quic_data.AddRead(ConstructServerDataPacket( 1503 mock_quic_data.AddRead(ConstructServerDataPacket(
1497 2, GetNthClientInitiatedStreamId(0), false, true, 0, "hello!")); 1504 2, GetNthClientInitiatedStreamId(0), false, true, 0, "hello!"));
1498 mock_quic_data.AddWrite(ConstructClientAckPacket(3, 2, 1, 1)); 1505 mock_quic_data.AddWrite(ConstructClientAckPacket(3, 2, 1, 1));
1499 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read 1506 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read
1500 mock_quic_data.AddRead(ASYNC, 0); // EOF 1507 mock_quic_data.AddRead(ASYNC, 0); // EOF
1501 1508
1502 mock_quic_data.AddSocketDataToFactory(&socket_factory_); 1509 mock_quic_data.AddSocketDataToFactory(&socket_factory_);
1503 1510
1504 AddHangingNonAlternateProtocolSocketData(); 1511 AddHangingNonAlternateProtocolSocketData();
1505 1512
1506 // Generate a list of QUIC versions suppored by netstack. 1513 CreateSession(supported_versions_);
1507 QuicVersionVector current_supported_versions = SupportedVersions(version_);
1508 if (version_ != QUIC_VERSION_40) {
1509 current_supported_versions.push_back(QUIC_VERSION_40);
1510 } else {
1511 current_supported_versions.push_back(QUIC_VERSION_37);
1512 }
1513
1514 CreateSession(current_supported_versions);
1515 1514
1516 SendRequestAndExpectHttpResponse("hello world"); 1515 SendRequestAndExpectHttpResponse("hello world");
1517 SendRequestAndExpectQuicResponse("hello!"); 1516 SendRequestAndExpectQuicResponse("hello!");
1518 1517
1519 // Check alternative service is set with only mutually supported versions. 1518 // Check alternative service is set with only mutually supported versions.
1520 const url::SchemeHostPort https_server(request_.url); 1519 const url::SchemeHostPort https_server(request_.url);
1521 const AlternativeServiceInfoVector alt_svc_info_vector = 1520 const AlternativeServiceInfoVector alt_svc_info_vector =
1522 session_->http_server_properties()->GetAlternativeServiceInfos( 1521 session_->http_server_properties()->GetAlternativeServiceInfos(
1523 https_server); 1522 https_server);
1524 EXPECT_EQ(1u, alt_svc_info_vector.size()); 1523 EXPECT_EQ(1u, alt_svc_info_vector.size());
1525 EXPECT_EQ(kProtoQUIC, alt_svc_info_vector[0].alternative_service().protocol); 1524 EXPECT_EQ(kProtoQUIC, alt_svc_info_vector[0].alternative_service().protocol);
1526 EXPECT_EQ(2u, alt_svc_info_vector[0].advertised_versions().size()); 1525 EXPECT_EQ(2u, alt_svc_info_vector[0].advertised_versions().size());
1527 // Advertised versions will be lised in a sorted order. 1526 // Advertised versions will be lised in a sorted order.
1528 std::sort(current_supported_versions.begin(), 1527 std::sort(supported_versions_.begin(), supported_versions_.end());
1529 current_supported_versions.end()); 1528 EXPECT_EQ(supported_versions_[0],
1530 EXPECT_EQ(current_supported_versions[0],
1531 alt_svc_info_vector[0].advertised_versions()[0]); 1529 alt_svc_info_vector[0].advertised_versions()[0]);
1532 EXPECT_EQ(current_supported_versions[1], 1530 EXPECT_EQ(supported_versions_[1],
1533 alt_svc_info_vector[0].advertised_versions()[1]); 1531 alt_svc_info_vector[0].advertised_versions()[1]);
1534 } 1532 }
1535 1533
1536 TEST_P(QuicNetworkTransactionTest, UseAlternativeServiceAllSupportedVersion) { 1534 TEST_P(QuicNetworkTransactionTest, UseAlternativeServiceAllSupportedVersion) {
1537 std::string altsvc_header = 1535 std::string altsvc_header =
1538 base::StringPrintf("Alt-Svc: quic=\":443\"; v=\"%u\"\r\n\r\n", version_); 1536 base::StringPrintf("Alt-Svc: quic=\":443\"; v=\"%u\"\r\n\r\n", version_);
1539 MockRead http_reads[] = { 1537 MockRead http_reads[] = {
1540 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(altsvc_header.c_str()), 1538 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(altsvc_header.c_str()),
1541 MockRead("hello world"), 1539 MockRead("hello world"),
1542 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), 1540 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 2856
2859 mock_quic_data2.AddSocketDataToFactory(&socket_factory_); 2857 mock_quic_data2.AddSocketDataToFactory(&socket_factory_);
2860 2858
2861 CreateSession(); 2859 CreateSession();
2862 2860
2863 // Set up alternative service for |origin1|. 2861 // Set up alternative service for |origin1|.
2864 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 2862 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
2865 http_server_properties_.SetQuicAlternativeService( 2863 http_server_properties_.SetQuicAlternativeService(
2866 url::SchemeHostPort(origin1), 2864 url::SchemeHostPort(origin1),
2867 AlternativeService(kProtoQUIC, "mail.example.com", 443), expiration, 2865 AlternativeService(kProtoQUIC, "mail.example.com", 443), expiration,
2868 HttpNetworkSession::Params().quic_supported_versions); 2866 supported_versions_);
2869 2867
2870 // Set up alternative service for |origin2|. 2868 // Set up alternative service for |origin2|.
2871 AlternativeServiceInfoVector alternative_services; 2869 AlternativeServiceInfoVector alternative_services;
2872 http_server_properties_.SetQuicAlternativeService( 2870 http_server_properties_.SetQuicAlternativeService(
2873 url::SchemeHostPort(origin2), 2871 url::SchemeHostPort(origin2),
2874 AlternativeService(kProtoQUIC, "www.example.com", 443), expiration, 2872 AlternativeService(kProtoQUIC, "www.example.com", 443), expiration,
2875 HttpNetworkSession::Params().quic_supported_versions); 2873 supported_versions_);
2876 // First request opens connection to |destination1| 2874 // First request opens connection to |destination1|
2877 // with QuicServerId.host() == origin1.host(). 2875 // with QuicServerId.host() == origin1.host().
2878 SendRequestAndExpectQuicResponse("hello!"); 2876 SendRequestAndExpectQuicResponse("hello!");
2879 2877
2880 // Second request pools to existing connection with same destination, 2878 // Second request pools to existing connection with same destination,
2881 // because certificate matches, even though QuicServerId is different. 2879 // because certificate matches, even though QuicServerId is different.
2882 // After it is reset, it will fail back to QUIC and mark QUIC as broken. 2880 // After it is reset, it will fail back to QUIC and mark QUIC as broken.
2883 request_.url = origin2; 2881 request_.url = origin2;
2884 SendRequestAndExpectHttpResponse("hello world"); 2882 SendRequestAndExpectHttpResponse("hello world");
2885 2883
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 CreateSession(); 3087 CreateSession();
3090 3088
3091 const char destination1[] = "first.example.com"; 3089 const char destination1[] = "first.example.com";
3092 const char destination2[] = "second.example.com"; 3090 const char destination2[] = "second.example.com";
3093 3091
3094 // Set up alternative service entry to destination1. 3092 // Set up alternative service entry to destination1.
3095 url::SchemeHostPort server(request_.url); 3093 url::SchemeHostPort server(request_.url);
3096 AlternativeService alternative_service(kProtoQUIC, destination1, 443); 3094 AlternativeService alternative_service(kProtoQUIC, destination1, 443);
3097 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 3095 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
3098 http_server_properties_.SetQuicAlternativeService( 3096 http_server_properties_.SetQuicAlternativeService(
3099 server, alternative_service, expiration, 3097 server, alternative_service, expiration, supported_versions_);
3100 HttpNetworkSession::Params().quic_supported_versions);
3101 // First request opens connection to |destination1| 3098 // First request opens connection to |destination1|
3102 // with QuicServerId.host() == kDefaultServerHostName. 3099 // with QuicServerId.host() == kDefaultServerHostName.
3103 SendRequestAndExpectQuicResponse("hello!"); 3100 SendRequestAndExpectQuicResponse("hello!");
3104 3101
3105 // Set up alternative service entry to a different destination. 3102 // Set up alternative service entry to a different destination.
3106 alternative_service = AlternativeService(kProtoQUIC, destination2, 443); 3103 alternative_service = AlternativeService(kProtoQUIC, destination2, 443);
3107 http_server_properties_.SetQuicAlternativeService( 3104 http_server_properties_.SetQuicAlternativeService(
3108 server, alternative_service, expiration, 3105 server, alternative_service, expiration, supported_versions_);
3109 HttpNetworkSession::Params().quic_supported_versions);
3110 // Second request pools to existing connection with same QuicServerId, 3106 // Second request pools to existing connection with same QuicServerId,
3111 // even though alternative service destination is different. 3107 // even though alternative service destination is different.
3112 SendRequestAndExpectQuicResponse("hello!"); 3108 SendRequestAndExpectQuicResponse("hello!");
3113 } 3109 }
3114 3110
3115 // Pool to existing session with matching destination and matching certificate 3111 // Pool to existing session with matching destination and matching certificate
3116 // even if origin is different, and even if the alternative service with 3112 // even if origin is different, and even if the alternative service with
3117 // matching destination is not the first one on the list. 3113 // matching destination is not the first one on the list.
3118 TEST_P(QuicNetworkTransactionTest, PoolByDestination) { 3114 TEST_P(QuicNetworkTransactionTest, PoolByDestination) {
3119 GURL origin1 = request_.url; 3115 GURL origin1 = request_.url;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 CreateSession(); 3160 CreateSession();
3165 3161
3166 const char destination1[] = "first.example.com"; 3162 const char destination1[] = "first.example.com";
3167 const char destination2[] = "second.example.com"; 3163 const char destination2[] = "second.example.com";
3168 3164
3169 // Set up alternative service for |origin1|. 3165 // Set up alternative service for |origin1|.
3170 AlternativeService alternative_service1(kProtoQUIC, destination1, 443); 3166 AlternativeService alternative_service1(kProtoQUIC, destination1, 443);
3171 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 3167 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
3172 http_server_properties_.SetQuicAlternativeService( 3168 http_server_properties_.SetQuicAlternativeService(
3173 url::SchemeHostPort(origin1), alternative_service1, expiration, 3169 url::SchemeHostPort(origin1), alternative_service1, expiration,
3174 HttpNetworkSession::Params().quic_supported_versions); 3170 supported_versions_);
3175 3171
3176 // Set up multiple alternative service entries for |origin2|, 3172 // Set up multiple alternative service entries for |origin2|,
3177 // the first one with a different destination as for |origin1|, 3173 // the first one with a different destination as for |origin1|,
3178 // the second one with the same. The second one should be used, 3174 // the second one with the same. The second one should be used,
3179 // because the request can be pooled to that one. 3175 // because the request can be pooled to that one.
3180 AlternativeService alternative_service2(kProtoQUIC, destination2, 443); 3176 AlternativeService alternative_service2(kProtoQUIC, destination2, 443);
3181 AlternativeServiceInfoVector alternative_services; 3177 AlternativeServiceInfoVector alternative_services;
3182 alternative_services.push_back( 3178 alternative_services.push_back(
3183 AlternativeServiceInfo::CreateQuicAlternativeServiceInfo( 3179 AlternativeServiceInfo::CreateQuicAlternativeServiceInfo(
3184 alternative_service2, expiration, 3180 alternative_service2, expiration,
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after
4684 EXPECT_TRUE(mock_quic_data.AllReadDataConsumed()); 4680 EXPECT_TRUE(mock_quic_data.AllReadDataConsumed());
4685 EXPECT_TRUE(mock_quic_data.AllWriteDataConsumed()); 4681 EXPECT_TRUE(mock_quic_data.AllWriteDataConsumed());
4686 } 4682 }
4687 4683
4688 class QuicNetworkTransactionWithDestinationTest 4684 class QuicNetworkTransactionWithDestinationTest
4689 : public PlatformTest, 4685 : public PlatformTest,
4690 public ::testing::WithParamInterface<PoolingTestParams> { 4686 public ::testing::WithParamInterface<PoolingTestParams> {
4691 protected: 4687 protected:
4692 QuicNetworkTransactionWithDestinationTest() 4688 QuicNetworkTransactionWithDestinationTest()
4693 : version_(GetParam().version), 4689 : version_(GetParam().version),
4690 supported_versions_(SupportedVersions(version_)),
4694 destination_type_(GetParam().destination_type), 4691 destination_type_(GetParam().destination_type),
4695 cert_transparency_verifier_(new MultiLogCTVerifier()), 4692 cert_transparency_verifier_(new MultiLogCTVerifier()),
4696 ssl_config_service_(new SSLConfigServiceDefaults), 4693 ssl_config_service_(new SSLConfigServiceDefaults),
4697 proxy_service_(ProxyService::CreateDirect()), 4694 proxy_service_(ProxyService::CreateDirect()),
4698 auth_handler_factory_( 4695 auth_handler_factory_(
4699 HttpAuthHandlerFactory::CreateDefault(&host_resolver_)), 4696 HttpAuthHandlerFactory::CreateDefault(&host_resolver_)),
4700 random_generator_(0), 4697 random_generator_(0),
4701 ssl_data_(ASYNC, OK) {} 4698 ssl_data_(ASYNC, OK) {}
4702 4699
4703 void SetUp() override { 4700 void SetUp() override {
4704 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); 4701 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
4705 base::RunLoop().RunUntilIdle(); 4702 base::RunLoop().RunUntilIdle();
4706 4703
4707 HttpNetworkSession::Params session_params; 4704 HttpNetworkSession::Params session_params;
4708 session_params.enable_quic = true; 4705 session_params.enable_quic = true;
4709 session_params.quic_supported_versions = SupportedVersions(version_); 4706 session_params.quic_supported_versions = supported_versions_;
4710 4707
4711 HttpNetworkSession::Context session_context; 4708 HttpNetworkSession::Context session_context;
4712 4709
4713 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(20)); 4710 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(20));
4714 session_context.quic_clock = &clock_; 4711 session_context.quic_clock = &clock_;
4715 4712
4716 crypto_client_stream_factory_.set_handshake_mode( 4713 crypto_client_stream_factory_.set_handshake_mode(
4717 MockCryptoClientStream::CONFIRM_HANDSHAKE); 4714 MockCryptoClientStream::CONFIRM_HANDSHAKE);
4718 session_context.quic_crypto_client_stream_factory = 4715 session_context.quic_crypto_client_stream_factory =
4719 &crypto_client_stream_factory_; 4716 &crypto_client_stream_factory_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4757 destination = HostPortPair(origin2_, 443); 4754 destination = HostPortPair(origin2_, 443);
4758 break; 4755 break;
4759 case DIFFERENT: 4756 case DIFFERENT:
4760 destination = HostPortPair(kDifferentHostname, 443); 4757 destination = HostPortPair(kDifferentHostname, 443);
4761 break; 4758 break;
4762 } 4759 }
4763 AlternativeService alternative_service(kProtoQUIC, destination); 4760 AlternativeService alternative_service(kProtoQUIC, destination);
4764 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 4761 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
4765 http_server_properties_.SetQuicAlternativeService( 4762 http_server_properties_.SetQuicAlternativeService(
4766 url::SchemeHostPort("https", origin, 443), alternative_service, 4763 url::SchemeHostPort("https", origin, 443), alternative_service,
4767 expiration, session_->params().quic_supported_versions); 4764 expiration, supported_versions_);
4768 } 4765 }
4769 4766
4770 std::unique_ptr<QuicEncryptedPacket> ConstructClientRequestHeadersPacket( 4767 std::unique_ptr<QuicEncryptedPacket> ConstructClientRequestHeadersPacket(
4771 QuicPacketNumber packet_number, 4768 QuicPacketNumber packet_number,
4772 QuicStreamId stream_id, 4769 QuicStreamId stream_id,
4773 bool should_include_version, 4770 bool should_include_version,
4774 QuicStreamOffset* offset, 4771 QuicStreamOffset* offset,
4775 QuicTestPacketMaker* maker) { 4772 QuicTestPacketMaker* maker) {
4776 SpdyPriority priority = 4773 SpdyPriority priority =
4777 ConvertRequestPriorityToQuicPriority(DEFAULT_PRIORITY); 4774 ConvertRequestPriorityToQuicPriority(DEFAULT_PRIORITY);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
4888 response->connection_info); 4885 response->connection_info);
4889 EXPECT_EQ(443, response->socket_address.port()); 4886 EXPECT_EQ(443, response->socket_address.port());
4890 } 4887 }
4891 4888
4892 QuicStreamId GetNthClientInitiatedStreamId(int n) { 4889 QuicStreamId GetNthClientInitiatedStreamId(int n) {
4893 return test::GetNthClientInitiatedStreamId(version_, n); 4890 return test::GetNthClientInitiatedStreamId(version_, n);
4894 } 4891 }
4895 4892
4896 MockClock clock_; 4893 MockClock clock_;
4897 QuicVersion version_; 4894 QuicVersion version_;
4895 QuicVersionVector supported_versions_;
4898 DestinationType destination_type_; 4896 DestinationType destination_type_;
4899 std::string origin1_; 4897 std::string origin1_;
4900 std::string origin2_; 4898 std::string origin2_;
4901 std::unique_ptr<HttpNetworkSession> session_; 4899 std::unique_ptr<HttpNetworkSession> session_;
4902 MockClientSocketFactory socket_factory_; 4900 MockClientSocketFactory socket_factory_;
4903 MockHostResolver host_resolver_; 4901 MockHostResolver host_resolver_;
4904 MockCertVerifier cert_verifier_; 4902 MockCertVerifier cert_verifier_;
4905 TransportSecurityState transport_security_state_; 4903 TransportSecurityState transport_security_state_;
4906 std::unique_ptr<CTVerifier> cert_transparency_verifier_; 4904 std::unique_ptr<CTVerifier> cert_transparency_verifier_;
4907 CTPolicyEnforcer ct_policy_enforcer_; 4905 CTPolicyEnforcer ct_policy_enforcer_;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
5192 5190
5193 request_.url = GURL("https://mail.example.org/pushed.jpg"); 5191 request_.url = GURL("https://mail.example.org/pushed.jpg");
5194 ChunkedUploadDataStream upload_data(0); 5192 ChunkedUploadDataStream upload_data(0);
5195 upload_data.AppendData("1", 1, true); 5193 upload_data.AppendData("1", 1, true);
5196 request_.upload_data_stream = &upload_data; 5194 request_.upload_data_stream = &upload_data;
5197 SendRequestAndExpectQuicResponse("and hello!"); 5195 SendRequestAndExpectQuicResponse("and hello!");
5198 } 5196 }
5199 5197
5200 } // namespace test 5198 } // namespace test
5201 } // namespace net 5199 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698