| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 return "127.0.0.1"; | 57 return "127.0.0.1"; |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace | 60 } // namespace |
| 61 | 61 |
| 62 TestServer::HTTPSOptions::HTTPSOptions() | 62 TestServer::HTTPSOptions::HTTPSOptions() |
| 63 : server_certificate(CERT_OK), | 63 : server_certificate(CERT_OK), |
| 64 request_client_certificate(false), | 64 request_client_certificate(false), |
| 65 bulk_ciphers(HTTPSOptions::BULK_CIPHER_ANY) {} | 65 bulk_ciphers(HTTPSOptions::BULK_CIPHER_ANY), |
| 66 use_tls_srp(0), only_tls_srp(0) {} |
| 66 | 67 |
| 67 TestServer::HTTPSOptions::HTTPSOptions( | 68 TestServer::HTTPSOptions::HTTPSOptions( |
| 68 TestServer::HTTPSOptions::ServerCertificate cert) | 69 TestServer::HTTPSOptions::ServerCertificate cert) |
| 69 : server_certificate(cert), | 70 : server_certificate(cert), |
| 70 request_client_certificate(false), | 71 request_client_certificate(false), |
| 71 bulk_ciphers(HTTPSOptions::BULK_CIPHER_ANY) {} | 72 bulk_ciphers(HTTPSOptions::BULK_CIPHER_ANY), |
| 73 use_tls_srp(0), only_tls_srp(0) {} |
| 72 | 74 |
| 73 TestServer::HTTPSOptions::~HTTPSOptions() {} | 75 TestServer::HTTPSOptions::~HTTPSOptions() {} |
| 74 | 76 |
| 75 FilePath TestServer::HTTPSOptions::GetCertificateFile() const { | 77 FilePath TestServer::HTTPSOptions::GetCertificateFile() const { |
| 76 switch (server_certificate) { | 78 switch (server_certificate) { |
| 77 case CERT_OK: | 79 case CERT_OK: |
| 78 case CERT_MISMATCHED_NAME: | 80 case CERT_MISMATCHED_NAME: |
| 79 return FilePath(FILE_PATH_LITERAL("ok_cert.pem")); | 81 return FilePath(FILE_PATH_LITERAL("ok_cert.pem")); |
| 80 case CERT_EXPIRED: | 82 case CERT_EXPIRED: |
| 81 return FilePath(FILE_PATH_LITERAL("expired_cert.pem")); | 83 return FilePath(FILE_PATH_LITERAL("expired_cert.pem")); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 100 } | 102 } |
| 101 | 103 |
| 102 TestServer::~TestServer() { | 104 TestServer::~TestServer() { |
| 103 TestRootCerts* root_certs = TestRootCerts::GetInstance(); | 105 TestRootCerts* root_certs = TestRootCerts::GetInstance(); |
| 104 root_certs->Clear(); | 106 root_certs->Clear(); |
| 105 Stop(); | 107 Stop(); |
| 106 } | 108 } |
| 107 | 109 |
| 108 bool TestServer::Start() { | 110 bool TestServer::Start() { |
| 109 if (type_ == TYPE_HTTPS) { | 111 if (type_ == TYPE_HTTPS) { |
| 110 if (!LoadTestRootCert()) | 112 if (!LoadTestRootCert()) { |
| 113 LOG(ERROR) << "Failed to load test root cert"; |
| 111 return false; | 114 return false; |
| 115 } |
| 112 } | 116 } |
| 113 | 117 |
| 114 // Get path to python server script | 118 // Get path to python server script |
| 115 FilePath testserver_path; | 119 FilePath testserver_path; |
| 116 if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_path)) { | 120 if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_path)) { |
| 117 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; | 121 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; |
| 118 return false; | 122 return false; |
| 119 } | 123 } |
| 120 testserver_path = testserver_path | 124 testserver_path = testserver_path |
| 121 .Append(FILE_PATH_LITERAL("net")) | 125 .Append(FILE_PATH_LITERAL("net")) |
| 122 .Append(FILE_PATH_LITERAL("tools")) | 126 .Append(FILE_PATH_LITERAL("tools")) |
| 123 .Append(FILE_PATH_LITERAL("testserver")) | 127 .Append(FILE_PATH_LITERAL("testserver")) |
| 124 .Append(FILE_PATH_LITERAL("testserver.py")); | 128 .Append(FILE_PATH_LITERAL("testserver.py")); |
| 125 | 129 |
| 126 if (!SetPythonPath()) | 130 if (!SetPythonPath()) { |
| 131 LOG(ERROR) << "Failed to set Python path"; |
| 127 return false; | 132 return false; |
| 133 } |
| 128 | 134 |
| 129 if (!LaunchPython(testserver_path)) | 135 if (!LaunchPython(testserver_path)) { |
| 136 LOG(ERROR) << "Failed to launch Python test server"; |
| 130 return false; | 137 return false; |
| 138 } |
| 131 | 139 |
| 132 if (!WaitToStart()) { | 140 if (!WaitToStart()) { |
| 133 Stop(); | 141 Stop(); |
| 142 LOG(ERROR) << "Failed in WaitToStart()"; |
| 134 return false; | 143 return false; |
| 135 } | 144 } |
| 136 | 145 |
| 137 allowed_port_.reset(new ScopedPortException(host_port_pair_.port())); | 146 allowed_port_.reset(new ScopedPortException(host_port_pair_.port())); |
| 138 | 147 |
| 139 started_ = true; | 148 started_ = true; |
| 140 return true; | 149 return true; |
| 141 } | 150 } |
| 142 | 151 |
| 143 bool TestServer::Stop() { | 152 bool TestServer::Stop() { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 394 |
| 386 const char kBulkCipherSwitch[] = "ssl-bulk-cipher"; | 395 const char kBulkCipherSwitch[] = "ssl-bulk-cipher"; |
| 387 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_RC4) | 396 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_RC4) |
| 388 command_line->AppendSwitchASCII(kBulkCipherSwitch, "rc4"); | 397 command_line->AppendSwitchASCII(kBulkCipherSwitch, "rc4"); |
| 389 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_AES128) | 398 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_AES128) |
| 390 command_line->AppendSwitchASCII(kBulkCipherSwitch, "aes128"); | 399 command_line->AppendSwitchASCII(kBulkCipherSwitch, "aes128"); |
| 391 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_AES256) | 400 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_AES256) |
| 392 command_line->AppendSwitchASCII(kBulkCipherSwitch, "aes256"); | 401 command_line->AppendSwitchASCII(kBulkCipherSwitch, "aes256"); |
| 393 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_3DES) | 402 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_3DES) |
| 394 command_line->AppendSwitchASCII(kBulkCipherSwitch, "3des"); | 403 command_line->AppendSwitchASCII(kBulkCipherSwitch, "3des"); |
| 404 |
| 405 if (https_options_.use_tls_srp) |
| 406 command_line->AppendSwitch("use-tls-srp"); |
| 407 if (https_options_.only_tls_srp) |
| 408 command_line->AppendSwitch("only-tls-srp"); |
| 395 } | 409 } |
| 396 | 410 |
| 397 return true; | 411 return true; |
| 398 } | 412 } |
| 399 | 413 |
| 400 } // namespace net | 414 } // namespace net |
| OLD | NEW |