| 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 f4edadb6a79e235ce81f88fcd093d4fccc86a3a1..95c83d1000d1eacdd5f5490b11ba3e6394b49003 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 url::SchemeHostPort& origin) {
|
| const AlternativeServiceVector alternative_service_vector =
|
| impl_.GetAlternativeServices(origin);
|
| return !alternative_service_vector.empty();
|
| }
|
|
|
| - bool SetAlternativeService(const HostPortPair& origin,
|
| + bool SetAlternativeService(const url::SchemeHostPort& origin,
|
| const AlternativeService& alternative_service) {
|
| const base::Time expiration =
|
| base::Time::Now() + base::TimeDelta::FromDays(1);
|
| @@ -104,25 +104,29 @@ typedef HttpServerPropertiesImplTest SpdyServerPropertiesTest;
|
|
|
| TEST_F(SpdyServerPropertiesTest, Initialize) {
|
| HostPortPair spdy_server_google("www.google.com", 443);
|
| + url::SchemeHostPort google_server("https", "www.google.com", 443);
|
| std::string spdy_server_g = spdy_server_google.ToString();
|
|
|
| HostPortPair spdy_server_photos("photos.google.com", 443);
|
| + url::SchemeHostPort photos_server("https", "photos.google.com", 443);
|
| std::string spdy_server_p = spdy_server_photos.ToString();
|
|
|
| HostPortPair spdy_server_docs("docs.google.com", 443);
|
| + url::SchemeHostPort docs_server("https", "docs.google.com", 443);
|
| std::string spdy_server_d = spdy_server_docs.ToString();
|
|
|
| HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + url::SchemeHostPort mail_server("https", "mail.google.com", 443);
|
| 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.
|
| @@ -130,8 +134,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;
|
| @@ -167,10 +171,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.
|
| @@ -194,47 +198,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);
|
| + url::SchemeHostPort 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);
|
| + url::SchemeHostPort google_server("https", "www.google.com", 443);
|
| 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);
|
| + url::SchemeHostPort 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);
|
| + url::SchemeHostPort docs_server("https", "docs.google.com", 443);
|
| 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);
|
| + url::SchemeHostPort quic_server_youtube("https", "www.youtube.com", 443);
|
| const AlternativeService alternative_service1(QUIC, "www.youtube.com", 443);
|
| SetAlternativeService(quic_server_youtube, alternative_service1);
|
| 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);
|
| + url::SchemeHostPort quic_server_example("https", "www.example.com", 443);
|
| const AlternativeService alternative_service2(NPN_HTTP_2, "", 443);
|
| SetAlternativeService(quic_server_example, alternative_service2);
|
| SetAlternativeService(quic_server_example, alternative_service1);
|
| 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));
|
| }
|
| @@ -242,16 +249,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);
|
| + url::SchemeHostPort google_server("https", "www.google.com", 443);
|
| impl_.SetSupportsSpdy(spdy_server_google, true);
|
| HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + url::SchemeHostPort mail_server("https", "mail.google.com", 443);
|
| 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) {
|
| @@ -263,6 +272,7 @@ TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) {
|
|
|
| // Check empty server is not added.
|
| HostPortPair spdy_server_empty(std::string(), 443);
|
| + url::SchemeHostPort empty_server("https", std::string(), 443);
|
| impl_.SetSupportsSpdy(spdy_server_empty, true);
|
| impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
|
| EXPECT_EQ(0U, spdy_server_list.GetSize());
|
| @@ -270,8 +280,10 @@ TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) {
|
| std::string string_value_g;
|
| std::string string_value_m;
|
| HostPortPair spdy_server_google("www.google.com", 443);
|
| + url::SchemeHostPort google_server("https", "www.google.com", 443);
|
| std::string spdy_server_g = spdy_server_google.ToString();
|
| HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + url::SchemeHostPort mail_server("https", "mail.google.com", 443);
|
| std::string spdy_server_m = spdy_server_mail.ToString();
|
|
|
| // Add www.google.com:443 as not supporting SPDY.
|
| @@ -317,8 +329,10 @@ TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) {
|
| std::string string_value_g;
|
| std::string string_value_m;
|
| HostPortPair spdy_server_google("www.google.com", 443);
|
| + url::SchemeHostPort google_server("https", "www.google.com", 443);
|
| std::string spdy_server_g = spdy_server_google.ToString();
|
| HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + url::SchemeHostPort mail_server("https", "mail.google.com", 443);
|
| std::string spdy_server_m = spdy_server_mail.ToString();
|
|
|
| // Add www.google.com:443 as supporting SPDY.
|
| @@ -340,7 +354,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));
|
| @@ -352,18 +366,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));
|
| + url::SchemeHostPort 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);
|
| + SetAlternativeService(scheme_origin, alternative_service);
|
| 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) {
|
| @@ -386,12 +400,11 @@ TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service4, expiration));
|
|
|
| - HostPortPair test_host_port_pair("foo", 443);
|
| - impl_.SetAlternativeServices(test_host_port_pair,
|
| - alternative_service_info_vector);
|
| + url::SchemeHostPort 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]);
|
| @@ -404,11 +417,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);
|
| + url::SchemeHostPort scheme_origin1("http", "foo1", 80);
|
| 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,
|
| + impl_.SetAlternativeService(scheme_origin1, alternative_service1,
|
| expiration1);
|
|
|
| // |test_host_port_pair2| has an alternative service, which will be
|
| @@ -421,9 +435,9 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service2, expiration2));
|
| HostPortPair test_host_port_pair2("foo2", 80);
|
| + url::SchemeHostPort scheme_origin2("http", "foo2", 80);
|
| // 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().
|
| @@ -435,10 +449,11 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| 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);
|
| + url::SchemeHostPort scheme_origin3("http", "foo3", 80);
|
| const AlternativeService alternative_service4(NPN_HTTP_2, "bar4", 1234);
|
| base::Time expiration4 = now + base::TimeDelta::FromDays(4);
|
| const AlternativeServiceInfo alternative_service_info2(alternative_service4,
|
| @@ -446,7 +461,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,
|
| @@ -458,17 +473,20 @@ 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(HostPortPair::FromSchemeHostPort(map_it->first)
|
| + .Equals(test_host_port_pair2));
|
| ASSERT_EQ(1u, map_it->second.size());
|
| EXPECT_EQ(alternative_service3, map_it->second[0].alternative_service);
|
| EXPECT_EQ(expiration3, map_it->second[0].expiration);
|
| ++map_it;
|
| - EXPECT_TRUE(map_it->first.Equals(test_host_port_pair1));
|
| + EXPECT_TRUE(HostPortPair::FromSchemeHostPort(map_it->first)
|
| + .Equals(test_host_port_pair1));
|
| ASSERT_EQ(1u, map_it->second.size());
|
| EXPECT_EQ(alternative_service1, map_it->second[0].alternative_service);
|
| EXPECT_EQ(expiration1, map_it->second[0].expiration);
|
| ++map_it;
|
| - EXPECT_TRUE(map_it->first.Equals(test_host_port_pair3));
|
| + EXPECT_TRUE(HostPortPair::FromSchemeHostPort(map_it->first)
|
| + .Equals(test_host_port_pair3));
|
| ASSERT_EQ(1u, map_it->second.size());
|
| EXPECT_EQ(alternative_service4, map_it->second[0].alternative_service);
|
| EXPECT_EQ(expiration4, map_it->second[0].expiration);
|
| @@ -478,13 +496,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);
|
| + url::SchemeHostPort 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);
|
| impl_.MarkAlternativeServiceBroken(alternative_service_with_foo_hostname);
|
|
|
| AlternativeServiceMap alternative_service_map(
|
| @@ -494,7 +511,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]);
|
| @@ -505,6 +522,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, InitializeWithEmptyHostname) {
|
| // with empty value.
|
| TEST_F(AlternateProtocolServerPropertiesTest, EmptyVector) {
|
| HostPortPair host_port_pair("foo", 443);
|
| + url::SchemeHostPort scheme_origin("https", "foo", 443);
|
| 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,
|
| @@ -512,7 +530,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
|
| @@ -523,24 +541,27 @@ 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);
|
| + url::SchemeHostPort scheme_origin("https", "foo.c.youtube.com", 443);
|
| HostPortPair canonical_host_port_pair("bar.c.youtube.com", 443);
|
| + url::SchemeHostPort canonical_scheme_origin("https", "bar.c.youtube.com",
|
| + 443);
|
| 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,
|
| @@ -548,7 +569,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
|
| @@ -560,62 +581,64 @@ 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);
|
| + url::SchemeHostPort scheme_origin1("http", "foo1", 80);
|
| const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo1", 443);
|
| - SetAlternativeService(test_host_port_pair1, alternative_service1);
|
| + SetAlternativeService(scheme_origin1, alternative_service1);
|
| HostPortPair test_host_port_pair2("foo2", 80);
|
| + url::SchemeHostPort scheme_origin2("http", "foo2", 80);
|
| const AlternativeService alternative_service2(NPN_HTTP_2, "foo2", 1234);
|
| - SetAlternativeService(test_host_port_pair2, alternative_service2);
|
| -
|
| + SetAlternativeService(scheme_origin2, alternative_service2);
|
| const AlternativeServiceMap& map = impl_.alternative_service_map();
|
| AlternativeServiceMap::const_iterator it = map.begin();
|
| - EXPECT_TRUE(it->first.Equals(test_host_port_pair2));
|
| + EXPECT_TRUE(
|
| + HostPortPair::FromSchemeHostPort(it->first).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(
|
| + HostPortPair::FromSchemeHostPort(it->first).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);
|
| + url::SchemeHostPort scheme_origin("http", "foo", 80);
|
| const AlternativeService alternative_service1(NPN_HTTP_2, "foo", 443);
|
| - SetAlternativeService(test_host_port_pair, alternative_service1);
|
| + SetAlternativeService(scheme_origin, alternative_service1);
|
| 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));
|
| @@ -628,10 +651,8 @@ TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) {
|
| const AlternativeService alternative_service2(NPN_HTTP_2, "foo", 1234);
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service2, 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]);
|
| @@ -639,9 +660,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);
|
| - alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + SetAlternativeService(scheme_origin, alternative_service1);
|
| + 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]));
|
| @@ -664,12 +684,11 @@ TEST_F(AlternateProtocolServerPropertiesTest, MaxAge) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service2, now + one_day));
|
|
|
| - HostPortPair test_host_port_pair("foo", 80);
|
| - impl_.SetAlternativeServices(test_host_port_pair,
|
| - alternative_service_info_vector);
|
| + url::SchemeHostPort 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]);
|
| }
|
| @@ -685,23 +704,41 @@ TEST_F(AlternateProtocolServerPropertiesTest, MaxAgeCanonical) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service1, 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, now + one_day));
|
|
|
| - HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80);
|
| - impl_.SetAlternativeServices(canonical_host_port_pair,
|
| + url::SchemeHostPort 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);
|
| + url::SchemeHostPort 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, expiration));
|
| + const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234);
|
| + alternative_service_info_vector.push_back(
|
| + AlternativeServiceInfo(alternative_service2, expiration));
|
| + url::SchemeHostPort http_origin("http", "foo", 80);
|
| + url::SchemeHostPort 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);
|
| @@ -712,17 +749,18 @@ TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service2, expiration));
|
| HostPortPair test_host_port_pair("foo", 80);
|
| - impl_.SetAlternativeServices(test_host_port_pair,
|
| - alternative_service_info_vector);
|
| + url::SchemeHostPort scheme_origin("http", "foo", 80);
|
| + 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(
|
| + HostPortPair::FromSchemeHostPort(it->first).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());
|
| }
|
|
|
| @@ -731,14 +769,13 @@ 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);
|
| + url::SchemeHostPort scheme_origin("https", "foo.c.youtube.com", 80);
|
| + url::SchemeHostPort 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);
|
| 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]);
|
|
|
| @@ -746,31 +783,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);
|
| - alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + SetAlternativeService(scheme_origin, broken_alternative_service);
|
| + 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);
|
| + url::SchemeHostPort scheme_origin("http", "foo", 80);
|
| const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
|
| - SetAlternativeService(test_host_port_pair, alternative_service);
|
| + SetAlternativeService(scheme_origin, alternative_service);
|
| 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);
|
| + url::SchemeHostPort scheme_origin("http", "foo", 80);
|
| const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
|
| - SetAlternativeService(host_port_pair, alternative_service);
|
| + SetAlternativeService(scheme_origin, alternative_service);
|
|
|
| EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service));
|
| EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service));
|
| @@ -786,10 +822,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));
|
| + url::SchemeHostPort scheme_origin("https", "foo.c.youtube.com", 80);
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
|
|
| HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80);
|
| - EXPECT_FALSE(HasAlternativeService(canonical_host_port_pair));
|
| + url::SchemeHostPort canonical_scheme_origin("https", "bar.c.youtube.com", 80);
|
| + EXPECT_FALSE(HasAlternativeService(canonical_scheme_origin));
|
|
|
| AlternativeServiceInfoVector alternative_service_info_vector;
|
| const AlternativeService canonical_alternative_service1(
|
| @@ -800,13 +838,13 @@ TEST_F(AlternateProtocolServerPropertiesTest, Canonical) {
|
| const AlternativeService canonical_alternative_service2(NPN_HTTP_2, "", 443);
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(canonical_alternative_service2, 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]);
|
|
|
| @@ -826,68 +864,86 @@ TEST_F(AlternateProtocolServerPropertiesTest, Canonical) {
|
| impl_.GetCanonicalSuffix(canonical_host_port_pair.host()));
|
| }
|
|
|
| +TEST_F(AlternateProtocolServerPropertiesTest, NoCanonicalMappingForHttpOrigin) {
|
| + url::SchemeHostPort scheme_origin("http", "foo.c.youtube.com", 80);
|
| + url::SchemeHostPort 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);
|
| + EXPECT_TRUE(HasAlternativeService(canonical_scheme_origin));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| +}
|
| +
|
| +TEST_F(AlternateProtocolServerPropertiesTest, CanonicalMappingForHttpsOrigin) {
|
| + url::SchemeHostPort scheme_origin("https", "foo.c.youtube.com", 80);
|
| + url::SchemeHostPort 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);
|
| + 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);
|
| + url::SchemeHostPort scheme_origin("https", "foo.c.youtube.com", 80);
|
| + url::SchemeHostPort 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);
|
| - impl_.ClearAlternativeServices(canonical_host_port_pair);
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + SetAlternativeService(canonical_scheme_origin, canonical_alternative_service);
|
| + 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);
|
| + url::SchemeHostPort scheme_origin("https", "foo.c.youtube.com", 80);
|
| + url::SchemeHostPort 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);
|
| 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);
|
| + url::SchemeHostPort scheme_origin("https", "foo.c.youtube.com", 80);
|
| + url::SchemeHostPort 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);
|
| + SetAlternativeService(bar_scheme_origin, bar_alternative_service);
|
| 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);
|
| + url::SchemeHostPort 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);
|
| - alternative_service_vector =
|
| - impl_.GetAlternativeServices(test_host_port_pair);
|
| + SetAlternativeService(qux_scheme_origin_pair, qux_alternative_service);
|
| + 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);
|
| + url::SchemeHostPort scheme_origin("https", "foo.c.youtube.com", 80);
|
| + url::SchemeHostPort 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);
|
| impl_.Clear();
|
| - EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest,
|
| ExpireBrokenAlternateProtocolMappings) {
|
| - HostPortPair host_port_pair("foo", 443);
|
| + url::SchemeHostPort scheme_origin("https", "foo", 443);
|
| AlternativeService alternative_service(QUIC, "foo", 443);
|
| - SetAlternativeService(host_port_pair, alternative_service);
|
| - EXPECT_TRUE(HasAlternativeService(host_port_pair));
|
| + SetAlternativeService(scheme_origin, alternative_service);
|
| + EXPECT_TRUE(HasAlternativeService(scheme_origin));
|
| EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service));
|
| EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service));
|
|
|
| @@ -905,20 +961,20 @@ TEST_F(AlternateProtocolServerPropertiesTest,
|
|
|
| // Regression test for https://crbug.com/505413.
|
| TEST_F(AlternateProtocolServerPropertiesTest, RemoveExpiredBrokenAltSvc) {
|
| - HostPortPair foo_host_port_pair("foo", 443);
|
| + url::SchemeHostPort foo_scheme_origin("https", "foo", 443);
|
| AlternativeService bar_alternative_service(QUIC, "bar", 443);
|
| - SetAlternativeService(foo_host_port_pair, bar_alternative_service);
|
| - EXPECT_TRUE(HasAlternativeService(foo_host_port_pair));
|
| + SetAlternativeService(foo_scheme_origin, bar_alternative_service);
|
| + EXPECT_TRUE(HasAlternativeService(foo_scheme_origin));
|
|
|
| - HostPortPair bar_host_port_pair1("bar", 80);
|
| + url::SchemeHostPort bar_scheme_origin1("http", "bar", 80);
|
| AlternativeService nohost_alternative_service(QUIC, "", 443);
|
| - SetAlternativeService(bar_host_port_pair1, nohost_alternative_service);
|
| - EXPECT_TRUE(HasAlternativeService(bar_host_port_pair1));
|
| + SetAlternativeService(bar_scheme_origin1, nohost_alternative_service);
|
| + EXPECT_TRUE(HasAlternativeService(bar_scheme_origin1));
|
|
|
| - HostPortPair bar_host_port_pair2("bar", 443);
|
| + url::SchemeHostPort bar_scheme_origin2("https", "bar", 443);
|
| AlternativeService baz_alternative_service(QUIC, "baz", 1234);
|
| - SetAlternativeService(bar_host_port_pair2, baz_alternative_service);
|
| - EXPECT_TRUE(HasAlternativeService(bar_host_port_pair2));
|
| + SetAlternativeService(bar_scheme_origin2, baz_alternative_service);
|
| + EXPECT_TRUE(HasAlternativeService(bar_scheme_origin2));
|
|
|
| // Mark "bar:443" as broken.
|
| base::TimeTicks past =
|
| @@ -930,11 +986,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));
|
|
|