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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 new_file_path += "replace_text="; | 293 new_file_path += "replace_text="; |
294 new_file_path += base64_old; | 294 new_file_path += base64_old; |
295 new_file_path += ":"; | 295 new_file_path += ":"; |
296 new_file_path += base64_new; | 296 new_file_path += base64_new; |
297 } | 297 } |
298 | 298 |
299 *replacement_path = new_file_path; | 299 *replacement_path = new_file_path; |
300 return true; | 300 return true; |
301 } | 301 } |
302 | 302 |
| 303 bool BaseTestServer::LoadTestRootCert() const { |
| 304 TestRootCerts* root_certs = TestRootCerts::GetInstance(); |
| 305 if (!root_certs) |
| 306 return false; |
| 307 |
| 308 // Should always use absolute path to load the root certificate. |
| 309 base::FilePath root_certificate_path = certificates_dir_; |
| 310 if (!certificates_dir_.IsAbsolute()) { |
| 311 base::FilePath src_dir; |
| 312 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) |
| 313 return false; |
| 314 root_certificate_path = src_dir.Append(certificates_dir_); |
| 315 } |
| 316 |
| 317 return root_certs->AddFromFile( |
| 318 root_certificate_path.AppendASCII("root_ca_cert.pem")); |
| 319 } |
| 320 |
303 void BaseTestServer::Init(const std::string& host) { | 321 void BaseTestServer::Init(const std::string& host) { |
304 host_port_pair_ = HostPortPair(host, 0); | 322 host_port_pair_ = HostPortPair(host, 0); |
305 | 323 |
306 // TODO(battre) Remove this after figuring out why the TestServer is flaky. | 324 // TODO(battre) Remove this after figuring out why the TestServer is flaky. |
307 // http://crbug.com/96594 | 325 // http://crbug.com/96594 |
308 log_to_console_ = true; | 326 log_to_console_ = true; |
309 } | 327 } |
310 | 328 |
311 void BaseTestServer::SetResourcePath(const base::FilePath& document_root, | 329 void BaseTestServer::SetResourcePath(const base::FilePath& document_root, |
312 const base::FilePath& certificates_dir) { | 330 const base::FilePath& certificates_dir) { |
(...skipping 22 matching lines...) Expand all Loading... |
335 } | 353 } |
336 if ((port <= 0) || (port > kuint16max)) { | 354 if ((port <= 0) || (port > kuint16max)) { |
337 LOG(ERROR) << "Invalid port value: " << port; | 355 LOG(ERROR) << "Invalid port value: " << port; |
338 return false; | 356 return false; |
339 } | 357 } |
340 host_port_pair_.set_port(port); | 358 host_port_pair_.set_port(port); |
341 | 359 |
342 return true; | 360 return true; |
343 } | 361 } |
344 | 362 |
345 bool BaseTestServer::LoadTestRootCert() const { | |
346 TestRootCerts* root_certs = TestRootCerts::GetInstance(); | |
347 if (!root_certs) | |
348 return false; | |
349 | |
350 // Should always use absolute path to load the root certificate. | |
351 base::FilePath root_certificate_path = certificates_dir_; | |
352 if (!certificates_dir_.IsAbsolute()) { | |
353 base::FilePath src_dir; | |
354 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) | |
355 return false; | |
356 root_certificate_path = src_dir.Append(certificates_dir_); | |
357 } | |
358 | |
359 return root_certs->AddFromFile( | |
360 root_certificate_path.AppendASCII("root_ca_cert.pem")); | |
361 } | |
362 | |
363 bool BaseTestServer::SetupWhenServerStarted() { | 363 bool BaseTestServer::SetupWhenServerStarted() { |
364 DCHECK(host_port_pair_.port()); | 364 DCHECK(host_port_pair_.port()); |
365 | 365 |
366 if (UsingSSL(type_) && !LoadTestRootCert()) | 366 if (UsingSSL(type_) && !LoadTestRootCert()) |
367 return false; | 367 return false; |
368 | 368 |
369 started_ = true; | 369 started_ = true; |
370 allowed_port_.reset(new ScopedPortException(host_port_pair_.port())); | 370 allowed_port_.reset(new ScopedPortException(host_port_pair_.port())); |
371 return true; | 371 return true; |
372 } | 372 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 492 |
493 return GenerateAdditionalArguments(arguments); | 493 return GenerateAdditionalArguments(arguments); |
494 } | 494 } |
495 | 495 |
496 bool BaseTestServer::GenerateAdditionalArguments( | 496 bool BaseTestServer::GenerateAdditionalArguments( |
497 base::DictionaryValue* arguments) const { | 497 base::DictionaryValue* arguments) const { |
498 return true; | 498 return true; |
499 } | 499 } |
500 | 500 |
501 } // namespace net | 501 } // namespace net |
OLD | NEW |