OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_TEST_SERVER_H_ | 5 #ifndef NET_TEST_TEST_SERVER_H_ |
6 #define NET_TEST_TEST_SERVER_H_ | 6 #define NET_TEST_TEST_SERVER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 | 14 |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/file_path.h" | 16 #include "base/file_path.h" |
17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
18 #include "base/process_util.h" | 18 #include "base/process_util.h" |
19 #include "net/base/host_port_pair.h" | 19 #include "net/base/host_port_pair.h" |
20 | 20 |
21 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
22 #include "base/scoped_handle_win.h" | 22 #include "base/scoped_handle_win.h" |
23 #endif | 23 #endif |
24 | 24 |
25 #if defined(USE_NSS) | |
26 #include "base/ref_counted.h" | |
27 #include "net/base/x509_certificate.h" | |
28 #endif | |
29 | |
30 class CommandLine; | 25 class CommandLine; |
31 class GURL; | 26 class GURL; |
32 | 27 |
33 namespace net { | 28 namespace net { |
34 | 29 |
35 class AddressList; | 30 class AddressList; |
36 | 31 |
37 // This object bounds the lifetime of an external python-based HTTP/FTP server | 32 // This object bounds the lifetime of an external python-based HTTP/FTP server |
38 // that can provide various responses useful for testing. | 33 // that can provide various responses useful for testing. |
39 class TestServer { | 34 class TestServer { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 137 |
143 // Launches the Python test server. Returns true on success. | 138 // Launches the Python test server. Returns true on success. |
144 bool LaunchPython(const FilePath& testserver_path) WARN_UNUSED_RESULT; | 139 bool LaunchPython(const FilePath& testserver_path) WARN_UNUSED_RESULT; |
145 | 140 |
146 // Waits for the server to start. Returns true on success. | 141 // Waits for the server to start. Returns true on success. |
147 bool WaitToStart() WARN_UNUSED_RESULT; | 142 bool WaitToStart() WARN_UNUSED_RESULT; |
148 | 143 |
149 // Returns path to the root certificate. | 144 // Returns path to the root certificate. |
150 FilePath GetRootCertificatePath(); | 145 FilePath GetRootCertificatePath(); |
151 | 146 |
152 // Returns false if our test root certificate is not trusted. | |
153 bool CheckCATrusted() WARN_UNUSED_RESULT; | |
154 | |
155 // Load the test root cert, if it hasn't been loaded yet. | 147 // Load the test root cert, if it hasn't been loaded yet. |
156 bool LoadTestRootCert() WARN_UNUSED_RESULT; | 148 bool LoadTestRootCert() WARN_UNUSED_RESULT; |
157 | 149 |
158 // Add the command line arguments for the Python test server to | 150 // Add the command line arguments for the Python test server to |
159 // |command_line|. Return true on success. | 151 // |command_line|. Return true on success. |
160 bool AddCommandLineArguments(CommandLine* command_line) const; | 152 bool AddCommandLineArguments(CommandLine* command_line) const; |
161 | 153 |
162 // Document root of the test server. | 154 // Document root of the test server. |
163 FilePath document_root_; | 155 FilePath document_root_; |
164 | 156 |
(...skipping 19 matching lines...) Expand all Loading... |
184 | 176 |
185 #if defined(OS_POSIX) | 177 #if defined(OS_POSIX) |
186 // The file descriptor the child writes to when it starts. | 178 // The file descriptor the child writes to when it starts. |
187 int child_fd_; | 179 int child_fd_; |
188 file_util::ScopedFD child_fd_closer_; | 180 file_util::ScopedFD child_fd_closer_; |
189 #endif | 181 #endif |
190 | 182 |
191 // If |type_| is TYPE_HTTPS, the TLS settings to use for the test server. | 183 // If |type_| is TYPE_HTTPS, the TLS settings to use for the test server. |
192 HTTPSOptions https_options_; | 184 HTTPSOptions https_options_; |
193 | 185 |
194 #if defined(USE_NSS) | |
195 scoped_refptr<X509Certificate> cert_; | |
196 #endif | |
197 | |
198 Type type_; | 186 Type type_; |
199 | 187 |
200 // Has the server been started? | 188 // Has the server been started? |
201 bool started_; | 189 bool started_; |
202 | 190 |
203 DISALLOW_COPY_AND_ASSIGN(TestServer); | 191 DISALLOW_COPY_AND_ASSIGN(TestServer); |
204 }; | 192 }; |
205 | 193 |
206 } // namespace net | 194 } // namespace net |
207 | 195 |
208 #endif // NET_TEST_TEST_SERVER_H_ | 196 #endif // NET_TEST_TEST_SERVER_H_ |
OLD | NEW |