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

Unified Diff: net/http/http_network_transaction_unittest.cc

Issue 2017323002: Disable HTTP/2 Alternative Service for different host. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not change port except for a small number of tests. Created 4 years, 7 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
« no previous file with comments | « no previous file | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6ff5d0bfd42baeb2715fedca94773aded2aac577..6e5b38e3f0e75d6d80ab84cc7e41514cfcb3bf53 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -327,7 +327,7 @@ class HttpNetworkTransactionTest
std::string GetAlternativeServiceHttpHeader() {
return std::string("Alt-Svc: ") + GetAlternateProtocolFromParam() +
- "=\"www.example.com:443\"\r\n";
+ "=\"www.example.org:443\"\r\n";
}
// Either |write_failure| specifies a write failure or |read_failure|
@@ -9705,10 +9705,55 @@ TEST_P(HttpNetworkTransactionTest, HonorAlternativeServiceHeader) {
ASSERT_EQ(1u, alternative_service_vector.size());
EXPECT_EQ(AlternateProtocolFromNextProto(GetProtocol()),
alternative_service_vector[0].protocol);
- EXPECT_EQ("www.example.com", alternative_service_vector[0].host);
+ EXPECT_EQ("www.example.org", alternative_service_vector[0].host);
EXPECT_EQ(443, alternative_service_vector[0].port);
}
+// HTTP/2 Alternative Services should be disabled if alternative service
+// hostname is different from that of origin.
+// TODO(bnc): Remove when https://crbug.com/615413 is fixed.
+TEST_P(HttpNetworkTransactionTest,
+ DisableHTTP2AlternativeServicesWithDifferentHost) {
+ session_deps_.enable_alternative_service_with_different_host = true;
+
+ HttpRequestInfo request;
+ request.method = "GET";
+ request.url = GURL("http://www.example.org/");
+ request.load_flags = 0;
+
+ MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
+ StaticSocketDataProvider first_data;
+ first_data.set_connect_data(mock_connect);
+ session_deps_.socket_factory->AddSocketDataProvider(&first_data);
+
+ MockRead data_reads[] = {
+ MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello world"),
+ MockRead(ASYNC, OK),
+ };
+ StaticSocketDataProvider second_data(data_reads, arraysize(data_reads), NULL,
+ 0);
+ session_deps_.socket_factory->AddSocketDataProvider(&second_data);
+
+ std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
+
+ base::WeakPtr<HttpServerProperties> http_server_properties =
+ session->http_server_properties();
+ AlternativeService alternative_service(
+ AlternateProtocolFromNextProto(GetProtocol()), "different.example.org",
+ 444);
+ base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
+ http_server_properties->SetAlternativeService(
+ url::SchemeHostPort(request.url), alternative_service, expiration);
+
+ std::unique_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
+ TestCompletionCallback callback;
+
+ int rv = trans->Start(&request, callback.callback(), BoundNetLog());
+ // Alternative service is not used, request fails.
+ EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv));
+}
+
TEST_P(HttpNetworkTransactionTest, ClearAlternativeServices) {
session_deps_.enable_alternative_service_with_different_host = false;
@@ -10600,7 +10645,7 @@ TEST_P(HttpNetworkTransactionTest, StallAlternativeServiceForNpnSpdy) {
HttpRequestInfo request;
request.method = "GET";
- request.url = GURL("http://www.example.com/");
+ request.url = GURL("http://www.example.org/");
request.load_flags = 0;
std::string alternative_service_http_header =
@@ -10769,8 +10814,8 @@ TEST_P(HttpNetworkTransactionTest, UseAlternativeServiceForTunneledNpnSpdy) {
spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
MockWrite spdy_writes[] = {
MockWrite(ASYNC, 0,
- "CONNECT www.example.com:443 HTTP/1.1\r\n"
- "Host: www.example.com:443\r\n"
+ "CONNECT www.example.org:443 HTTP/1.1\r\n"
+ "Host: www.example.org:443\r\n"
"Proxy-Connection: keep-alive\r\n\r\n"),
CreateMockWrite(*req, 2),
};
@@ -10913,7 +10958,7 @@ TEST_P(HttpNetworkTransactionTest,
EXPECT_EQ("hello world", response_data);
// Set up an initial SpdySession in the pool to reuse.
- HostPortPair host_port_pair("www.example.com", 443);
+ HostPortPair host_port_pair("www.example.org", 443);
SpdySessionKey key(host_port_pair, ProxyServer::Direct(),
PRIVACY_MODE_DISABLED);
base::WeakPtr<SpdySession> spdy_session =
@@ -13159,17 +13204,18 @@ TEST_P(AltSvcCertificateVerificationTest, NewConnectionValid) {
Run(false, true);
}
-TEST_P(AltSvcCertificateVerificationTest, NewConnectionInvalid) {
+// TODO(bnc): Re-enable when https://crbug.com/615413 is fixed.
+TEST_P(AltSvcCertificateVerificationTest, DISABLED_NewConnectionInvalid) {
Run(false, false);
}
// Alternative service requires HTTP/2 (or SPDY), but HTTP/1.1 is negotiated
// with the alternative server. That connection should not be used.
TEST_P(HttpNetworkTransactionTest, AlternativeServiceNotOnHttp11) {
- url::SchemeHostPort server("https", "origin.example.org", 443);
- HostPortPair alternative("alternative.example.org", 443);
+ url::SchemeHostPort server("https", "www.example.org", 443);
+ HostPortPair alternative("www.example.org", 444);
- // Negotiate HTTP/1.1 with alternative.example.org.
+ // Negotiate HTTP/1.1 with alternative.
SSLSocketDataProvider ssl(ASYNC, OK);
ssl.SetNextProto(kProtoHTTP11);
session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
@@ -13201,7 +13247,7 @@ TEST_P(HttpNetworkTransactionTest, AlternativeServiceNotOnHttp11) {
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
HttpRequestInfo request;
request.method = "GET";
- request.url = GURL("https://origin.example.org:443");
+ request.url = GURL("https://www.example.org:443");
request.load_flags = 0;
TestCompletionCallback callback;
@@ -13216,8 +13262,8 @@ TEST_P(HttpNetworkTransactionTest, AlternativeServiceNotOnHttp11) {
// succeeds, the request should succeed, even if the latter fails because
// HTTP/1.1 is negotiated which is insufficient for alternative service.
TEST_P(HttpNetworkTransactionTest, FailedAlternativeServiceIsNotUserVisible) {
- url::SchemeHostPort server("https", "origin.example.org", 443);
- HostPortPair alternative("alternative.example.org", 443);
+ url::SchemeHostPort server("https", "www.example.org", 443);
+ HostPortPair alternative("www.example.org", 444);
// Negotiate HTTP/1.1 with alternative.
SSLSocketDataProvider alternative_ssl(ASYNC, OK);
@@ -13235,14 +13281,12 @@ TEST_P(HttpNetworkTransactionTest, FailedAlternativeServiceIsNotUserVisible) {
session_deps_.socket_factory->AddSSLSocketDataProvider(&origin_ssl);
MockWrite http_writes[] = {
- MockWrite(
- "GET / HTTP/1.1\r\n"
- "Host: origin.example.org\r\n"
- "Connection: keep-alive\r\n\r\n"),
- MockWrite(
- "GET /second HTTP/1.1\r\n"
- "Host: origin.example.org\r\n"
- "Connection: keep-alive\r\n\r\n"),
+ MockWrite("GET / HTTP/1.1\r\n"
+ "Host: www.example.org\r\n"
+ "Connection: keep-alive\r\n\r\n"),
+ MockWrite("GET /second HTTP/1.1\r\n"
+ "Host: www.example.org\r\n"
+ "Connection: keep-alive\r\n\r\n"),
};
MockRead http_reads[] = {
@@ -13273,7 +13317,7 @@ TEST_P(HttpNetworkTransactionTest, FailedAlternativeServiceIsNotUserVisible) {
HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
HttpRequestInfo request1;
request1.method = "GET";
- request1.url = GURL("https://origin.example.org:443");
+ request1.url = GURL("https://www.example.org:443");
request1.load_flags = 0;
TestCompletionCallback callback1;
@@ -13301,7 +13345,7 @@ TEST_P(HttpNetworkTransactionTest, FailedAlternativeServiceIsNotUserVisible) {
HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session.get());
HttpRequestInfo request2;
request2.method = "GET";
- request2.url = GURL("https://origin.example.org:443/second");
+ request2.url = GURL("https://www.example.org:443/second");
request2.load_flags = 0;
TestCompletionCallback callback2;
« no previous file with comments | « no previous file | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698