summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-03 03:06:40 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-03 03:06:40 +0000
commita3c4ef3bf3bfc924680ecb827e9f43c4c2c45ee2 (patch)
tree23bf3d746d9350f612338f2ba924bb3d1ab1675a /net
parent0f247aea86a7b558996df6ad5814ba96d8990c3a (diff)
downloadchromium_src-a3c4ef3bf3bfc924680ecb827e9f43c4c2c45ee2.zip
chromium_src-a3c4ef3bf3bfc924680ecb827e9f43c4c2c45ee2.tar.gz
chromium_src-a3c4ef3bf3bfc924680ecb827e9f43c4c2c45ee2.tar.bz2
Add --https-cert option to run_testserver.
--https-cert has three valid values: ok: A valid certificate is supplied. mismatched-name: A certificate with an invalid name is supplied. expired: An expired certificate is supplied. Review URL: http://codereview.chromium.org/7825030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99523 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/tools/testserver/run_testserver.cc37
1 files changed, 31 insertions, 6 deletions
diff --git a/net/tools/testserver/run_testserver.cc b/net/tools/testserver/run_testserver.cc
index 00a765d..53f60d1 100644
--- a/net/tools/testserver/run_testserver.cc
+++ b/net/tools/testserver/run_testserver.cc
@@ -14,7 +14,8 @@
#include "net/test/test_server.h"
static void PrintUsage() {
- printf("run_testserver --doc-root=relpath [--http|--https|--ftp|--sync]\n");
+ printf("run_testserver --doc-root=relpath [--http|--https|--ftp|--sync]\n"
+ " [--https-cert=ok|mismatched-name|expired]\n");
printf("(NOTE: relpath should be relative to the 'src' directory)\n");
}
@@ -52,6 +53,25 @@ int main(int argc, const char* argv[]) {
server_type = net::TestServer::TYPE_SYNC;
}
+ net::TestServer::HTTPSOptions https_options;
+ if (command_line->HasSwitch("https-cert")) {
+ server_type = net::TestServer::TYPE_HTTPS;
+ std::string cert_option = command_line->GetSwitchValueASCII("https-cert");
+ if (cert_option == "ok") {
+ https_options.server_certificate = net::TestServer::HTTPSOptions::CERT_OK;
+ } else if (cert_option == "mismatched-name") {
+ https_options.server_certificate =
+ net::TestServer::HTTPSOptions::CERT_MISMATCHED_NAME;
+ } else if (cert_option == "expired") {
+ https_options.server_certificate =
+ net::TestServer::HTTPSOptions::CERT_EXPIRED;
+ } else {
+ printf("Error: --https-cert has invalid value %s\n", cert_option.c_str());
+ PrintUsage();
+ return -1;
+ }
+ }
+
FilePath doc_root = command_line->GetSwitchValuePath("doc-root");
if ((server_type != net::TestServer::TYPE_SYNC) && doc_root.empty()) {
printf("Error: --doc-root must be specified\n");
@@ -59,20 +79,25 @@ int main(int argc, const char* argv[]) {
return -1;
}
- net::TestServer test_server(server_type, doc_root);
- if (!test_server.Start()) {
+ scoped_ptr<net::TestServer> test_server;
+ if (server_type == net::TestServer::TYPE_HTTPS)
+ test_server.reset(new net::TestServer(https_options, doc_root));
+ else
+ test_server.reset(new net::TestServer(server_type, doc_root));
+
+ if (!test_server->Start()) {
printf("Error: failed to start test server. Exiting.\n");
return -1;
}
- if (!file_util::DirectoryExists(test_server.document_root())) {
+ if (!file_util::DirectoryExists(test_server->document_root())) {
printf("Error: invalid doc root: \"%s\" does not exist!\n",
- UTF16ToUTF8(test_server.document_root().LossyDisplayName()).c_str());
+ UTF16ToUTF8(test_server->document_root().LossyDisplayName()).c_str());
return -1;
}
printf("testserver running at %s (type ctrl+c to exit)\n",
- test_server.host_port_pair().ToString().c_str());
+ test_server->host_port_pair().ToString().c_str());
message_loop.Run();
return 0;