summaryrefslogtreecommitdiffstats
path: root/net/test/test_server.h
diff options
context:
space:
mode:
authordavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-07 01:10:02 +0000
committerdavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-07 01:10:02 +0000
commit8df162ae8daedfa09971f7b59420212df505a2b7 (patch)
treeb7e71c3ce4d3f4dae7735deb8c0b2d9f046ea582 /net/test/test_server.h
parent29810ee54b8cd8b3fd0177c48daffc1c85a94d65 (diff)
downloadchromium_src-8df162ae8daedfa09971f7b59420212df505a2b7.zip
chromium_src-8df162ae8daedfa09971f7b59420212df505a2b7.tar.gz
chromium_src-8df162ae8daedfa09971f7b59420212df505a2b7.tar.bz2
Add rudimentary support for client auth in testserver.py and unit tests
Nothing fancy for now. Just some tests that ERR_SSL_CLIENT_AUTH_CERT_NEEDED is returned from the socket layer, and that URLRequest requests a certificate. R=wtc BUG=51132,51127 TEST=SSLClientSocketTest.ConnectClientAuthNoCert,HTTPRequestTest.ClientAuthTest Review URL: http://codereview.chromium.org/3014055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test/test_server.h')
-rw-r--r--net/test/test_server.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/net/test/test_server.h b/net/test/test_server.h
index 3b21339..989e38d 100644
--- a/net/test/test_server.h
+++ b/net/test/test_server.h
@@ -76,6 +76,13 @@ class TestServerLauncher {
FilePath GetDocumentRootPath() { return document_root_dir_; }
+ // When Start is called, if protocol is HTTPS and ssl_client_auth_ is true,
+ // the server will request a client certificate on each connection. Must be
+ // called before Start to take effect.
+ void set_ssl_client_auth(bool ssl_client_auth) {
+ ssl_client_auth_ = ssl_client_auth;
+ }
+
// Issuer name of the root cert that should be trusted for the test to work.
static const wchar_t kCertIssuerName[];
@@ -123,6 +130,8 @@ class TestServerLauncher {
scoped_refptr<X509Certificate> cert_;
#endif
+ bool ssl_client_auth_;
+
DISALLOW_COPY_AND_ASSIGN(TestServerLauncher);
};
@@ -262,6 +271,22 @@ class HTTPSTestServer : public HTTPTestServer {
return test_server;
}
+ // Create a server which requests SSL client auth
+ static scoped_refptr<HTTPSTestServer> CreateClientAuthServer(
+ const std::wstring& document_root) {
+ scoped_refptr<HTTPSTestServer> test_server = new HTTPSTestServer();
+ FilePath docroot = FilePath::FromWStringHack(document_root);
+ FilePath certpath = test_server->launcher_.GetOKCertPath();
+ test_server->launcher_.set_ssl_client_auth(true);
+ if (!test_server->Start(net::TestServerLauncher::ProtoHTTP,
+ net::TestServerLauncher::kHostName,
+ net::TestServerLauncher::kOKHTTPSPort,
+ docroot, certpath, std::wstring())) {
+ return NULL;
+ }
+ return test_server;
+ }
+
// Create a server with an up to date certificate for the wrong hostname
// for this host
static scoped_refptr<HTTPSTestServer> CreateMismatchedServer(