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" |
11 #include "base/files/file_path.h" | |
11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
12 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "net/base/address_list.h" | 17 #include "net/base/address_list.h" |
17 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
20 #include "net/base/test_completion_callback.h" | 21 #include "net/base/test_completion_callback.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
34 BaseTestServer::SSLOptions::CERT_MISMATCHED_NAME || | 35 BaseTestServer::SSLOptions::CERT_MISMATCHED_NAME || |
35 options.server_certificate == | 36 options.server_certificate == |
36 BaseTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN) { | 37 BaseTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN) { |
37 // For |CERT_MISMATCHED_NAME|, return a different hostname string | 38 // For |CERT_MISMATCHED_NAME|, return a different hostname string |
38 // that resolves to the same hostname. For | 39 // that resolves to the same hostname. For |
39 // |CERT_COMMON_NAME_IS_DOMAIN|, the certificate is issued for | 40 // |CERT_COMMON_NAME_IS_DOMAIN|, the certificate is issued for |
40 // "localhost" instead of "127.0.0.1". | 41 // "localhost" instead of "127.0.0.1". |
41 return "localhost"; | 42 return "localhost"; |
42 } | 43 } |
43 } | 44 } |
44 | |
Ryan Sleevi
2015/08/07 00:14:10
Unnecessary change?
| |
45 // Use the 127.0.0.1 as default. | 45 // Use the 127.0.0.1 as default. |
46 return BaseTestServer::kLocalhost; | 46 return BaseTestServer::kLocalhost; |
47 } | 47 } |
48 | 48 |
49 std::string GetClientCertType(SSLClientCertType type) { | 49 std::string GetClientCertType(SSLClientCertType type) { |
50 switch (type) { | 50 switch (type) { |
51 case CLIENT_CERT_RSA_SIGN: | 51 case CLIENT_CERT_RSA_SIGN: |
52 return "rsa_sign"; | 52 return "rsa_sign"; |
53 case CLIENT_CERT_ECDSA_SIGN: | 53 case CLIENT_CERT_ECDSA_SIGN: |
54 return "ecdsa_sign"; | 54 return "ecdsa_sign"; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 case CERT_COMMON_NAME_IS_DOMAIN: | 142 case CERT_COMMON_NAME_IS_DOMAIN: |
143 return base::FilePath(FILE_PATH_LITERAL("localhost_cert.pem")); | 143 return base::FilePath(FILE_PATH_LITERAL("localhost_cert.pem")); |
144 case CERT_EXPIRED: | 144 case CERT_EXPIRED: |
145 return base::FilePath(FILE_PATH_LITERAL("expired_cert.pem")); | 145 return base::FilePath(FILE_PATH_LITERAL("expired_cert.pem")); |
146 case CERT_CHAIN_WRONG_ROOT: | 146 case CERT_CHAIN_WRONG_ROOT: |
147 // This chain uses its own dedicated test root certificate to avoid | 147 // This chain uses its own dedicated test root certificate to avoid |
148 // side-effects that may affect testing. | 148 // side-effects that may affect testing. |
149 return base::FilePath(FILE_PATH_LITERAL("redundant-server-chain.pem")); | 149 return base::FilePath(FILE_PATH_LITERAL("redundant-server-chain.pem")); |
150 case CERT_AUTO: | 150 case CERT_AUTO: |
151 return base::FilePath(); | 151 return base::FilePath(); |
152 case CERT_EXAMPLE_DOMAIN: | |
153 return base::FilePath(FILE_PATH_LITERAL("example_cert.pem")); | |
154 case CERT_WWW_EXAMPLE_DOMAIN: | |
155 return base::FilePath(FILE_PATH_LITERAL("www_example_cert.pem")); | |
152 default: | 156 default: |
153 NOTREACHED(); | 157 NOTREACHED(); |
154 } | 158 } |
155 return base::FilePath(); | 159 return base::FilePath(); |
156 } | 160 } |
157 | 161 |
158 std::string BaseTestServer::SSLOptions::GetOCSPArgument() const { | 162 std::string BaseTestServer::SSLOptions::GetOCSPArgument() const { |
159 if (server_certificate != CERT_AUTO) | 163 if (server_certificate != CERT_AUTO) |
160 return std::string(); | 164 return std::string(); |
161 | 165 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 | 518 |
515 return GenerateAdditionalArguments(arguments); | 519 return GenerateAdditionalArguments(arguments); |
516 } | 520 } |
517 | 521 |
518 bool BaseTestServer::GenerateAdditionalArguments( | 522 bool BaseTestServer::GenerateAdditionalArguments( |
519 base::DictionaryValue* arguments) const { | 523 base::DictionaryValue* arguments) const { |
520 return true; | 524 return true; |
521 } | 525 } |
522 | 526 |
523 } // namespace net | 527 } // namespace net |
OLD | NEW |