| Index: net/http/http_server_properties_impl_unittest.cc
|
| diff --git a/net/http/http_server_properties_impl_unittest.cc b/net/http/http_server_properties_impl_unittest.cc
|
| index d06574f30891050472f1ab15c0b5b56fea275b67..64cce64ceb8fde58b5e59dba4326db7e2bbdc4d5 100644
|
| --- a/net/http/http_server_properties_impl_unittest.cc
|
| +++ b/net/http/http_server_properties_impl_unittest.cc
|
| @@ -55,13 +55,13 @@ struct SpdySettingsDataToVerify {
|
|
|
| class HttpServerPropertiesImplTest : public testing::Test {
|
| protected:
|
| - bool HasAlternativeService(const HostPortPair& origin) {
|
| + bool HasAlternativeService(const SchemeOriginPair& origin) {
|
| const AlternativeServiceVector alternative_service_vector =
|
| impl_.GetAlternativeServices(origin);
|
| return !alternative_service_vector.empty();
|
| }
|
|
|
| - bool SetAlternativeService(const HostPortPair& origin,
|
| + bool SetAlternativeService(const SchemeOriginPair& origin,
|
| const AlternativeService& alternative_service,
|
| double alternative_probability) {
|
| const base::Time expiration =
|
| @@ -106,25 +106,29 @@ typedef HttpServerPropertiesImplTest SpdyServerPropertiesTest;
|
|
|
| TEST_F(SpdyServerPropertiesTest, Initialize) {
|
| HostPortPair spdy_server_google("www.google.com", 443);
|
| + SchemeOriginPair google_server("https", spdy_server_google);
|
| std::string spdy_server_g = spdy_server_google.ToString();
|
|
|
| HostPortPair spdy_server_photos("photos.google.com", 443);
|
| + SchemeOriginPair photos_server("https", spdy_server_photos);
|
| std::string spdy_server_p = spdy_server_photos.ToString();
|
|
|
| HostPortPair spdy_server_docs("docs.google.com", 443);
|
| + SchemeOriginPair docs_server("https", spdy_server_docs);
|
| std::string spdy_server_d = spdy_server_docs.ToString();
|
|
|
| HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + SchemeOriginPair mail_server("https", spdy_server_mail);
|
| std::string spdy_server_m = spdy_server_mail.ToString();
|
|
|
| // Check by initializing NULL spdy servers.
|
| impl_.InitializeSpdyServers(NULL, true);
|
| - EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google));
|
| + EXPECT_FALSE(impl_.SupportsRequestPriority(google_server));
|
|
|
| // Check by initializing empty spdy servers.
|
| std::vector<std::string> spdy_servers;
|
| impl_.InitializeSpdyServers(&spdy_servers, true);
|
| - EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google));
|
| + EXPECT_FALSE(impl_.SupportsRequestPriority(google_server));
|
|
|
| // Check by initializing www.google.com:443 and photos.google.com:443 as spdy
|
| // servers.
|
| @@ -132,8 +136,8 @@ TEST_F(SpdyServerPropertiesTest, Initialize) {
|
| spdy_servers1.push_back(spdy_server_g); // Will be 0th index.
|
| spdy_servers1.push_back(spdy_server_p); // Will be 1st index.
|
| impl_.InitializeSpdyServers(&spdy_servers1, true);
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_photos));
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(photos_server));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(google_server));
|
|
|
| // Verify spdy_server_g and spdy_server_d are in the list in the same order.
|
| base::ListValue spdy_server_list;
|
| @@ -169,10 +173,10 @@ TEST_F(SpdyServerPropertiesTest, Initialize) {
|
| ASSERT_TRUE(spdy_server_list.GetString(3, &string_value_d));
|
| ASSERT_EQ(spdy_server_d, string_value_d);
|
|
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_mail));
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_photos));
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(docs_server));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(mail_server));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(photos_server));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(google_server));
|
|
|
| // Verify new data that is being initialized overwrites what is already in the
|
| // memory and also verify the recency list order.
|
| @@ -196,47 +200,50 @@ TEST_F(SpdyServerPropertiesTest, Initialize) {
|
|
|
| // Verify photos and mail servers don't support SPDY and other servers support
|
| // SPDY.
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
|
| - EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
|
| - EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_photos));
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(docs_server));
|
| + EXPECT_FALSE(impl_.SupportsRequestPriority(mail_server));
|
| + EXPECT_FALSE(impl_.SupportsRequestPriority(photos_server));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(google_server));
|
| }
|
|
|
| TEST_F(SpdyServerPropertiesTest, SupportsRequestPriorityTest) {
|
| - HostPortPair spdy_server_empty(std::string(), 443);
|
| + SchemeOriginPair spdy_server_empty("https", std::string(), 443);
|
| +
|
| EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_empty));
|
|
|
| // Add www.google.com:443 as supporting SPDY.
|
| HostPortPair spdy_server_google("www.google.com", 443);
|
| + SchemeOriginPair google_server("https", spdy_server_google);
|
| impl_.SetSupportsSpdy(spdy_server_google, true);
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(google_server));
|
|
|
| // Add mail.google.com:443 as not supporting SPDY.
|
| - HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + SchemeOriginPair spdy_server_mail("https", "mail.google.com", 443);
|
| EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
|
|
|
| // Add docs.google.com:443 as supporting SPDY.
|
| HostPortPair spdy_server_docs("docs.google.com", 443);
|
| + SchemeOriginPair docs_server("https", spdy_server_docs);
|
| impl_.SetSupportsSpdy(spdy_server_docs, true);
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(docs_server));
|
|
|
| // Add www.youtube.com:443 as supporting QUIC.
|
| - HostPortPair quic_server_youtube("www.youtube.com", 443);
|
| + SchemeOriginPair quic_server_youtube("https", "www.youtube.com", 443);
|
| const AlternativeService alternative_service1(QUIC, "www.youtube.com", 443);
|
| SetAlternativeService(quic_server_youtube, alternative_service1, 1.0);
|
| EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_youtube));
|
|
|
| // Add www.example.com:443 with two alternative services, one supporting QUIC.
|
| - HostPortPair quic_server_example("www.example.com", 443);
|
| + SchemeOriginPair quic_server_example("https", "www.example.com", 443);
|
| const AlternativeService alternative_service2(NPN_HTTP_2, "", 443);
|
| SetAlternativeService(quic_server_example, alternative_service2, 1.0);
|
| SetAlternativeService(quic_server_example, alternative_service1, 1.0);
|
| EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_example));
|
|
|
| // Verify all the entries are the same after additions.
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(google_server));
|
| EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(docs_server));
|
| EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_youtube));
|
| EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_example));
|
| }
|
| @@ -244,16 +251,18 @@ TEST_F(SpdyServerPropertiesTest, SupportsRequestPriorityTest) {
|
| TEST_F(SpdyServerPropertiesTest, Clear) {
|
| // Add www.google.com:443 and mail.google.com:443 as supporting SPDY.
|
| HostPortPair spdy_server_google("www.google.com", 443);
|
| + SchemeOriginPair google_server("https", spdy_server_google);
|
| impl_.SetSupportsSpdy(spdy_server_google, true);
|
| HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + SchemeOriginPair mail_server("https", spdy_server_mail);
|
| impl_.SetSupportsSpdy(spdy_server_mail, true);
|
|
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_mail));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(google_server));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(mail_server));
|
|
|
| impl_.Clear();
|
| - EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google));
|
| - EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
|
| + EXPECT_FALSE(impl_.SupportsRequestPriority(google_server));
|
| + EXPECT_FALSE(impl_.SupportsRequestPriority(mail_server));
|
| }
|
|
|
| TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) {
|
| @@ -265,6 +274,7 @@ TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) {
|
|
|
| // Check empty server is not added.
|
| HostPortPair spdy_server_empty(std::string(), 443);
|
| + SchemeOriginPair empty_server("https", spdy_server_empty);
|
| impl_.SetSupportsSpdy(spdy_server_empty, true);
|
| impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
|
| EXPECT_EQ(0U, spdy_server_list.GetSize());
|
| @@ -272,8 +282,10 @@ TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) {
|
| std::string string_value_g;
|
| std::string string_value_m;
|
| HostPortPair spdy_server_google("www.google.com", 443);
|
| + SchemeOriginPair google_server("https", spdy_server_google);
|
| std::string spdy_server_g = spdy_server_google.ToString();
|
| HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + SchemeOriginPair mail_server("https", spdy_server_mail);
|
| std::string spdy_server_m = spdy_server_mail.ToString();
|
|
|
| // Add www.google.com:443 as not supporting SPDY.
|
| @@ -319,8 +331,10 @@ TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) {
|
| std::string string_value_g;
|
| std::string string_value_m;
|
| HostPortPair spdy_server_google("www.google.com", 443);
|
| + SchemeOriginPair google_server("https", spdy_server_google);
|
| std::string spdy_server_g = spdy_server_google.ToString();
|
| HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + SchemeOriginPair mail_server("https", spdy_server_mail);
|
| std::string spdy_server_m = spdy_server_mail.ToString();
|
|
|
| // Add www.google.com:443 as supporting SPDY.
|
| @@ -342,7 +356,7 @@ TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) {
|
|
|
| // Get www.google.com:443 should reorder SpdyServerHostPortMap. Verify that it
|
| // is www.google.com:443 is the MRU server.
|
| - EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
|
| + EXPECT_TRUE(impl_.SupportsRequestPriority(google_server));
|
| impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
|
| ASSERT_EQ(2U, spdy_server_list.GetSize());
|
| ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g));
|
| @@ -354,18 +368,18 @@ TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) {
|
| typedef HttpServerPropertiesImplTest AlternateProtocolServerPropertiesTest;
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, Basic) {
|
| - HostPortPair test_host_port_pair("foo", 80);
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + SchemeOriginPair scheme_origin("http", "foo", 80);
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
|
|
| AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
|
| - SetAlternativeService(test_host_port_pair, alternative_service, 1.0);
|
| + SetAlternativeService(scheme_origin, alternative_service, 1.0);
|
| const AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service, alternative_service_vector[0]);
|
|
|
| impl_.Clear();
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) {
|
| @@ -388,12 +402,11 @@ TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service4, 1.0, expiration));
|
|
|
| - HostPortPair test_host_port_pair("foo", 443);
|
| - impl_.SetAlternativeServices(test_host_port_pair,
|
| - alternative_service_info_vector);
|
| + SchemeOriginPair scheme_origin("https", "foo", 443);
|
| + impl_.SetAlternativeServices(scheme_origin, alternative_service_info_vector);
|
|
|
| const AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(3u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service2, alternative_service_vector[0]);
|
| EXPECT_EQ(alternative_service3, alternative_service_vector[1]);
|
| @@ -401,11 +414,11 @@ TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) {
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, DefaultProbabilityExcluded) {
|
| - HostPortPair test_host_port_pair("foo", 80);
|
| + SchemeOriginPair scheme_origin("http", "foo", 80);
|
| const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
|
| - SetAlternativeService(test_host_port_pair, alternative_service, 0.99);
|
| + SetAlternativeService(scheme_origin, alternative_service, 0.99);
|
|
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| // GetAlternativeServices and HasAlternativeServices should only return the ones
|
| @@ -428,12 +441,11 @@ TEST_F(AlternateProtocolServerPropertiesTest, Probability) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service4, 0.6, expiration));
|
|
|
| - HostPortPair test_host_port_pair("foo", 80);
|
| - impl_.SetAlternativeServices(test_host_port_pair,
|
| - alternative_service_info_vector);
|
| + SchemeOriginPair scheme_origin("http", "foo", 80);
|
| + impl_.SetAlternativeServices(scheme_origin, alternative_service_info_vector);
|
|
|
| const AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(2u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service2, alternative_service_vector[0]);
|
| EXPECT_EQ(alternative_service4, alternative_service_vector[1]);
|
| @@ -442,19 +454,19 @@ TEST_F(AlternateProtocolServerPropertiesTest, Probability) {
|
| TEST_F(AlternateProtocolServerPropertiesTest, ProbabilityExcluded) {
|
| impl_.SetAlternativeServiceProbabilityThreshold(0.75);
|
|
|
| - HostPortPair test_host_port_pair("foo", 80);
|
| + SchemeOriginPair scheme_origin("http", "foo", 80);
|
| const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
|
| - SetAlternativeService(test_host_port_pair, alternative_service, 0.5);
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + SetAlternativeService(scheme_origin, alternative_service, 0.5);
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, ZeroProbabilityAlwaysExcluded) {
|
| impl_.SetAlternativeServiceProbabilityThreshold(0.0);
|
|
|
| - HostPortPair test_host_port_pair("foo", 80);
|
| + SchemeOriginPair scheme_origin("http", "foo", 80);
|
| const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
|
| - SetAlternativeService(test_host_port_pair, alternative_service, 0);
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + SetAlternativeService(scheme_origin, alternative_service, 0);
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| @@ -463,11 +475,12 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| // |alternative_service_map| does not have an entry for
|
| // |test_host_port_pair1|.
|
| HostPortPair test_host_port_pair1("foo1", 80);
|
| + SchemeOriginPair scheme_origin1("http", test_host_port_pair1);
|
| const AlternativeService alternative_service1(NPN_HTTP_2, "bar1", 443);
|
| const base::Time now = base::Time::Now();
|
| base::Time expiration1 = now + base::TimeDelta::FromDays(1);
|
| // 1st entry in the memory.
|
| - impl_.SetAlternativeService(test_host_port_pair1, alternative_service1, 1.0,
|
| + impl_.SetAlternativeService(scheme_origin1, alternative_service1, 1.0,
|
| expiration1);
|
|
|
| // |test_host_port_pair2| has an alternative service, which will be
|
| @@ -480,9 +493,9 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service2, 1.0, expiration2));
|
| HostPortPair test_host_port_pair2("foo2", 80);
|
| + SchemeOriginPair scheme_origin2("http", test_host_port_pair2);
|
| // 0th entry in the memory.
|
| - impl_.SetAlternativeServices(test_host_port_pair2,
|
| - alternative_service_info_vector);
|
| + impl_.SetAlternativeServices(scheme_origin2, alternative_service_info_vector);
|
|
|
| // Prepare |alternative_service_map| to be loaded by
|
| // InitializeAlternativeServiceServers().
|
| @@ -494,10 +507,11 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| 0.7, expiration3);
|
| // Simulate updating data for 0th entry with data from Preferences.
|
| alternative_service_map.Put(
|
| - test_host_port_pair2,
|
| + scheme_origin2,
|
| AlternativeServiceInfoVector(/*size=*/1, alternative_service_info1));
|
|
|
| HostPortPair test_host_port_pair3("foo3", 80);
|
| + SchemeOriginPair scheme_origin3("http", test_host_port_pair3);
|
| const AlternativeService alternative_service4(NPN_HTTP_2, "bar4", 1234);
|
| base::Time expiration4 = now + base::TimeDelta::FromDays(4);
|
| const AlternativeServiceInfo alternative_service_info2(alternative_service4,
|
| @@ -505,7 +519,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| // Add an old entry from Preferences, this will be added to end of recency
|
| // list.
|
| alternative_service_map.Put(
|
| - test_host_port_pair3,
|
| + scheme_origin3,
|
| AlternativeServiceInfoVector(/*size=*/1, alternative_service_info2));
|
|
|
| // MRU list will be test_host_port_pair2, test_host_port_pair1,
|
| @@ -517,19 +531,19 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| ASSERT_EQ(3u, map.size());
|
| AlternativeServiceMap::const_iterator map_it = map.begin();
|
|
|
| - EXPECT_TRUE(map_it->first.Equals(test_host_port_pair2));
|
| + EXPECT_TRUE(map_it->first.host_port_pair().Equals(test_host_port_pair2));
|
| ASSERT_EQ(1u, map_it->second.size());
|
| EXPECT_EQ(alternative_service3, map_it->second[0].alternative_service);
|
| EXPECT_EQ(0.7, map_it->second[0].probability);
|
| EXPECT_EQ(expiration3, map_it->second[0].expiration);
|
| ++map_it;
|
| - EXPECT_TRUE(map_it->first.Equals(test_host_port_pair1));
|
| + EXPECT_TRUE(map_it->first.host_port_pair().Equals(test_host_port_pair1));
|
| ASSERT_EQ(1u, map_it->second.size());
|
| EXPECT_EQ(alternative_service1, map_it->second[0].alternative_service);
|
| EXPECT_EQ(1.0, map_it->second[0].probability);
|
| EXPECT_EQ(expiration1, map_it->second[0].expiration);
|
| ++map_it;
|
| - EXPECT_TRUE(map_it->first.Equals(test_host_port_pair3));
|
| + EXPECT_TRUE(map_it->first.host_port_pair().Equals(test_host_port_pair3));
|
| ASSERT_EQ(1u, map_it->second.size());
|
| EXPECT_EQ(alternative_service4, map_it->second[0].alternative_service);
|
| EXPECT_EQ(0.2, map_it->second[0].probability);
|
| @@ -540,12 +554,12 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| // InitializeAlternativeServiceServers() should not crash if there is an empty
|
| // hostname is the mapping.
|
| TEST_F(AlternateProtocolServerPropertiesTest, InitializeWithEmptyHostname) {
|
| - const HostPortPair host_port_pair("foo", 443);
|
| + SchemeOriginPair scheme_origin("https", "foo", 443);
|
| const AlternativeService alternative_service_with_empty_hostname(NPN_HTTP_2,
|
| "", 1234);
|
| const AlternativeService alternative_service_with_foo_hostname(NPN_HTTP_2,
|
| "foo", 1234);
|
| - SetAlternativeService(host_port_pair, alternative_service_with_empty_hostname,
|
| + SetAlternativeService(scheme_origin, alternative_service_with_empty_hostname,
|
| 1.0);
|
| impl_.MarkAlternativeServiceBroken(alternative_service_with_foo_hostname);
|
|
|
| @@ -556,7 +570,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, InitializeWithEmptyHostname) {
|
| EXPECT_TRUE(
|
| impl_.IsAlternativeServiceBroken(alternative_service_with_foo_hostname));
|
| const AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service_with_foo_hostname,
|
| alternative_service_vector[0]);
|
| @@ -567,6 +581,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, InitializeWithEmptyHostname) {
|
| // with empty value.
|
| TEST_F(AlternateProtocolServerPropertiesTest, EmptyVector) {
|
| HostPortPair host_port_pair("foo", 443);
|
| + SchemeOriginPair scheme_origin("https", host_port_pair);
|
| const AlternativeService alternative_service(NPN_HTTP_2, "bar", 443);
|
| base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1);
|
| const AlternativeServiceInfo alternative_service_info(alternative_service,
|
| @@ -574,7 +589,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, EmptyVector) {
|
| AlternativeServiceMap alternative_service_map(
|
| AlternativeServiceMap::NO_AUTO_EVICT);
|
| alternative_service_map.Put(
|
| - host_port_pair,
|
| + scheme_origin,
|
| AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
|
|
|
| // Prepare |alternative_service_map_| with a single key that has a single
|
| @@ -585,24 +600,26 @@ TEST_F(AlternateProtocolServerPropertiesTest, EmptyVector) {
|
| // |alternative_service_map_|, emptying the AlternativeServiceInfoVector
|
| // corresponding to |host_port_pair|.
|
| AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_TRUE(alternative_service_vector.empty());
|
|
|
| // GetAlternativeServices() should remove this key from
|
| // |alternative_service_map_|, and SetAlternativeServices() should not crash.
|
| impl_.SetAlternativeServices(
|
| - host_port_pair,
|
| + scheme_origin,
|
| AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
|
|
|
| // There should still be no alternative service assigned to |host_port_pair|.
|
| - alternative_service_vector = impl_.GetAlternativeServices(host_port_pair);
|
| + alternative_service_vector = impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_TRUE(alternative_service_vector.empty());
|
| }
|
|
|
| // Regression test for https://crbug.com/516486 for the canonical host case.
|
| TEST_F(AlternateProtocolServerPropertiesTest, EmptyVectorForCanonical) {
|
| HostPortPair host_port_pair("foo.c.youtube.com", 443);
|
| + SchemeOriginPair scheme_origin("https", host_port_pair);
|
| HostPortPair canonical_host_port_pair("bar.c.youtube.com", 443);
|
| + SchemeOriginPair canonical_scheme_origin("https", canonical_host_port_pair);
|
| const AlternativeService alternative_service(NPN_HTTP_2, "", 443);
|
| base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1);
|
| const AlternativeServiceInfo alternative_service_info(alternative_service,
|
| @@ -610,7 +627,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, EmptyVectorForCanonical) {
|
| AlternativeServiceMap alternative_service_map(
|
| AlternativeServiceMap::NO_AUTO_EVICT);
|
| alternative_service_map.Put(
|
| - canonical_host_port_pair,
|
| + canonical_scheme_origin,
|
| AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
|
|
|
| // Prepare |alternative_service_map_| with a single key that has a single
|
| @@ -622,62 +639,63 @@ TEST_F(AlternateProtocolServerPropertiesTest, EmptyVectorForCanonical) {
|
| // corresponding to |canonical_host_port_pair|, even when looking up
|
| // alternative services for |host_port_pair|.
|
| AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_TRUE(alternative_service_vector.empty());
|
|
|
| // GetAlternativeServices() should remove this key from
|
| // |alternative_service_map_|, and SetAlternativeServices() should not crash.
|
| impl_.SetAlternativeServices(
|
| - canonical_host_port_pair,
|
| + canonical_scheme_origin,
|
| AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
|
|
|
| // There should still be no alternative service assigned to
|
| // |canonical_host_port_pair|.
|
| alternative_service_vector =
|
| - impl_.GetAlternativeServices(canonical_host_port_pair);
|
| + impl_.GetAlternativeServices(canonical_scheme_origin);
|
| ASSERT_TRUE(alternative_service_vector.empty());
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternativeServices) {
|
| HostPortPair test_host_port_pair1("foo1", 80);
|
| + SchemeOriginPair scheme_origin1("http", test_host_port_pair1);
|
| const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo1", 443);
|
| - SetAlternativeService(test_host_port_pair1, alternative_service1, 1.0);
|
| + SetAlternativeService(scheme_origin1, alternative_service1, 1.0);
|
| HostPortPair test_host_port_pair2("foo2", 80);
|
| + SchemeOriginPair scheme_origin2("http", test_host_port_pair2);
|
| const AlternativeService alternative_service2(NPN_HTTP_2, "foo2", 1234);
|
| - SetAlternativeService(test_host_port_pair2, alternative_service2, 1.0);
|
| + SetAlternativeService(scheme_origin2, alternative_service2, 1.0);
|
|
|
| const AlternativeServiceMap& map = impl_.alternative_service_map();
|
| AlternativeServiceMap::const_iterator it = map.begin();
|
| - EXPECT_TRUE(it->first.Equals(test_host_port_pair2));
|
| + EXPECT_TRUE(it->first.host_port_pair().Equals(test_host_port_pair2));
|
| ASSERT_EQ(1u, it->second.size());
|
| EXPECT_EQ(alternative_service2, it->second[0].alternative_service);
|
|
|
| const AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair1);
|
| + impl_.GetAlternativeServices(scheme_origin1);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service1, alternative_service_vector[0]);
|
|
|
| // GetAlternativeServices should reorder the AlternateProtocol map.
|
| it = map.begin();
|
| - EXPECT_TRUE(it->first.Equals(test_host_port_pair1));
|
| + EXPECT_TRUE(it->first.host_port_pair().Equals(test_host_port_pair1));
|
| ASSERT_EQ(1u, it->second.size());
|
| EXPECT_EQ(alternative_service1, it->second[0].alternative_service);
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) {
|
| - HostPortPair test_host_port_pair("foo", 80);
|
| + SchemeOriginPair scheme_origin("http", "foo", 80);
|
| const AlternativeService alternative_service1(NPN_HTTP_2, "foo", 443);
|
| - SetAlternativeService(test_host_port_pair, alternative_service1, 1.0);
|
| + SetAlternativeService(scheme_origin, alternative_service1, 1.0);
|
| AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service1, alternative_service_vector[0]);
|
| EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service1));
|
|
|
| // GetAlternativeServices should return the broken alternative service.
|
| impl_.MarkAlternativeServiceBroken(alternative_service1);
|
| - alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + alternative_service_vector = impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service1, alternative_service_vector[0]);
|
| EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1));
|
| @@ -690,10 +708,8 @@ TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) {
|
| const AlternativeService alternative_service2(NPN_HTTP_2, "foo", 1234);
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service2, 1.0, expiration));
|
| - impl_.SetAlternativeServices(test_host_port_pair,
|
| - alternative_service_info_vector);
|
| - alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + impl_.SetAlternativeServices(scheme_origin, alternative_service_info_vector);
|
| + alternative_service_vector = impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(2u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service1, alternative_service_vector[0]);
|
| EXPECT_EQ(alternative_service2, alternative_service_vector[1]);
|
| @@ -701,9 +717,8 @@ TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) {
|
| EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service_vector[1]));
|
|
|
| // SetAlternativeService should add a broken alternative service to the map.
|
| - SetAlternativeService(test_host_port_pair, alternative_service1, 1.0);
|
| - alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + SetAlternativeService(scheme_origin, alternative_service1, 1.0);
|
| + alternative_service_vector = impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service1, alternative_service_vector[0]);
|
| EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service_vector[0]));
|
| @@ -726,12 +741,11 @@ TEST_F(AlternateProtocolServerPropertiesTest, MaxAge) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service2, 1.0, now + one_day));
|
|
|
| - HostPortPair test_host_port_pair("foo", 80);
|
| - impl_.SetAlternativeServices(test_host_port_pair,
|
| - alternative_service_info_vector);
|
| + SchemeOriginPair scheme_origin("http", "foo", 80);
|
| + impl_.SetAlternativeServices(scheme_origin, alternative_service_info_vector);
|
|
|
| AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service2, alternative_service_vector[0]);
|
| }
|
| @@ -747,23 +761,41 @@ TEST_F(AlternateProtocolServerPropertiesTest, MaxAgeCanonical) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service1, 1.0, now - one_day));
|
|
|
| - // Second alterrnative service will expire one day from now, should be
|
| + // Second alternative service will expire one day from now, should be
|
| // returned by GetAlternativeSerices().
|
| const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234);
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service2, 1.0, now + one_day));
|
|
|
| - HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80);
|
| - impl_.SetAlternativeServices(canonical_host_port_pair,
|
| + SchemeOriginPair canonical_scheme_origin("https", "bar.c.youtube.com", 80);
|
| + impl_.SetAlternativeServices(canonical_scheme_origin,
|
| alternative_service_info_vector);
|
|
|
| - HostPortPair test_host_port_pair("foo.c.youtube.com", 80);
|
| + SchemeOriginPair scheme_origin("https", "foo.c.youtube.com", 80);
|
| AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service2, alternative_service_vector[0]);
|
| }
|
|
|
| +TEST_F(AlternateProtocolServerPropertiesTest,
|
| + SetAlternativeServicesWithScheme) {
|
| + AlternativeServiceInfoVector alternative_service_info_vector;
|
| + const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo", 443);
|
| + base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
|
| + alternative_service_info_vector.push_back(
|
| + AlternativeServiceInfo(alternative_service1, 1.0, expiration));
|
| + const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234);
|
| + alternative_service_info_vector.push_back(
|
| + AlternativeServiceInfo(alternative_service2, 1.0, expiration));
|
| + SchemeOriginPair http_origin("http", "foo", 80);
|
| + SchemeOriginPair https_origin("https", "foo", 80);
|
| + impl_.SetAlternativeServices(http_origin, alternative_service_info_vector);
|
| +
|
| + ASSERT_EQ(2u, impl_.GetAlternativeServices(http_origin).size());
|
| + ASSERT_EQ(0u, impl_.GetAlternativeServices(https_origin).size());
|
| +}
|
| +
|
| TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) {
|
| AlternativeServiceInfoVector alternative_service_info_vector;
|
| const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo", 443);
|
| @@ -774,17 +806,17 @@ TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service2, 1.0, expiration));
|
| HostPortPair test_host_port_pair("foo", 80);
|
| - impl_.SetAlternativeServices(test_host_port_pair,
|
| - alternative_service_info_vector);
|
| + SchemeOriginPair scheme_origin("http", test_host_port_pair);
|
| + impl_.SetAlternativeServices(scheme_origin, alternative_service_info_vector);
|
|
|
| const net::AlternativeServiceMap& map = impl_.alternative_service_map();
|
| net::AlternativeServiceMap::const_iterator it = map.begin();
|
| - EXPECT_TRUE(it->first.Equals(test_host_port_pair));
|
| + EXPECT_TRUE(it->first.host_port_pair().Equals(test_host_port_pair));
|
| ASSERT_EQ(2u, it->second.size());
|
| EXPECT_EQ(alternative_service1, it->second[0].alternative_service);
|
| EXPECT_EQ(alternative_service2, it->second[1].alternative_service);
|
|
|
| - impl_.ClearAlternativeServices(test_host_port_pair);
|
| + impl_.ClearAlternativeServices(scheme_origin);
|
| EXPECT_TRUE(map.empty());
|
| }
|
|
|
| @@ -793,14 +825,14 @@ TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) {
|
| // particular, an alternative service mapped to an origin shadows alternative
|
| // services of canonical hosts.
|
| TEST_F(AlternateProtocolServerPropertiesTest, BrokenShadowsCanonical) {
|
| - HostPortPair test_host_port_pair("foo.c.youtube.com", 80);
|
| - HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80);
|
| + SchemeOriginPair scheme_origin("https", "foo.c.youtube.com", 80);
|
| + SchemeOriginPair canonical_scheme_origin("https", "bar.c.youtube.com", 80);
|
| AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
|
| 1234);
|
| - SetAlternativeService(canonical_host_port_pair, canonical_alternative_service,
|
| + SetAlternativeService(canonical_scheme_origin, canonical_alternative_service,
|
| 1.0);
|
| AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(canonical_alternative_service, alternative_service_vector[0]);
|
|
|
| @@ -808,31 +840,30 @@ TEST_F(AlternateProtocolServerPropertiesTest, BrokenShadowsCanonical) {
|
| impl_.MarkAlternativeServiceBroken(broken_alternative_service);
|
| EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service));
|
|
|
| - SetAlternativeService(test_host_port_pair, broken_alternative_service, 1.0);
|
| - alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + SetAlternativeService(scheme_origin, broken_alternative_service, 1.0);
|
| + alternative_service_vector = impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(broken_alternative_service, alternative_service_vector[0]);
|
| EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) {
|
| - HostPortPair test_host_port_pair("foo", 80);
|
| + SchemeOriginPair scheme_origin("http", "foo", 80);
|
| const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
|
| - SetAlternativeService(test_host_port_pair, alternative_service, 1.0);
|
| + SetAlternativeService(scheme_origin, alternative_service, 1.0);
|
| impl_.MarkAlternativeServiceBroken(alternative_service);
|
| - ASSERT_TRUE(HasAlternativeService(test_host_port_pair));
|
| + ASSERT_TRUE(HasAlternativeService(scheme_origin));
|
| EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service));
|
| // ClearAlternativeServices should leave a broken alternative service marked
|
| // as such.
|
| - impl_.ClearAlternativeServices(test_host_port_pair);
|
| + impl_.ClearAlternativeServices(scheme_origin);
|
| EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, MarkRecentlyBroken) {
|
| - HostPortPair host_port_pair("foo", 80);
|
| + SchemeOriginPair scheme_origin("http", "foo", 80);
|
| const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
|
| - SetAlternativeService(host_port_pair, alternative_service, 1.0);
|
| + SetAlternativeService(scheme_origin, alternative_service, 1.0);
|
|
|
| EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service));
|
| EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service));
|
| @@ -848,10 +879,12 @@ TEST_F(AlternateProtocolServerPropertiesTest, MarkRecentlyBroken) {
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, Canonical) {
|
| HostPortPair test_host_port_pair("foo.c.youtube.com", 80);
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + SchemeOriginPair scheme_origin("https", test_host_port_pair);
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
|
|
| HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80);
|
| - EXPECT_FALSE(HasAlternativeService(canonical_host_port_pair));
|
| + SchemeOriginPair canonical_scheme_origin("https", canonical_host_port_pair);
|
| + EXPECT_FALSE(HasAlternativeService(canonical_scheme_origin));
|
|
|
| AlternativeServiceInfoVector alternative_service_info_vector;
|
| const AlternativeService canonical_alternative_service1(
|
| @@ -862,13 +895,13 @@ TEST_F(AlternateProtocolServerPropertiesTest, Canonical) {
|
| const AlternativeService canonical_alternative_service2(NPN_HTTP_2, "", 443);
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(canonical_alternative_service2, 1.0, expiration));
|
| - impl_.SetAlternativeServices(canonical_host_port_pair,
|
| + impl_.SetAlternativeServices(canonical_scheme_origin,
|
| alternative_service_info_vector);
|
|
|
| // Since |test_host_port_pair| does not have an alternative service itself,
|
| // GetAlternativeServices should return those of |canonical_host_port_pair|.
|
| AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(2u, alternative_service_vector.size());
|
| EXPECT_EQ(canonical_alternative_service1, alternative_service_vector[0]);
|
|
|
| @@ -888,96 +921,123 @@ TEST_F(AlternateProtocolServerPropertiesTest, Canonical) {
|
| impl_.GetCanonicalSuffix(canonical_host_port_pair.host()));
|
| }
|
|
|
| +TEST_F(AlternateProtocolServerPropertiesTest, NoCanonicalMappingForHttpOrigin) {
|
| + impl_.SetAlternativeServiceProbabilityThreshold(0.02);
|
| +
|
| + SchemeOriginPair scheme_origin("http", "foo.c.youtube.com", 80);
|
| + SchemeOriginPair canonical_scheme_origin("https", "bar.c.youtube.com", 80);
|
| + AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
|
| + 1234);
|
| + // Set alternative service for canonical_scheme_origin.
|
| + SetAlternativeService(canonical_scheme_origin, canonical_alternative_service,
|
| + 0.03);
|
| + EXPECT_TRUE(HasAlternativeService(canonical_scheme_origin));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| +}
|
| +
|
| +TEST_F(AlternateProtocolServerPropertiesTest, CanonicalMappingForHttpsOrigin) {
|
| + impl_.SetAlternativeServiceProbabilityThreshold(0.02);
|
| +
|
| + SchemeOriginPair scheme_origin("https", "foo.c.youtube.com", 80);
|
| + SchemeOriginPair canonical_scheme_origin("https", "bar.c.youtube.com", 80);
|
| + AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
|
| + 1234);
|
| + // Set alternative service for canonical_scheme_origin.
|
| + SetAlternativeService(canonical_scheme_origin, canonical_alternative_service,
|
| + 0.03);
|
| + EXPECT_TRUE(HasAlternativeService(canonical_scheme_origin));
|
| + EXPECT_TRUE(HasAlternativeService(scheme_origin));
|
| +}
|
| +
|
| TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBelowThreshold) {
|
| impl_.SetAlternativeServiceProbabilityThreshold(0.02);
|
|
|
| - HostPortPair test_host_port_pair("foo.c.youtube.com", 80);
|
| - HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80);
|
| + SchemeOriginPair scheme_origin("https", "foo.c.youtube.com", 80);
|
| + SchemeOriginPair canonical_scheme_origin("https", "bar.c.youtube.com", 80);
|
| AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
|
| 1234);
|
|
|
| - SetAlternativeService(canonical_host_port_pair, canonical_alternative_service,
|
| + SetAlternativeService(canonical_scheme_origin, canonical_alternative_service,
|
| 0.01);
|
| - EXPECT_FALSE(HasAlternativeService(canonical_host_port_pair));
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternativeService(canonical_scheme_origin));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, CanonicalAboveThreshold) {
|
| impl_.SetAlternativeServiceProbabilityThreshold(0.02);
|
|
|
| - HostPortPair test_host_port_pair("foo.c.youtube.com", 80);
|
| - HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80);
|
| + SchemeOriginPair scheme_origin("https", "foo.c.youtube.com", 80);
|
| + SchemeOriginPair canonical_scheme_origin("https", "bar.c.youtube.com", 80);
|
| AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
|
| 1234);
|
|
|
| - SetAlternativeService(canonical_host_port_pair, canonical_alternative_service,
|
| + SetAlternativeService(canonical_scheme_origin, canonical_alternative_service,
|
| 0.03);
|
| - EXPECT_TRUE(HasAlternativeService(canonical_host_port_pair));
|
| - EXPECT_TRUE(HasAlternativeService(test_host_port_pair));
|
| + EXPECT_TRUE(HasAlternativeService(canonical_scheme_origin));
|
| + EXPECT_TRUE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) {
|
| - HostPortPair test_host_port_pair("foo.c.youtube.com", 80);
|
| - HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80);
|
| + SchemeOriginPair scheme_origin("https", "foo.c.youtube.com", 80);
|
| + SchemeOriginPair canonical_scheme_origin("https", "bar.c.youtube.com", 80);
|
| AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
|
| 1234);
|
|
|
| - SetAlternativeService(canonical_host_port_pair, canonical_alternative_service,
|
| + SetAlternativeService(canonical_scheme_origin, canonical_alternative_service,
|
| 1.0);
|
| - impl_.ClearAlternativeServices(canonical_host_port_pair);
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + impl_.ClearAlternativeServices(canonical_scheme_origin);
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken) {
|
| - HostPortPair test_host_port_pair("foo.c.youtube.com", 80);
|
| - HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80);
|
| + SchemeOriginPair scheme_origin("https", "foo.c.youtube.com", 80);
|
| + SchemeOriginPair canonical_scheme_origin("https", "bar.c.youtube.com", 80);
|
| AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
|
| 1234);
|
|
|
| - SetAlternativeService(canonical_host_port_pair, canonical_alternative_service,
|
| + SetAlternativeService(canonical_scheme_origin, canonical_alternative_service,
|
| 1.0);
|
| impl_.MarkAlternativeServiceBroken(canonical_alternative_service);
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| // Adding an alternative service for a new host overrides canonical host.
|
| TEST_F(AlternateProtocolServerPropertiesTest, CanonicalOverride) {
|
| - HostPortPair test_host_port_pair("foo.c.youtube.com", 80);
|
| - HostPortPair bar_host_port_pair("bar.c.youtube.com", 80);
|
| + SchemeOriginPair scheme_origin("https", "foo.c.youtube.com", 80);
|
| + SchemeOriginPair bar_scheme_origin("https", "bar.c.youtube.com", 80);
|
| AlternativeService bar_alternative_service(QUIC, "bar.c.youtube.com", 1234);
|
| - SetAlternativeService(bar_host_port_pair, bar_alternative_service, 1.0);
|
| + SetAlternativeService(bar_scheme_origin, bar_alternative_service, 1.0);
|
| AlternativeServiceVector alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(bar_alternative_service, alternative_service_vector[0]);
|
|
|
| - HostPortPair qux_host_port_pair("qux.c.youtube.com", 80);
|
| + SchemeOriginPair qux_scheme_origin_pair("https", "qux.c.youtube.com", 80);
|
| AlternativeService qux_alternative_service(QUIC, "qux.c.youtube.com", 443);
|
| - SetAlternativeService(qux_host_port_pair, qux_alternative_service, 1.0);
|
| - alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + SetAlternativeService(qux_scheme_origin_pair, qux_alternative_service, 1.0);
|
| + alternative_service_vector = impl_.GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(qux_alternative_service, alternative_service_vector[0]);
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, ClearWithCanonical) {
|
| - HostPortPair test_host_port_pair("foo.c.youtube.com", 80);
|
| - HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80);
|
| + SchemeOriginPair scheme_origin("https", "foo.c.youtube.com", 80);
|
| + SchemeOriginPair canonical_scheme_origin("https", "bar.c.youtube.com", 80);
|
| AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
|
| 1234);
|
|
|
| - SetAlternativeService(canonical_host_port_pair, canonical_alternative_service,
|
| + SetAlternativeService(canonical_scheme_origin, canonical_alternative_service,
|
| 1.0);
|
| impl_.Clear();
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest,
|
| ExpireBrokenAlternateProtocolMappings) {
|
| - HostPortPair host_port_pair("foo", 443);
|
| + SchemeOriginPair scheme_origin("https", "foo", 443);
|
| AlternativeService alternative_service(QUIC, "foo", 443);
|
| - SetAlternativeService(host_port_pair, alternative_service, 1.0);
|
| - EXPECT_TRUE(HasAlternativeService(host_port_pair));
|
| + SetAlternativeService(scheme_origin, alternative_service, 1.0);
|
| + EXPECT_TRUE(HasAlternativeService(scheme_origin));
|
| EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service));
|
| EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service));
|
|
|
| @@ -995,20 +1055,20 @@ TEST_F(AlternateProtocolServerPropertiesTest,
|
|
|
| // Regression test for https://crbug.com/505413.
|
| TEST_F(AlternateProtocolServerPropertiesTest, RemoveExpiredBrokenAltSvc) {
|
| - HostPortPair foo_host_port_pair("foo", 443);
|
| + SchemeOriginPair foo_scheme_origin("https", "foo", 443);
|
| AlternativeService bar_alternative_service(QUIC, "bar", 443);
|
| - SetAlternativeService(foo_host_port_pair, bar_alternative_service, 1.0);
|
| - EXPECT_TRUE(HasAlternativeService(foo_host_port_pair));
|
| + SetAlternativeService(foo_scheme_origin, bar_alternative_service, 1.0);
|
| + EXPECT_TRUE(HasAlternativeService(foo_scheme_origin));
|
|
|
| - HostPortPair bar_host_port_pair1("bar", 80);
|
| + SchemeOriginPair bar_scheme_origin1("http", "bar", 80);
|
| AlternativeService nohost_alternative_service(QUIC, "", 443);
|
| - SetAlternativeService(bar_host_port_pair1, nohost_alternative_service, 1.0);
|
| - EXPECT_TRUE(HasAlternativeService(bar_host_port_pair1));
|
| + SetAlternativeService(bar_scheme_origin1, nohost_alternative_service, 1.0);
|
| + EXPECT_TRUE(HasAlternativeService(bar_scheme_origin1));
|
|
|
| - HostPortPair bar_host_port_pair2("bar", 443);
|
| + SchemeOriginPair bar_scheme_origin2("https", "bar", 443);
|
| AlternativeService baz_alternative_service(QUIC, "baz", 1234);
|
| - SetAlternativeService(bar_host_port_pair2, baz_alternative_service, 1.0);
|
| - EXPECT_TRUE(HasAlternativeService(bar_host_port_pair2));
|
| + SetAlternativeService(bar_scheme_origin2, baz_alternative_service, 1.0);
|
| + EXPECT_TRUE(HasAlternativeService(bar_scheme_origin2));
|
|
|
| // Mark "bar:443" as broken.
|
| base::TimeTicks past =
|
| @@ -1020,11 +1080,11 @@ TEST_F(AlternateProtocolServerPropertiesTest, RemoveExpiredBrokenAltSvc) {
|
| HttpServerPropertiesImplPeer::ExpireBrokenAlternateProtocolMappings(impl_);
|
|
|
| // "foo:443" should have no alternative service now.
|
| - EXPECT_FALSE(HasAlternativeService(foo_host_port_pair));
|
| + EXPECT_FALSE(HasAlternativeService(foo_scheme_origin));
|
| // "bar:80" should have no alternative service now.
|
| - EXPECT_FALSE(HasAlternativeService(bar_host_port_pair1));
|
| + EXPECT_FALSE(HasAlternativeService(bar_scheme_origin1));
|
| // The alternative service of "bar:443" should be unaffected.
|
| - EXPECT_TRUE(HasAlternativeService(bar_host_port_pair2));
|
| + EXPECT_TRUE(HasAlternativeService(bar_scheme_origin2));
|
|
|
| EXPECT_TRUE(
|
| impl_.WasAlternativeServiceRecentlyBroken(bar_alternative_service));
|
|
|