Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1696)

Side by Side Diff: net/test/spawned_test_server/base_test_server.h

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef NET_TEST_SPAWNED_TEST_SERVER_BASE_TEST_SERVER_H_ 5 #ifndef NET_TEST_SPAWNED_TEST_SERVER_BASE_TEST_SERVER_H_
6 #define NET_TEST_SPAWNED_TEST_SERVER_BASE_TEST_SERVER_H_ 6 #define NET_TEST_SPAWNED_TEST_SERVER_BASE_TEST_SERVER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // Container for various options to control how the HTTPS or WSS server is 46 // Container for various options to control how the HTTPS or WSS server is
47 // initialized. 47 // initialized.
48 struct SSLOptions { 48 struct SSLOptions {
49 enum ServerCertificate { 49 enum ServerCertificate {
50 CERT_OK, 50 CERT_OK,
51 51
52 // CERT_AUTO causes the testserver to generate a test certificate issued 52 // CERT_AUTO causes the testserver to generate a test certificate issued
53 // by "Testing CA" (see net/data/ssl/certificates/ocsp-test-root.pem). 53 // by "Testing CA" (see net/data/ssl/certificates/ocsp-test-root.pem).
54 CERT_AUTO, 54 CERT_AUTO,
55
56 CERT_MISMATCHED_NAME, 55 CERT_MISMATCHED_NAME,
57 CERT_EXPIRED, 56 CERT_EXPIRED,
58 // Cross-signed certificate to test PKIX path building. Contains an 57 // Cross-signed certificate to test PKIX path building. Contains an
59 // intermediate cross-signed by an unknown root, while the client (via 58 // intermediate cross-signed by an unknown root, while the client (via
60 // TestRootStore) is expected to have a self-signed version of the 59 // TestRootStore) is expected to have a self-signed version of the
61 // intermediate. 60 // intermediate.
62 CERT_CHAIN_WRONG_ROOT, 61 CERT_CHAIN_WRONG_ROOT,
63 }; 62 };
64 63
65 // OCSPStatus enumerates the types of OCSP response that the testserver 64 // OCSPStatus enumerates the types of OCSP response that the testserver
66 // can produce. 65 // can produce.
67 enum OCSPStatus { 66 enum OCSPStatus {
68 OCSP_OK, 67 OCSP_OK,
69 OCSP_REVOKED, 68 OCSP_REVOKED,
70 OCSP_INVALID, 69 OCSP_INVALID,
71 OCSP_UNAUTHORIZED, 70 OCSP_UNAUTHORIZED,
72 OCSP_UNKNOWN, 71 OCSP_UNKNOWN,
73 }; 72 };
74 73
75 // Bitmask of key exchange algorithms that the test server supports and that 74 // Bitmask of key exchange algorithms that the test server supports and that
76 // can be selectively enabled or disabled. 75 // can be selectively enabled or disabled.
77 enum KeyExchange { 76 enum KeyExchange {
78 // Special value used to indicate that any algorithm the server supports 77 // Special value used to indicate that any algorithm the server supports
79 // is acceptable. Preferred over explicitly OR-ing all key exchange 78 // is acceptable. Preferred over explicitly OR-ing all key exchange
80 // algorithms. 79 // algorithms.
81 KEY_EXCHANGE_ANY = 0, 80 KEY_EXCHANGE_ANY = 0,
82 81 KEY_EXCHANGE_RSA = (1 << 0),
83 KEY_EXCHANGE_RSA = (1 << 0),
84 KEY_EXCHANGE_DHE_RSA = (1 << 1), 82 KEY_EXCHANGE_DHE_RSA = (1 << 1),
85 }; 83 };
86 84
87 // Bitmask of bulk encryption algorithms that the test server supports 85 // Bitmask of bulk encryption algorithms that the test server supports
88 // and that can be selectively enabled or disabled. 86 // and that can be selectively enabled or disabled.
89 enum BulkCipher { 87 enum BulkCipher {
90 // Special value used to indicate that any algorithm the server supports 88 // Special value used to indicate that any algorithm the server supports
91 // is acceptable. Preferred over explicitly OR-ing all ciphers. 89 // is acceptable. Preferred over explicitly OR-ing all ciphers.
92 BULK_CIPHER_ANY = 0, 90 BULK_CIPHER_ANY = 0,
93 91 BULK_CIPHER_RC4 = (1 << 0),
94 BULK_CIPHER_RC4 = (1 << 0),
95 BULK_CIPHER_AES128 = (1 << 1), 92 BULK_CIPHER_AES128 = (1 << 1),
96 BULK_CIPHER_AES256 = (1 << 2), 93 BULK_CIPHER_AES256 = (1 << 2),
97 94
98 // NOTE: 3DES support in the Python test server has external 95 // NOTE: 3DES support in the Python test server has external
99 // dependencies and not be available on all machines. Clients may not 96 // dependencies and not be available on all machines. Clients may not
100 // be able to connect if only 3DES is specified. 97 // be able to connect if only 3DES is specified.
101 BULK_CIPHER_3DES = (1 << 3), 98 BULK_CIPHER_3DES = (1 << 3),
102 }; 99 };
103 100
104 // NOTE: the values of these enumerators are passed to the the Python test 101 // NOTE: the values of these enumerators are passed to the the Python test
105 // server. Do not change them. 102 // server. Do not change them.
106 enum TLSIntolerantLevel { 103 enum TLSIntolerantLevel {
107 TLS_INTOLERANT_NONE = 0, 104 TLS_INTOLERANT_NONE = 0,
108 TLS_INTOLERANT_ALL = 1, // Intolerant of all TLS versions. 105 TLS_INTOLERANT_ALL = 1, // Intolerant of all TLS versions.
109 TLS_INTOLERANT_TLS1_1 = 2, // Intolerant of TLS 1.1 or higher. 106 TLS_INTOLERANT_TLS1_1 = 2, // Intolerant of TLS 1.1 or higher.
110 TLS_INTOLERANT_TLS1_2 = 3, // Intolerant of TLS 1.2 or higher. 107 TLS_INTOLERANT_TLS1_2 = 3, // Intolerant of TLS 1.2 or higher.
111 }; 108 };
112 109
113 // Initialize a new SSLOptions using CERT_OK as the certificate. 110 // Initialize a new SSLOptions using CERT_OK as the certificate.
114 SSLOptions(); 111 SSLOptions();
115 112
116 // Initialize a new SSLOptions that will use the specified certificate. 113 // Initialize a new SSLOptions that will use the specified certificate.
117 explicit SSLOptions(ServerCertificate cert); 114 explicit SSLOptions(ServerCertificate cert);
118 ~SSLOptions(); 115 ~SSLOptions();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 bool staple_ocsp_response; 181 bool staple_ocsp_response;
185 182
186 // Whether to enable NPN support. 183 // Whether to enable NPN support.
187 bool enable_npn; 184 bool enable_npn;
188 }; 185 };
189 186
190 // Pass as the 'host' parameter during construction to server on 127.0.0.1 187 // Pass as the 'host' parameter during construction to server on 127.0.0.1
191 static const char kLocalhost[]; 188 static const char kLocalhost[];
192 189
193 // Initialize a TestServer listening on a specific host (IP or hostname). 190 // Initialize a TestServer listening on a specific host (IP or hostname).
194 BaseTestServer(Type type, const std::string& host); 191 BaseTestServer(Type type, const std::string& host);
195 192
196 // Initialize a TestServer with a specific set of SSLOptions for HTTPS or WSS. 193 // Initialize a TestServer with a specific set of SSLOptions for HTTPS or WSS.
197 BaseTestServer(Type type, const SSLOptions& ssl_options); 194 BaseTestServer(Type type, const SSLOptions& ssl_options);
198 195
199 // Returns the host port pair used by current Python based test server only 196 // Returns the host port pair used by current Python based test server only
200 // if the server is started. 197 // if the server is started.
201 const HostPortPair& host_port_pair() const; 198 const HostPortPair& host_port_pair() const;
202 199
203 const base::FilePath& document_root() const { return document_root_; } 200 const base::FilePath& document_root() const { return document_root_; }
204 const base::DictionaryValue& server_data() const; 201 const base::DictionaryValue& server_data() const;
205 std::string GetScheme() const; 202 std::string GetScheme() const;
206 bool GetAddressList(AddressList* address_list) const WARN_UNUSED_RESULT; 203 bool GetAddressList(AddressList* address_list) const WARN_UNUSED_RESULT;
207 204
208 GURL GetURL(const std::string& path) const; 205 GURL GetURL(const std::string& path) const;
209 206
210 GURL GetURLWithUser(const std::string& path, 207 GURL GetURLWithUser(const std::string& path, const std::string& user) const;
211 const std::string& user) const;
212 208
213 GURL GetURLWithUserAndPassword(const std::string& path, 209 GURL GetURLWithUserAndPassword(const std::string& path,
214 const std::string& user, 210 const std::string& user,
215 const std::string& password) const; 211 const std::string& password) const;
216 212
217 static bool GetFilePathWithReplacements( 213 static bool GetFilePathWithReplacements(
218 const std::string& original_path, 214 const std::string& original_path,
219 const std::vector<StringPair>& text_to_replace, 215 const std::vector<StringPair>& text_to_replace,
220 std::string* replacement_path); 216 std::string* replacement_path);
221 217
(...skipping 23 matching lines...) Expand all
245 void SetResourcePath(const base::FilePath& document_root, 241 void SetResourcePath(const base::FilePath& document_root,
246 const base::FilePath& certificates_dir); 242 const base::FilePath& certificates_dir);
247 243
248 // Parses the server data read from the test server. Returns true 244 // Parses the server data read from the test server. Returns true
249 // on success. 245 // on success.
250 bool ParseServerData(const std::string& server_data) WARN_UNUSED_RESULT; 246 bool ParseServerData(const std::string& server_data) WARN_UNUSED_RESULT;
251 247
252 // Generates a DictionaryValue with the arguments for launching the external 248 // Generates a DictionaryValue with the arguments for launching the external
253 // Python test server. 249 // Python test server.
254 bool GenerateArguments(base::DictionaryValue* arguments) const 250 bool GenerateArguments(base::DictionaryValue* arguments) const
255 WARN_UNUSED_RESULT; 251 WARN_UNUSED_RESULT;
256 252
257 // Subclasses can override this to add arguments that are specific to their 253 // Subclasses can override this to add arguments that are specific to their
258 // own test servers. 254 // own test servers.
259 virtual bool GenerateAdditionalArguments( 255 virtual bool GenerateAdditionalArguments(
260 base::DictionaryValue* arguments) const WARN_UNUSED_RESULT; 256 base::DictionaryValue* arguments) const WARN_UNUSED_RESULT;
261 257
262 private: 258 private:
263 void Init(const std::string& host); 259 void Init(const std::string& host);
264 260
265 // Marks the root certificate of an HTTPS test server as trusted for 261 // Marks the root certificate of an HTTPS test server as trusted for
(...skipping 25 matching lines...) Expand all
291 bool log_to_console_; 287 bool log_to_console_;
292 288
293 scoped_ptr<ScopedPortException> allowed_port_; 289 scoped_ptr<ScopedPortException> allowed_port_;
294 290
295 DISALLOW_COPY_AND_ASSIGN(BaseTestServer); 291 DISALLOW_COPY_AND_ASSIGN(BaseTestServer);
296 }; 292 };
297 293
298 } // namespace net 294 } // namespace net
299 295
300 #endif // NET_TEST_SPAWNED_TEST_SERVER_BASE_TEST_SERVER_H_ 296 #endif // NET_TEST_SPAWNED_TEST_SERVER_BASE_TEST_SERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698