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

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 2932503005: Change AlternativeServiceInfo to a class (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/bidirectional_stream_unittest.cc ('k') | net/http/http_server_properties.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 10093 matching lines...) Expand 10 before | Expand all | Expand 10 after
10104 10104
10105 std::string response_data; 10105 std::string response_data;
10106 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); 10106 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk());
10107 EXPECT_EQ("hello world", response_data); 10107 EXPECT_EQ("hello world", response_data);
10108 10108
10109 AlternativeServiceInfoVector alternative_service_info_vector = 10109 AlternativeServiceInfoVector alternative_service_info_vector =
10110 http_server_properties->GetAlternativeServiceInfos(test_server); 10110 http_server_properties->GetAlternativeServiceInfos(test_server);
10111 ASSERT_EQ(1u, alternative_service_info_vector.size()); 10111 ASSERT_EQ(1u, alternative_service_info_vector.size());
10112 AlternativeService alternative_service(kProtoHTTP2, "mail.example.org", 443); 10112 AlternativeService alternative_service(kProtoHTTP2, "mail.example.org", 443);
10113 EXPECT_EQ(alternative_service, 10113 EXPECT_EQ(alternative_service,
10114 alternative_service_info_vector[0].alternative_service); 10114 alternative_service_info_vector[0].alternative_service());
10115 } 10115 }
10116 10116
10117 // Regression test for https://crbug.com/615497. 10117 // Regression test for https://crbug.com/615497.
10118 TEST_F(HttpNetworkTransactionTest, 10118 TEST_F(HttpNetworkTransactionTest,
10119 DoNotParseAlternativeServiceHeaderOnInsecureRequest) { 10119 DoNotParseAlternativeServiceHeaderOnInsecureRequest) {
10120 MockRead data_reads[] = { 10120 MockRead data_reads[] = {
10121 MockRead("HTTP/1.1 200 OK\r\n"), 10121 MockRead("HTTP/1.1 200 OK\r\n"),
10122 MockRead(kAlternativeServiceHttpHeader), 10122 MockRead(kAlternativeServiceHttpHeader),
10123 MockRead("\r\n"), 10123 MockRead("\r\n"),
10124 MockRead("hello world"), 10124 MockRead("hello world"),
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
10346 std::string response_data; 10346 std::string response_data;
10347 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); 10347 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk());
10348 EXPECT_EQ("hello world", response_data); 10348 EXPECT_EQ("hello world", response_data);
10349 10349
10350 AlternativeServiceInfoVector alternative_service_info_vector = 10350 AlternativeServiceInfoVector alternative_service_info_vector =
10351 http_server_properties->GetAlternativeServiceInfos(test_server); 10351 http_server_properties->GetAlternativeServiceInfos(test_server);
10352 ASSERT_EQ(2u, alternative_service_info_vector.size()); 10352 ASSERT_EQ(2u, alternative_service_info_vector.size());
10353 10353
10354 AlternativeService alternative_service(kProtoHTTP2, "www.example.com", 443); 10354 AlternativeService alternative_service(kProtoHTTP2, "www.example.com", 443);
10355 EXPECT_EQ(alternative_service, 10355 EXPECT_EQ(alternative_service,
10356 alternative_service_info_vector[0].alternative_service); 10356 alternative_service_info_vector[0].alternative_service());
10357 AlternativeService alternative_service_2(kProtoHTTP2, "www.example.org", 10357 AlternativeService alternative_service_2(kProtoHTTP2, "www.example.org",
10358 1234); 10358 1234);
10359 EXPECT_EQ(alternative_service_2, 10359 EXPECT_EQ(alternative_service_2,
10360 alternative_service_info_vector[1].alternative_service); 10360 alternative_service_info_vector[1].alternative_service());
10361 } 10361 }
10362 10362
10363 TEST_F(HttpNetworkTransactionTest, IdentifyQuicBroken) { 10363 TEST_F(HttpNetworkTransactionTest, IdentifyQuicBroken) {
10364 url::SchemeHostPort server("https", "origin.example.org", 443); 10364 url::SchemeHostPort server("https", "origin.example.org", 443);
10365 HostPortPair alternative("alternative.example.org", 443); 10365 HostPortPair alternative("alternative.example.org", 443);
10366 std::string origin_url = "https://origin.example.org:443"; 10366 std::string origin_url = "https://origin.example.org:443";
10367 std::string alternative_url = "https://alternative.example.org:443"; 10367 std::string alternative_url = "https://alternative.example.org:443";
10368 10368
10369 // Negotiate HTTP/1.1 with alternative.example.org. 10369 // Negotiate HTTP/1.1 with alternative.example.org.
10370 SSLSocketDataProvider ssl(ASYNC, OK); 10370 SSLSocketDataProvider ssl(ASYNC, OK);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
10537 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 10537 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
10538 10538
10539 std::string response_data; 10539 std::string response_data;
10540 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); 10540 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk());
10541 EXPECT_EQ("hello world", response_data); 10541 EXPECT_EQ("hello world", response_data);
10542 10542
10543 const AlternativeServiceInfoVector alternative_service_info_vector = 10543 const AlternativeServiceInfoVector alternative_service_info_vector =
10544 http_server_properties->GetAlternativeServiceInfos(server); 10544 http_server_properties->GetAlternativeServiceInfos(server);
10545 ASSERT_EQ(1u, alternative_service_info_vector.size()); 10545 ASSERT_EQ(1u, alternative_service_info_vector.size());
10546 EXPECT_EQ(alternative_service, 10546 EXPECT_EQ(alternative_service,
10547 alternative_service_info_vector[0].alternative_service); 10547 alternative_service_info_vector[0].alternative_service());
10548 EXPECT_TRUE( 10548 EXPECT_TRUE(
10549 http_server_properties->IsAlternativeServiceBroken(alternative_service)); 10549 http_server_properties->IsAlternativeServiceBroken(alternative_service));
10550 } 10550 }
10551 10551
10552 // Ensure that we are not allowed to redirect traffic via an alternate protocol 10552 // Ensure that we are not allowed to redirect traffic via an alternate protocol
10553 // to an unrestricted (port >= 1024) when the original traffic was on a 10553 // to an unrestricted (port >= 1024) when the original traffic was on a
10554 // restricted port (port < 1024). Ensure that we can redirect in all other 10554 // restricted port (port < 1024). Ensure that we can redirect in all other
10555 // cases. 10555 // cases.
10556 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortRestrictedBlocked) { 10556 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortRestrictedBlocked) {
10557 HttpRequestInfo restricted_port_request; 10557 HttpRequestInfo restricted_port_request;
(...skipping 6354 matching lines...) Expand 10 before | Expand all | Expand 10 after
16912 16912
16913 TestCompletionCallback callback; 16913 TestCompletionCallback callback;
16914 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 16914 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
16915 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 16915 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
16916 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 16916 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
16917 16917
16918 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_NO_SUPPORTED_PROXIES)); 16918 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_NO_SUPPORTED_PROXIES));
16919 } 16919 }
16920 16920
16921 } // namespace net 16921 } // namespace net
OLDNEW
« no previous file with comments | « net/http/bidirectional_stream_unittest.cc ('k') | net/http/http_server_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698