| 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 "net/test/spawned_test_server/base_test_server.h" | 5 #include "net/test/spawned_test_server/base_test_server.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 new_file_path += "replace_text="; | 303 new_file_path += "replace_text="; |
| 304 new_file_path += base64_old; | 304 new_file_path += base64_old; |
| 305 new_file_path += ":"; | 305 new_file_path += ":"; |
| 306 new_file_path += base64_new; | 306 new_file_path += base64_new; |
| 307 } | 307 } |
| 308 | 308 |
| 309 *replacement_path = new_file_path; | 309 *replacement_path = new_file_path; |
| 310 return true; | 310 return true; |
| 311 } | 311 } |
| 312 | 312 |
| 313 bool BaseTestServer::LoadTestRootCert() const { |
| 314 TestRootCerts* root_certs = TestRootCerts::GetInstance(); |
| 315 if (!root_certs) |
| 316 return false; |
| 317 |
| 318 // Should always use absolute path to load the root certificate. |
| 319 base::FilePath root_certificate_path = certificates_dir_; |
| 320 if (!certificates_dir_.IsAbsolute()) { |
| 321 base::FilePath src_dir; |
| 322 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) |
| 323 return false; |
| 324 root_certificate_path = src_dir.Append(certificates_dir_); |
| 325 } |
| 326 |
| 327 return root_certs->AddFromFile( |
| 328 root_certificate_path.AppendASCII("root_ca_cert.pem")); |
| 329 } |
| 330 |
| 313 void BaseTestServer::Init(const std::string& host) { | 331 void BaseTestServer::Init(const std::string& host) { |
| 314 host_port_pair_ = HostPortPair(host, 0); | 332 host_port_pair_ = HostPortPair(host, 0); |
| 315 | 333 |
| 316 // TODO(battre) Remove this after figuring out why the TestServer is flaky. | 334 // TODO(battre) Remove this after figuring out why the TestServer is flaky. |
| 317 // http://crbug.com/96594 | 335 // http://crbug.com/96594 |
| 318 log_to_console_ = true; | 336 log_to_console_ = true; |
| 319 } | 337 } |
| 320 | 338 |
| 321 void BaseTestServer::SetResourcePath(const base::FilePath& document_root, | 339 void BaseTestServer::SetResourcePath(const base::FilePath& document_root, |
| 322 const base::FilePath& certificates_dir) { | 340 const base::FilePath& certificates_dir) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 345 } | 363 } |
| 346 if ((port <= 0) || (port > kuint16max)) { | 364 if ((port <= 0) || (port > kuint16max)) { |
| 347 LOG(ERROR) << "Invalid port value: " << port; | 365 LOG(ERROR) << "Invalid port value: " << port; |
| 348 return false; | 366 return false; |
| 349 } | 367 } |
| 350 host_port_pair_.set_port(port); | 368 host_port_pair_.set_port(port); |
| 351 | 369 |
| 352 return true; | 370 return true; |
| 353 } | 371 } |
| 354 | 372 |
| 355 bool BaseTestServer::LoadTestRootCert() const { | |
| 356 TestRootCerts* root_certs = TestRootCerts::GetInstance(); | |
| 357 if (!root_certs) | |
| 358 return false; | |
| 359 | |
| 360 // Should always use absolute path to load the root certificate. | |
| 361 base::FilePath root_certificate_path = certificates_dir_; | |
| 362 if (!certificates_dir_.IsAbsolute()) { | |
| 363 base::FilePath src_dir; | |
| 364 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) | |
| 365 return false; | |
| 366 root_certificate_path = src_dir.Append(certificates_dir_); | |
| 367 } | |
| 368 | |
| 369 return root_certs->AddFromFile( | |
| 370 root_certificate_path.AppendASCII("root_ca_cert.pem")); | |
| 371 } | |
| 372 | |
| 373 bool BaseTestServer::SetupWhenServerStarted() { | 373 bool BaseTestServer::SetupWhenServerStarted() { |
| 374 DCHECK(host_port_pair_.port()); | 374 DCHECK(host_port_pair_.port()); |
| 375 | 375 |
| 376 if (UsingSSL(type_) && !LoadTestRootCert()) | 376 if (UsingSSL(type_) && !LoadTestRootCert()) |
| 377 return false; | 377 return false; |
| 378 | 378 |
| 379 started_ = true; | 379 started_ = true; |
| 380 allowed_port_.reset(new ScopedPortException(host_port_pair_.port())); | 380 allowed_port_.reset(new ScopedPortException(host_port_pair_.port())); |
| 381 return true; | 381 return true; |
| 382 } | 382 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 502 |
| 503 return GenerateAdditionalArguments(arguments); | 503 return GenerateAdditionalArguments(arguments); |
| 504 } | 504 } |
| 505 | 505 |
| 506 bool BaseTestServer::GenerateAdditionalArguments( | 506 bool BaseTestServer::GenerateAdditionalArguments( |
| 507 base::DictionaryValue* arguments) const { | 507 base::DictionaryValue* arguments) const { |
| 508 return true; | 508 return true; |
| 509 } | 509 } |
| 510 | 510 |
| 511 } // namespace net | 511 } // namespace net |
| OLD | NEW |