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

Side by Side Diff: net/base/ssl_test_util.h

Issue 16207: Make ssl_client_socket_unittest use a local server (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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
« no previous file with comments | « net/base/ssl_client_socket_unittest.cc ('k') | net/base/ssl_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_BASE_SSL_TEST_UTIL_H_ 5 #ifndef NET_BASE_SSL_TEST_UTIL_H_
6 #define NET_BASE_SSL_TEST_UTIL_H_ 6 #define NET_BASE_SSL_TEST_UTIL_H_
7 7
8 #include <string>
9
10 #include "base/file_path.h"
11 #include "base/process_util.h"
12 #include "base/ref_counted.h"
8 #include "build/build_config.h" 13 #include "build/build_config.h"
9 14
10 #include "base/file_path.h" 15 // TODO(dkegel): share this between net/base and
11
12 // TODO(dkegel): share this between net/base and
13 // chrome/browser without putting it in net.lib 16 // chrome/browser without putting it in net.lib
14 17
15 class SSLTestUtil { 18 namespace net {
19
20 // This object bounds the lifetime of an external python-based HTTP/HTTPS/FTP
21 // server that can provide various responses useful for testing.
22 // A few basic convenience methods are provided, but no
23 // URL handling methods (those belong at a higher layer, e.g. in
24 // url_request_unittest.h).
25
26 class TestServerLauncher {
16 public: 27 public:
17 SSLTestUtil(); 28 TestServerLauncher();
18 29
19 ~SSLTestUtil(); 30 virtual ~TestServerLauncher();
20 31
21 FilePath GetRootCertPath(); 32 enum Protocol {
33 ProtoHTTP, ProtoFTP
34 };
22 35
36 // Start src/net/tools/test_server/test_server.py and
37 // ask it to serve the given protocol.
38 // If protocol is HTTP, and cert_path is not empty, serves HTTPS.
39 // Returns true on success, false if files not found or root cert
40 // not trusted.
41 bool Start(Protocol protocol,
42 const std::string& host_name, int port,
43 const FilePath& document_root,
44 const FilePath& cert_path);
45
46 // Stop the server started by Start().
47 void Stop();
48
49 // Paths to a good, an expired, and an invalid server certificate
50 // (use as arguments to Start()).
23 FilePath GetOKCertPath(); 51 FilePath GetOKCertPath();
52 FilePath GetExpiredCertPath();
24 53
25 FilePath GetExpiredCertPath(); 54 // Issuer name of the root cert that should be trusted for the test to work.
55 static const wchar_t kCertIssuerName[];
26 56
27 // Hostname to use for test server 57 // Hostname to use for test server
28 static const char kHostName[]; 58 static const char kHostName[];
29 59
60 // Different hostname to use for test server (that still resolves to same IP)
61 static const char kMismatchedHostName[];
62
30 // Port to use for test server 63 // Port to use for test server
31 static const int kOKHTTPSPort; 64 static const int kOKHTTPSPort;
32 65
33 // Port to use for bad test server 66 // Port to use for bad test server
34 static const int kBadHTTPSPort; 67 static const int kBadHTTPSPort;
35 68
36 // Issuer name of the cert that should be trusted for the test to work. 69 private:
37 static const wchar_t kCertIssuerName[]; 70 // Wait a while for the server to start, return whether
71 // we were able to make a connection to it.
72 bool Wait(const std::string& host_name, int port);
73
74 // Append to PYTHONPATH so Python can find pyftpdlib and tlslite.
75 void SetPythonPath();
76
77 // Path to our test root certificate.
78 FilePath GetRootCertPath();
38 79
39 // Returns false if our test root certificate is not trusted. 80 // Returns false if our test root certificate is not trusted.
40 bool CheckCATrusted(); 81 bool CheckCATrusted();
41 82
42 private: 83 FilePath data_dir_;
84
43 FilePath cert_dir_; 85 FilePath cert_dir_;
44 86
87 FilePath python_runtime_;
88
89 base::ProcessHandle process_handle_;
90
45 #if defined(OS_LINUX) 91 #if defined(OS_LINUX)
46 struct PrivateCERTCertificate; 92 struct PrivateCERTCertificate;
47 PrivateCERTCertificate *cert_; 93 PrivateCERTCertificate *cert_;
48 #endif 94 #endif
49 95
50 DISALLOW_COPY_AND_ASSIGN(SSLTestUtil); 96 DISALLOW_COPY_AND_ASSIGN(TestServerLauncher);
51 }; 97 };
52 98
53 #endif // NET_BASE_SSL_TEST_UTIL_H_ 99 }
100
101 #endif // NET_BASE_SSL_TEST_UTIL_H_
102
OLDNEW
« no previous file with comments | « net/base/ssl_client_socket_unittest.cc ('k') | net/base/ssl_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698