OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/test_server.h" | 5 #include "net/test/test_server.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 case CERT_CHAIN_WRONG_ROOT: | 62 case CERT_CHAIN_WRONG_ROOT: |
63 // This chain uses its own dedicated test root certificate to avoid | 63 // This chain uses its own dedicated test root certificate to avoid |
64 // side-effects that may affect testing. | 64 // side-effects that may affect testing. |
65 return FilePath(FILE_PATH_LITERAL("redundant-server-chain.pem")); | 65 return FilePath(FILE_PATH_LITERAL("redundant-server-chain.pem")); |
66 default: | 66 default: |
67 NOTREACHED(); | 67 NOTREACHED(); |
68 } | 68 } |
69 return FilePath(); | 69 return FilePath(); |
70 } | 70 } |
71 | 71 |
72 std::string TestServer::HTTPSOptions::GetSpecialCertificateString() const { | |
73 switch (server_certificate) { | |
74 case OCSP_OK: | |
75 return "__ocsp_ok__"; | |
76 case OCSP_REVOKED: | |
77 return "__ocsp_revoked__"; | |
78 case OCSP_INVALID: | |
79 return "__ocsp_invalid__"; | |
80 default: | |
81 return ""; | |
82 } | |
Ryan Sleevi
2012/03/09 22:07:53
Can you rework this not to require these sorts of
agl
2012/03/13 22:24:29
I had to split the certificate and key filename fr
| |
83 } | |
84 | |
72 const char TestServer::kLocalhost[] = "127.0.0.1"; | 85 const char TestServer::kLocalhost[] = "127.0.0.1"; |
73 const char TestServer::kGDataAuthToken[] = "testtoken"; | 86 const char TestServer::kGDataAuthToken[] = "testtoken"; |
74 | 87 |
75 TestServer::TestServer(Type type, | 88 TestServer::TestServer(Type type, |
76 const std::string& host, | 89 const std::string& host, |
77 const FilePath& document_root) | 90 const FilePath& document_root) |
78 : type_(type), | 91 : type_(type), |
79 started_(false), | 92 started_(false), |
80 log_to_console_(false) { | 93 log_to_console_(false) { |
81 Init(host, document_root); | 94 Init(host, document_root); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 } else if (type_ == TYPE_SYNC) { | 389 } else if (type_ == TYPE_SYNC) { |
377 command_line->AppendArg("--sync"); | 390 command_line->AppendArg("--sync"); |
378 } else if (type_ == TYPE_TCP_ECHO) { | 391 } else if (type_ == TYPE_TCP_ECHO) { |
379 command_line->AppendArg("--tcp-echo"); | 392 command_line->AppendArg("--tcp-echo"); |
380 } else if (type_ == TYPE_UDP_ECHO) { | 393 } else if (type_ == TYPE_UDP_ECHO) { |
381 command_line->AppendArg("--udp-echo"); | 394 command_line->AppendArg("--udp-echo"); |
382 } else if (type_ == TYPE_GDATA) { | 395 } else if (type_ == TYPE_GDATA) { |
383 // --auth-token will be used in tests for chrome/browser/chromeos/gdata. | 396 // --auth-token will be used in tests for chrome/browser/chromeos/gdata. |
384 command_line->AppendArg(std::string("--auth-token=") + kGDataAuthToken); | 397 command_line->AppendArg(std::string("--auth-token=") + kGDataAuthToken); |
385 } else if (type_ == TYPE_HTTPS) { | 398 } else if (type_ == TYPE_HTTPS) { |
386 FilePath certificate_path(certificates_dir_); | 399 std::string cert_option = https_options_.GetSpecialCertificateString(); |
387 certificate_path = certificate_path.Append( | 400 if (!cert_option.empty()) { |
388 https_options_.GetCertificateFile()); | 401 command_line->AppendArg("--https=" + cert_option); |
389 if (!file_util::PathExists(certificate_path)) { | 402 } else { |
390 LOG(ERROR) << "Certificate path " << certificate_path.value() | 403 FilePath certificate_path(certificates_dir_); |
391 << " doesn't exist. Can't launch https server."; | 404 certificate_path = certificate_path.Append( |
392 return false; | 405 https_options_.GetCertificateFile()); |
406 if (!file_util::PathExists(certificate_path)) { | |
407 LOG(ERROR) << "Certificate path " << certificate_path.value() | |
408 << " doesn't exist. Can't launch https server."; | |
409 return false; | |
410 } | |
411 command_line->AppendArgNative(FILE_PATH_LITERAL("--https=") + | |
412 certificate_path.value()); | |
393 } | 413 } |
394 command_line->AppendArgNative(FILE_PATH_LITERAL("--https=") + | |
395 certificate_path.value()); | |
396 | 414 |
397 if (https_options_.request_client_certificate) | 415 if (https_options_.request_client_certificate) |
398 command_line->AppendArg("--ssl-client-auth"); | 416 command_line->AppendArg("--ssl-client-auth"); |
399 | 417 |
400 for (std::vector<FilePath>::const_iterator it = | 418 for (std::vector<FilePath>::const_iterator it = |
401 https_options_.client_authorities.begin(); | 419 https_options_.client_authorities.begin(); |
402 it != https_options_.client_authorities.end(); ++it) { | 420 it != https_options_.client_authorities.end(); ++it) { |
403 if (!file_util::PathExists(*it)) { | 421 if (!file_util::PathExists(*it)) { |
404 LOG(ERROR) << "Client authority path " << it->value() | 422 LOG(ERROR) << "Client authority path " << it->value() |
405 << " doesn't exist. Can't launch https server."; | 423 << " doesn't exist. Can't launch https server."; |
(...skipping 15 matching lines...) Expand all Loading... | |
421 command_line->AppendArg(kBulkCipherSwitch + "=3des"); | 439 command_line->AppendArg(kBulkCipherSwitch + "=3des"); |
422 | 440 |
423 if (https_options_.record_resume) | 441 if (https_options_.record_resume) |
424 command_line->AppendArg("--https-record-resume"); | 442 command_line->AppendArg("--https-record-resume"); |
425 } | 443 } |
426 | 444 |
427 return true; | 445 return true; |
428 } | 446 } |
429 | 447 |
430 } // namespace net | 448 } // namespace net |
OLD | NEW |