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

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

Issue 10878003: Refactoring for merging WebSocket test server to net::TestServer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reflect Ryan's review Created 8 years, 4 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 (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 #ifndef NET_TEST_BASE_TEST_SERVER_H_ 5 #ifndef NET_TEST_BASE_TEST_SERVER_H_
6 #define NET_TEST_BASE_TEST_SERVER_H_ 6 #define NET_TEST_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 17 matching lines...) Expand all
28 // The base class of Test server implementation. 28 // The base class of Test server implementation.
29 class BaseTestServer { 29 class BaseTestServer {
30 public: 30 public:
31 typedef std::pair<std::string, std::string> StringPair; 31 typedef std::pair<std::string, std::string> StringPair;
32 32
33 enum Type { 33 enum Type {
34 TYPE_FTP, 34 TYPE_FTP,
35 TYPE_GDATA, 35 TYPE_GDATA,
36 TYPE_HTTP, 36 TYPE_HTTP,
37 TYPE_HTTPS, 37 TYPE_HTTPS,
38 TYPE_WS,
Paweł Hajdan Jr. 2012/08/30 08:56:34 This is not obvious (at least to me). Could you ma
Ryan Sleevi 2012/08/30 14:25:46 Given that this enumeration is listing protocol sc
Paweł Hajdan Jr. 2012/08/31 07:51:29 Please add the comment then. "ws" is not that easy
Takashi Toyoshima 2012/09/01 09:07:30 WebSocket or ws. I'm often worried about which is
Paweł Hajdan Jr. 2012/09/04 09:30:11 +1
39 TYPE_WSS,
38 TYPE_SYNC, 40 TYPE_SYNC,
39 TYPE_TCP_ECHO, 41 TYPE_TCP_ECHO,
40 TYPE_UDP_ECHO, 42 TYPE_UDP_ECHO,
41 }; 43 };
42 44
43 // Container for various options to control how the HTTPS server is 45 // Container for various options to control how the HTTPS or WSS server is
44 // initialized. 46 // initialized.
45 struct HTTPSOptions { 47 struct SSLOptions {
46 enum ServerCertificate { 48 enum ServerCertificate {
47 CERT_OK, 49 CERT_OK,
48 50
49 // CERT_AUTO causes the testserver to generate a test certificate issued 51 // CERT_AUTO causes the testserver to generate a test certificate issued
50 // by "Testing CA" (see net/data/ssl/certificates/ocsp-test-root.pem). 52 // by "Testing CA" (see net/data/ssl/certificates/ocsp-test-root.pem).
51 CERT_AUTO, 53 CERT_AUTO,
52 54
53 CERT_MISMATCHED_NAME, 55 CERT_MISMATCHED_NAME,
54 CERT_EXPIRED, 56 CERT_EXPIRED,
55 // Cross-signed certificate to test PKIX path building. Contains an 57 // Cross-signed certificate to test PKIX path building. Contains an
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 90
89 // NOTE: the values of these enumerators are passed to the the Python test 91 // NOTE: the values of these enumerators are passed to the the Python test
90 // server. Do not change them. 92 // server. Do not change them.
91 enum TLSIntolerantLevel { 93 enum TLSIntolerantLevel {
92 TLS_INTOLERANT_NONE = 0, 94 TLS_INTOLERANT_NONE = 0,
93 TLS_INTOLERANT_ALL = 1, // Intolerant of all TLS versions. 95 TLS_INTOLERANT_ALL = 1, // Intolerant of all TLS versions.
94 TLS_INTOLERANT_TLS1_1 = 2, // Intolerant of TLS 1.1 or higher. 96 TLS_INTOLERANT_TLS1_1 = 2, // Intolerant of TLS 1.1 or higher.
95 TLS_INTOLERANT_TLS1_2 = 3, // Intolerant of TLS 1.2 or higher. 97 TLS_INTOLERANT_TLS1_2 = 3, // Intolerant of TLS 1.2 or higher.
96 }; 98 };
97 99
98 // Initialize a new HTTPSOptions using CERT_OK as the certificate. 100 // Initialize a new SSLOptions using CERT_OK as the certificate.
99 HTTPSOptions(); 101 SSLOptions();
100 102
101 // Initialize a new HTTPSOptions that will use the specified certificate. 103 // Initialize a new SSLOptions that will use the specified certificate.
102 explicit HTTPSOptions(ServerCertificate cert); 104 explicit SSLOptions(ServerCertificate cert);
103 ~HTTPSOptions(); 105 ~SSLOptions();
104 106
105 // Returns the relative filename of the file that contains the 107 // Returns the relative filename of the file that contains the
106 // |server_certificate|. 108 // |server_certificate|.
107 FilePath GetCertificateFile() const; 109 FilePath GetCertificateFile() const;
108 110
109 // GetOCSPArgument returns the value of any OCSP argument to testserver or 111 // GetOCSPArgument returns the value of any OCSP argument to testserver or
110 // the empty string if there is none. 112 // the empty string if there is none.
111 std::string GetOCSPArgument() const; 113 std::string GetOCSPArgument() const;
112 114
113 // The certificate to use when serving requests. 115 // The certificate to use when serving requests.
(...skipping 30 matching lines...) Expand all
144 146
145 // Pass as the 'host' parameter during construction to server on 127.0.0.1 147 // Pass as the 'host' parameter during construction to server on 127.0.0.1
146 static const char kLocalhost[]; 148 static const char kLocalhost[];
147 149
148 // The auth token to be used for TYPE_GDATA server. 150 // The auth token to be used for TYPE_GDATA server.
149 static const char kGDataAuthToken[]; 151 static const char kGDataAuthToken[];
150 152
151 // Initialize a TestServer listening on a specific host (IP or hostname). 153 // Initialize a TestServer listening on a specific host (IP or hostname).
152 BaseTestServer(Type type, const std::string& host); 154 BaseTestServer(Type type, const std::string& host);
153 155
154 // Initialize a HTTPS TestServer with a specific set of HTTPSOptions. 156 // Initialize a TestServer with a specific set of SSLOptions for HTTPS or WSS.
155 explicit BaseTestServer(const HTTPSOptions& https_options); 157 explicit BaseTestServer(Type type, const SSLOptions& ssl_options);
156 158
157 // Returns the host port pair used by current Python based test server only 159 // Returns the host port pair used by current Python based test server only
158 // if the server is started. 160 // if the server is started.
159 const HostPortPair& host_port_pair() const; 161 const HostPortPair& host_port_pair() const;
160 162
161 const FilePath& document_root() const { return document_root_; } 163 const FilePath& document_root() const { return document_root_; }
162 const base::DictionaryValue& server_data() const; 164 const base::DictionaryValue& server_data() const;
163 std::string GetScheme() const; 165 std::string GetScheme() const;
164 bool GetAddressList(AddressList* address_list) const WARN_UNUSED_RESULT; 166 bool GetAddressList(AddressList* address_list) const WARN_UNUSED_RESULT;
165 167
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 220
219 // Directory that contains the SSL certificates. 221 // Directory that contains the SSL certificates.
220 FilePath certificates_dir_; 222 FilePath certificates_dir_;
221 223
222 // Address the test server listens on. 224 // Address the test server listens on.
223 HostPortPair host_port_pair_; 225 HostPortPair host_port_pair_;
224 226
225 // Holds the data sent from the server (e.g., port number). 227 // Holds the data sent from the server (e.g., port number).
226 scoped_ptr<base::DictionaryValue> server_data_; 228 scoped_ptr<base::DictionaryValue> server_data_;
227 229
228 // If |type_| is TYPE_HTTPS, the TLS settings to use for the test server. 230 // If |type_| is TYPE_HTTPS or TYPE_WSS, the TLS settings to use for the test
229 HTTPSOptions https_options_; 231 // server.
232 SSLOptions ssl_options_;
230 233
231 Type type_; 234 Type type_;
232 235
233 // Has the server been started? 236 // Has the server been started?
234 bool started_; 237 bool started_;
235 238
236 // Enables logging of the server to the console. 239 // Enables logging of the server to the console.
237 bool log_to_console_; 240 bool log_to_console_;
238 241
239 scoped_ptr<ScopedPortException> allowed_port_; 242 scoped_ptr<ScopedPortException> allowed_port_;
240 243
241 DISALLOW_COPY_AND_ASSIGN(BaseTestServer); 244 DISALLOW_COPY_AND_ASSIGN(BaseTestServer);
242 }; 245 };
243 246
244 } // namespace net 247 } // namespace net
245 248
246 #endif // NET_TEST_BASE_TEST_SERVER_H_ 249 #endif // NET_TEST_BASE_TEST_SERVER_H_
247 250
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698