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

Unified Diff: net/http/http_network_transaction_unittest.cc

Issue 1824903002: Change the AlternativeServiceMap with SchemeOriginPair key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unittests Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/http/http_network_transaction_unittest.cc
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index bc7f7b37dfbf3d0f33dac274a581e2aad2f2e157..eb54f19a20801c47e535d7d14a5861006a643dc5 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -8809,8 +8809,8 @@ scoped_ptr<HttpNetworkSession> SetupSessionForGroupNameTests(
AlternateProtocolFromNextProto(next_proto), "", 443);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
http_server_properties->SetAlternativeService(
- HostPortPair("host.with.alternate", 80), alternative_service, 1.0,
- expiration);
+ SchemeOriginPair("http", "host.with.alternate", 80), alternative_service,
+ 1.0, expiration);
return session;
}
@@ -9697,11 +9697,11 @@ TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) {
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- HostPortPair http_host_port_pair("www.example.org", 80);
+ SchemeOriginPair http_origin("http", "www.example.org", 80);
HttpServerProperties& http_server_properties =
*session->http_server_properties();
AlternativeServiceVector alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
EXPECT_TRUE(alternative_service_vector.empty());
EXPECT_EQ(OK, callback.WaitForResult());
@@ -9718,7 +9718,7 @@ TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) {
EXPECT_EQ("hello world", response_data);
alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
ASSERT_EQ(1u, alternative_service_vector.size());
EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
alternative_service_vector[0].protocol);
@@ -9734,13 +9734,13 @@ TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) {
scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
HttpServerProperties& http_server_properties =
*session->http_server_properties();
- HostPortPair http_host_port_pair("www.example.org", 80);
+ SchemeOriginPair http_origin("http", "www.example.org", 80);
AlternativeService alternative_service(QUIC, "", 80);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- http_server_properties.SetAlternativeService(
- http_host_port_pair, alternative_service, 1.0, expiration);
+ http_server_properties.SetAlternativeService(http_origin, alternative_service,
+ 1.0, expiration);
AlternativeServiceVector alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
EXPECT_EQ(1u, alternative_service_vector.size());
// Send a clear header.
@@ -9779,7 +9779,7 @@ TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) {
EXPECT_EQ("hello world", response_data);
alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
EXPECT_TRUE(alternative_service_vector.empty());
}
@@ -9817,11 +9817,11 @@ TEST_P(HttpNetworkTransactionTest, DoNotHonorAlternativeServiceHeader) {
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- HostPortPair http_host_port_pair("www.example.org", 80);
+ SchemeOriginPair http_origin("http", "www.example.org", 80);
HttpServerProperties& http_server_properties =
*session->http_server_properties();
AlternativeServiceVector alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
EXPECT_TRUE(alternative_service_vector.empty());
EXPECT_EQ(OK, callback.WaitForResult());
@@ -9838,7 +9838,7 @@ TEST_P(HttpNetworkTransactionTest, DoNotHonorAlternativeServiceHeader) {
EXPECT_EQ("hello world", response_data);
alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
EXPECT_TRUE(alternative_service_vector.empty());
}
@@ -9875,11 +9875,11 @@ TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) {
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- HostPortPair http_host_port_pair("www.example.org", 80);
+ SchemeOriginPair http_origin("http", "www.example.org", 80);
HttpServerProperties& http_server_properties =
*session->http_server_properties();
AlternativeServiceVector alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
EXPECT_TRUE(alternative_service_vector.empty());
EXPECT_EQ(OK, callback.WaitForResult());
@@ -9896,7 +9896,7 @@ TEST_P(HttpNetworkTransactionTest, HonorMultipleAlternativeServiceHeader) {
EXPECT_EQ("hello world", response_data);
alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
ASSERT_EQ(2u, alternative_service_vector.size());
EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
alternative_service_vector[0].protocol);
@@ -9942,11 +9942,11 @@ TEST_P(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) {
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- HostPortPair http_host_port_pair("www.example.org", 80);
+ SchemeOriginPair http_origin("http", "www.example.org", 80);
HttpServerProperties& http_server_properties =
*session->http_server_properties();
AlternativeServiceVector alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
EXPECT_TRUE(alternative_service_vector.empty());
EXPECT_EQ(OK, callback.WaitForResult());
@@ -9963,7 +9963,7 @@ TEST_P(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) {
EXPECT_EQ("hello world", response_data);
alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
ASSERT_EQ(1u, alternative_service_vector.size());
EXPECT_EQ(443, alternative_service_vector[0].port);
EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
@@ -9994,16 +9994,16 @@ TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) {
scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
- HostPortPair http_host_port_pair("www.example.org", 80);
+ SchemeOriginPair http_origin("http", "www.example.org", 80);
HttpServerProperties& http_server_properties =
*session->http_server_properties();
AlternativeService alternative_service(QUIC, "", 80);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- http_server_properties.SetAlternativeService(
- http_host_port_pair, alternative_service, 1.0, expiration);
+ http_server_properties.SetAlternativeService(http_origin, alternative_service,
+ 1.0, expiration);
AlternativeServiceVector alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
ASSERT_EQ(1u, alternative_service_vector.size());
EXPECT_EQ(QUIC, alternative_service_vector[0].protocol);
@@ -10027,7 +10027,7 @@ TEST_P(HttpNetworkTransactionTest, EmptyAlternateProtocolHeader) {
EXPECT_EQ("hello world", response_data);
alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
EXPECT_TRUE(alternative_service_vector.empty());
}
@@ -10068,11 +10068,11 @@ TEST_P(HttpNetworkTransactionTest, AltSvcOverwritesAlternateProtocol) {
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- HostPortPair http_host_port_pair("www.example.org", 80);
+ SchemeOriginPair http_origin("http", "www.example.org", 80);
HttpServerProperties& http_server_properties =
*session->http_server_properties();
AlternativeServiceVector alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
EXPECT_TRUE(alternative_service_vector.empty());
EXPECT_EQ(OK, callback.WaitForResult());
@@ -10089,7 +10089,7 @@ TEST_P(HttpNetworkTransactionTest, AltSvcOverwritesAlternateProtocol) {
EXPECT_EQ("hello world", response_data);
alternative_service_vector =
- http_server_properties.GetAlternativeServices(http_host_port_pair);
+ http_server_properties.GetAlternativeServices(http_origin);
ASSERT_EQ(1u, alternative_service_vector.size());
EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
alternative_service_vector[0].protocol);
@@ -10130,7 +10130,8 @@ TEST_P(HttpNetworkTransactionTest, DisableAlternativeServiceToDifferentHost) {
80);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
http_server_properties->SetAlternativeService(
- HostPortPair::FromURL(request.url), alternative_service, 1.0, expiration);
+ SchemeOriginPair::FromURL(request.url), alternative_service, 1.0,
+ expiration);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
@@ -10183,8 +10184,8 @@ TEST_P(HttpNetworkTransactionTest, IdentifyQuicBroken) {
session->http_server_properties();
AlternativeService alternative_service(QUIC, alternative);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- http_server_properties->SetAlternativeService(origin, alternative_service,
- 1.0, expiration);
+ http_server_properties->SetAlternativeService(
+ SchemeOriginPair("https", origin), alternative_service, 1.0, expiration);
// Mark the QUIC alternative service as broken.
http_server_properties->MarkAlternativeServiceBroken(alternative_service);
@@ -10204,7 +10205,8 @@ TEST_P(HttpNetworkTransactionTest, IdentifyQuicBroken) {
}
TEST_P(HttpNetworkTransactionTest, IdentifyQuicNotBroken) {
- HostPortPair origin("origin.example.org", 443);
+ // HostPortPair origin("origin.example.org", 443);
+ SchemeOriginPair scheme_origin("https", "origin.example.org", 443);
HostPortPair alternative1("alternative1.example.org", 443);
HostPortPair alternative2("alternative2.example.org", 443);
std::string origin_url = "https://origin.example.org:443";
@@ -10257,13 +10259,13 @@ TEST_P(HttpNetworkTransactionTest, IdentifyQuicNotBroken) {
alternative_service_info_vector.push_back(alternative_service_info2);
http_server_properties->SetAlternativeServices(
- origin, alternative_service_info_vector);
+ scheme_origin, alternative_service_info_vector);
// Mark one of the QUIC alternative service as broken.
http_server_properties->MarkAlternativeServiceBroken(alternative_service1);
const AlternativeServiceVector alternative_service_vector =
- http_server_properties->GetAlternativeServices(origin);
+ http_server_properties->GetAlternativeServices(scheme_origin);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
@@ -10308,7 +10310,8 @@ TEST_P(HttpNetworkTransactionTest,
base::WeakPtr<HttpServerProperties> http_server_properties =
session->http_server_properties();
- const HostPortPair host_port_pair = HostPortPair::FromURL(request.url);
+ SchemeOriginPair scheme_origin = SchemeOriginPair::FromURL(request.url);
+
// Port must be < 1024, or the header will be ignored (since initial port was
// port 80 (another restricted port).
const AlternativeService alternative_service(
@@ -10316,7 +10319,7 @@ TEST_P(HttpNetworkTransactionTest,
666); // Port is ignored by MockConnect anyway.
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
http_server_properties->SetAlternativeService(
- host_port_pair, alternative_service, 1.0, expiration);
+ scheme_origin, alternative_service, 1.0, expiration);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
@@ -10336,7 +10339,7 @@ TEST_P(HttpNetworkTransactionTest,
EXPECT_EQ("hello world", response_data);
const AlternativeServiceVector alternative_service_vector =
- http_server_properties->GetAlternativeServices(host_port_pair);
+ http_server_properties->GetAlternativeServices(scheme_origin);
ASSERT_EQ(1u, alternative_service_vector.size());
EXPECT_EQ(alternative_service, alternative_service_vector[0]);
EXPECT_TRUE(http_server_properties->IsAlternativeServiceBroken(
@@ -10381,8 +10384,8 @@ TEST_P(HttpNetworkTransactionTest,
kUnrestrictedAlternatePort);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
http_server_properties->SetAlternativeService(
- HostPortPair::FromURL(restricted_port_request.url), alternative_service,
- 1.0, expiration);
+ SchemeOriginPair::FromURL(restricted_port_request.url),
+ alternative_service, 1.0, expiration);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
@@ -10434,8 +10437,8 @@ TEST_P(HttpNetworkTransactionTest,
kUnrestrictedAlternatePort);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
http_server_properties->SetAlternativeService(
- HostPortPair::FromURL(restricted_port_request.url), alternative_service,
- 1.0, expiration);
+ SchemeOriginPair::FromURL(restricted_port_request.url),
+ alternative_service, 1.0, expiration);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
@@ -10486,8 +10489,8 @@ TEST_P(HttpNetworkTransactionTest,
kRestrictedAlternatePort);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
http_server_properties->SetAlternativeService(
- HostPortPair::FromURL(restricted_port_request.url), alternative_service,
- 1.0, expiration);
+ SchemeOriginPair::FromURL(restricted_port_request.url),
+ alternative_service, 1.0, expiration);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
@@ -10539,8 +10542,8 @@ TEST_P(HttpNetworkTransactionTest,
kRestrictedAlternatePort);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
http_server_properties->SetAlternativeService(
- HostPortPair::FromURL(unrestricted_port_request.url), alternative_service,
- 1.0, expiration);
+ SchemeOriginPair::FromURL(unrestricted_port_request.url),
+ alternative_service, 1.0, expiration);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
@@ -10591,8 +10594,8 @@ TEST_P(HttpNetworkTransactionTest,
kUnrestrictedAlternatePort);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
http_server_properties->SetAlternativeService(
- HostPortPair::FromURL(unrestricted_port_request.url), alternative_service,
- 1.0, expiration);
+ SchemeOriginPair::FromURL(unrestricted_port_request.url),
+ alternative_service, 1.0, expiration);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
@@ -10638,7 +10641,8 @@ TEST_P(HttpNetworkTransactionTest, AlternateProtocolUnsafeBlocked) {
kUnsafePort);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
http_server_properties->SetAlternativeService(
- HostPortPair::FromURL(request.url), alternative_service, 1.0, expiration);
+ SchemeOriginPair::FromURL(request.url), alternative_service, 1.0,
+ expiration);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
@@ -13369,8 +13373,9 @@ class AltSvcCertificateVerificationTest : public HttpNetworkTransactionTest {
AlternativeService alternative_service(
AlternateProtocolFromNextProto(GetProtocol()), alternative);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- http_server_properties->SetAlternativeService(origin, alternative_service,
- 1.0, expiration);
+ http_server_properties->SetAlternativeService(
+ SchemeOriginPair("https", origin), alternative_service, 1.0,
+ expiration);
// First request to alternative.
if (pooling) {
@@ -13474,8 +13479,8 @@ TEST_P(HttpNetworkTransactionTest, AlternativeServiceNotOnHttp11) {
AlternativeService alternative_service(
AlternateProtocolFromNextProto(GetProtocol()), alternative);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- http_server_properties->SetAlternativeService(origin, alternative_service,
- 1.0, expiration);
+ http_server_properties->SetAlternativeService(
+ SchemeOriginPair("https", origin), alternative_service, 1.0, expiration);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
@@ -13548,8 +13553,8 @@ TEST_P(HttpNetworkTransactionTest, FailedAlternativeServiceIsNotUserVisible) {
AlternativeService alternative_service(
AlternateProtocolFromNextProto(GetProtocol()), alternative);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- http_server_properties->SetAlternativeService(origin, alternative_service,
- 1.0, expiration);
+ http_server_properties->SetAlternativeService(
+ SchemeOriginPair("https", origin), alternative_service, 1.0, expiration);
HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
HttpRequestInfo request1;
@@ -13658,8 +13663,8 @@ TEST_P(HttpNetworkTransactionTest, AlternativeServiceShouldNotPoolToHttp11) {
AlternativeService alternative_service(
AlternateProtocolFromNextProto(GetProtocol()), alternative);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- http_server_properties->SetAlternativeService(origin, alternative_service,
- 1.0, expiration);
+ http_server_properties->SetAlternativeService(
+ SchemeOriginPair("https", origin), alternative_service, 1.0, expiration);
// First transaction to alternative to open an HTTP/1.1 socket.
scoped_ptr<HttpTransaction> trans1(

Powered by Google App Engine
This is Rietveld 408576698