| OLD | NEW |
| 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 <memory> | 5 #include <memory> |
| 6 #include <ostream> | 6 #include <ostream> |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "net/http/transport_security_state.h" | 29 #include "net/http/transport_security_state.h" |
| 30 #include "net/log/net_log_with_source.h" | 30 #include "net/log/net_log_with_source.h" |
| 31 #include "net/proxy/proxy_service.h" | 31 #include "net/proxy/proxy_service.h" |
| 32 #include "net/quic/test_tools/crypto_test_utils.h" | 32 #include "net/quic/test_tools/crypto_test_utils.h" |
| 33 #include "net/quic/test_tools/quic_test_utils.h" | 33 #include "net/quic/test_tools/quic_test_utils.h" |
| 34 #include "net/ssl/default_channel_id_store.h" | 34 #include "net/ssl/default_channel_id_store.h" |
| 35 #include "net/ssl/ssl_config_service_defaults.h" | 35 #include "net/ssl/ssl_config_service_defaults.h" |
| 36 #include "net/test/cert_test_util.h" | 36 #include "net/test/cert_test_util.h" |
| 37 #include "net/test/gtest_util.h" | 37 #include "net/test/gtest_util.h" |
| 38 #include "net/test/test_data_directory.h" | 38 #include "net/test/test_data_directory.h" |
| 39 #include "net/tools/quic/quic_in_memory_cache.h" | 39 #include "net/tools/quic/quic_http_response_cache.h" |
| 40 #include "net/tools/quic/quic_simple_server.h" | 40 #include "net/tools/quic/quic_simple_server.h" |
| 41 #include "testing/gmock/include/gmock/gmock.h" | 41 #include "testing/gmock/include/gmock/gmock.h" |
| 42 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
| 43 #include "testing/platform_test.h" | 43 #include "testing/platform_test.h" |
| 44 | 44 |
| 45 using base::StringPiece; | 45 using base::StringPiece; |
| 46 | 46 |
| 47 namespace net { | 47 namespace net { |
| 48 | 48 |
| 49 using test::IsOk; | 49 using test::IsOk; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Starts the QUIC server listening on a random port. | 172 // Starts the QUIC server listening on a random port. |
| 173 void StartServer() { | 173 void StartServer() { |
| 174 server_address_ = IPEndPoint(IPAddress(127, 0, 0, 1), 0); | 174 server_address_ = IPEndPoint(IPAddress(127, 0, 0, 1), 0); |
| 175 server_config_.SetInitialStreamFlowControlWindowToSend( | 175 server_config_.SetInitialStreamFlowControlWindowToSend( |
| 176 kInitialStreamFlowControlWindowForTest); | 176 kInitialStreamFlowControlWindowForTest); |
| 177 server_config_.SetInitialSessionFlowControlWindowToSend( | 177 server_config_.SetInitialSessionFlowControlWindowToSend( |
| 178 kInitialSessionFlowControlWindowForTest); | 178 kInitialSessionFlowControlWindowForTest); |
| 179 server_config_options_.token_binding_params = QuicTagVector{kTB10, kP256}; | 179 server_config_options_.token_binding_params = QuicTagVector{kTB10, kP256}; |
| 180 server_.reset(new QuicSimpleServer( | 180 server_.reset(new QuicSimpleServer( |
| 181 CryptoTestUtils::ProofSourceForTesting(), server_config_, | 181 CryptoTestUtils::ProofSourceForTesting(), server_config_, |
| 182 server_config_options_, AllSupportedVersions(), &in_memory_cache_)); | 182 server_config_options_, AllSupportedVersions(), &response_cache_)); |
| 183 server_->Listen(server_address_); | 183 server_->Listen(server_address_); |
| 184 server_address_ = server_->server_address(); | 184 server_address_ = server_->server_address(); |
| 185 server_->StartReading(); | 185 server_->StartReading(); |
| 186 server_started_ = true; | 186 server_started_ = true; |
| 187 } | 187 } |
| 188 | 188 |
| 189 // Adds an entry to the cache used by the QUIC server to serve | 189 // Adds an entry to the cache used by the QUIC server to serve |
| 190 // responses. | 190 // responses. |
| 191 void AddToCache(StringPiece path, | 191 void AddToCache(StringPiece path, |
| 192 int response_code, | 192 int response_code, |
| 193 StringPiece response_detail, | 193 StringPiece response_detail, |
| 194 StringPiece body) { | 194 StringPiece body) { |
| 195 in_memory_cache_.AddSimpleResponse("test.example.com", path, response_code, | 195 response_cache_.AddSimpleResponse("test.example.com", path, response_code, |
| 196 body); | 196 body); |
| 197 } | 197 } |
| 198 | 198 |
| 199 // Populates |request_body_| with |length_| ASCII bytes. | 199 // Populates |request_body_| with |length_| ASCII bytes. |
| 200 void GenerateBody(size_t length) { | 200 void GenerateBody(size_t length) { |
| 201 request_body_.clear(); | 201 request_body_.clear(); |
| 202 request_body_.reserve(length); | 202 request_body_.reserve(length); |
| 203 for (size_t i = 0; i < length; ++i) { | 203 for (size_t i = 0; i < length; ++i) { |
| 204 request_body_.append(1, static_cast<char>(32 + i % (126 - 32))); | 204 request_body_.append(1, static_cast<char>(32 + i % (126 - 32))); |
| 205 } | 205 } |
| 206 } | 206 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 scoped_refptr<SSLConfigServiceDefaults> ssl_config_service_; | 241 scoped_refptr<SSLConfigServiceDefaults> ssl_config_service_; |
| 242 std::unique_ptr<ProxyService> proxy_service_; | 242 std::unique_ptr<ProxyService> proxy_service_; |
| 243 std::unique_ptr<HttpAuthHandlerFactory> auth_handler_factory_; | 243 std::unique_ptr<HttpAuthHandlerFactory> auth_handler_factory_; |
| 244 HttpServerPropertiesImpl http_server_properties_; | 244 HttpServerPropertiesImpl http_server_properties_; |
| 245 HttpNetworkSession::Params params_; | 245 HttpNetworkSession::Params params_; |
| 246 std::unique_ptr<TestTransactionFactory> transaction_factory_; | 246 std::unique_ptr<TestTransactionFactory> transaction_factory_; |
| 247 HttpRequestInfo request_; | 247 HttpRequestInfo request_; |
| 248 std::string request_body_; | 248 std::string request_body_; |
| 249 std::unique_ptr<UploadDataStream> upload_data_stream_; | 249 std::unique_ptr<UploadDataStream> upload_data_stream_; |
| 250 std::unique_ptr<QuicSimpleServer> server_; | 250 std::unique_ptr<QuicSimpleServer> server_; |
| 251 QuicInMemoryCache in_memory_cache_; | 251 QuicHttpResponseCache response_cache_; |
| 252 IPEndPoint server_address_; | 252 IPEndPoint server_address_; |
| 253 std::string server_hostname_; | 253 std::string server_hostname_; |
| 254 QuicConfig server_config_; | 254 QuicConfig server_config_; |
| 255 QuicCryptoServerConfig::ConfigOptions server_config_options_; | 255 QuicCryptoServerConfig::ConfigOptions server_config_options_; |
| 256 bool server_started_; | 256 bool server_started_; |
| 257 bool strike_register_no_startup_period_; | 257 bool strike_register_no_startup_period_; |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 INSTANTIATE_TEST_CASE_P(Tests, | 260 INSTANTIATE_TEST_CASE_P(Tests, |
| 261 QuicEndToEndTest, | 261 QuicEndToEndTest, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 359 |
| 360 // Will terminate when the last consumer completes. | 360 // Will terminate when the last consumer completes. |
| 361 base::RunLoop().Run(); | 361 base::RunLoop().Run(); |
| 362 | 362 |
| 363 for (const auto& consumer : consumers) | 363 for (const auto& consumer : consumers) |
| 364 CheckResponse(*consumer.get(), "HTTP/1.1 200", kResponseBody); | 364 CheckResponse(*consumer.get(), "HTTP/1.1 200", kResponseBody); |
| 365 } | 365 } |
| 366 | 366 |
| 367 } // namespace test | 367 } // namespace test |
| 368 } // namespace net | 368 } // namespace net |
| OLD | NEW |