summaryrefslogtreecommitdiffstats
path: root/net/test
diff options
context:
space:
mode:
Diffstat (limited to 'net/test')
-rw-r--r--net/test/base_test_server.cc64
-rw-r--r--net/test/base_test_server.h25
-rw-r--r--net/test/local_test_server.cc15
-rw-r--r--net/test/local_test_server.h5
-rw-r--r--net/test/remote_test_server.cc8
-rw-r--r--net/test/remote_test_server.h5
6 files changed, 69 insertions, 53 deletions
diff --git a/net/test/base_test_server.cc b/net/test/base_test_server.cc
index 4321614..a4d1ff9 100644
--- a/net/test/base_test_server.cc
+++ b/net/test/base_test_server.cc
@@ -28,10 +28,11 @@ namespace net {
namespace {
std::string GetHostname(BaseTestServer::Type type,
- const BaseTestServer::HTTPSOptions& options) {
- if (type == BaseTestServer::TYPE_HTTPS &&
+ const BaseTestServer::SSLOptions& options) {
+ if ((type == BaseTestServer::TYPE_HTTPS ||
+ type == BaseTestServer::TYPE_WSS) &&
options.server_certificate ==
- BaseTestServer::HTTPSOptions::CERT_MISMATCHED_NAME) {
+ BaseTestServer::SSLOptions::CERT_MISMATCHED_NAME) {
// Return a different hostname string that resolves to the same hostname.
return "localhost";
}
@@ -41,37 +42,37 @@ std::string GetHostname(BaseTestServer::Type type,
}
void GetCiphersList(int cipher, base::ListValue* values) {
- if (cipher & BaseTestServer::HTTPSOptions::BULK_CIPHER_RC4)
+ if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_RC4)
values->Append(base::Value::CreateStringValue("rc4"));
- if (cipher & BaseTestServer::HTTPSOptions::BULK_CIPHER_AES128)
+ if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_AES128)
values->Append(base::Value::CreateStringValue("aes128"));
- if (cipher & BaseTestServer::HTTPSOptions::BULK_CIPHER_AES256)
+ if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_AES256)
values->Append(base::Value::CreateStringValue("aes256"));
- if (cipher & BaseTestServer::HTTPSOptions::BULK_CIPHER_3DES)
+ if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_3DES)
values->Append(base::Value::CreateStringValue("3des"));
}
} // namespace
-BaseTestServer::HTTPSOptions::HTTPSOptions()
+BaseTestServer::SSLOptions::SSLOptions()
: server_certificate(CERT_OK),
ocsp_status(OCSP_OK),
request_client_certificate(false),
- bulk_ciphers(HTTPSOptions::BULK_CIPHER_ANY),
+ bulk_ciphers(SSLOptions::BULK_CIPHER_ANY),
record_resume(false),
tls_intolerant(TLS_INTOLERANT_NONE) {}
-BaseTestServer::HTTPSOptions::HTTPSOptions(
- BaseTestServer::HTTPSOptions::ServerCertificate cert)
+BaseTestServer::SSLOptions::SSLOptions(
+ BaseTestServer::SSLOptions::ServerCertificate cert)
: server_certificate(cert),
request_client_certificate(false),
- bulk_ciphers(HTTPSOptions::BULK_CIPHER_ANY),
+ bulk_ciphers(SSLOptions::BULK_CIPHER_ANY),
record_resume(false),
tls_intolerant(TLS_INTOLERANT_NONE) {}
-BaseTestServer::HTTPSOptions::~HTTPSOptions() {}
+BaseTestServer::SSLOptions::~SSLOptions() {}
-FilePath BaseTestServer::HTTPSOptions::GetCertificateFile() const {
+FilePath BaseTestServer::SSLOptions::GetCertificateFile() const {
switch (server_certificate) {
case CERT_OK:
case CERT_MISMATCHED_NAME:
@@ -90,7 +91,7 @@ FilePath BaseTestServer::HTTPSOptions::GetCertificateFile() const {
return FilePath();
}
-std::string BaseTestServer::HTTPSOptions::GetOCSPArgument() const {
+std::string BaseTestServer::SSLOptions::GetOCSPArgument() const {
if (server_certificate != CERT_AUTO)
return "";
@@ -121,12 +122,13 @@ BaseTestServer::BaseTestServer(Type type, const std::string& host)
Init(host);
}
-BaseTestServer::BaseTestServer(const HTTPSOptions& https_options)
- : https_options_(https_options),
- type_(TYPE_HTTPS),
+BaseTestServer::BaseTestServer(Type type, const SSLOptions& ssl_options)
+ : ssl_options_(ssl_options),
+ type_(type),
started_(false),
log_to_console_(false) {
- Init(GetHostname(TYPE_HTTPS, https_options));
+ DCHECK(type == TYPE_HTTPS || type == TYPE_WSS);
+ Init(GetHostname(type, ssl_options));
}
BaseTestServer::~BaseTestServer() {}
@@ -152,6 +154,10 @@ std::string BaseTestServer::GetScheme() const {
return "http";
case TYPE_HTTPS:
return "https";
+ case TYPE_WS:
+ return "ws";
+ case TYPE_WSS:
+ return "wss";
case TYPE_TCP_ECHO:
case TYPE_UDP_ECHO:
default:
@@ -303,7 +309,7 @@ bool BaseTestServer::LoadTestRootCert() const {
bool BaseTestServer::SetupWhenServerStarted() {
DCHECK(host_port_pair_.port());
- if (type_ == TYPE_HTTPS && !LoadTestRootCert())
+ if ((type_ == TYPE_HTTPS || type_ == TYPE_WSS) && !LoadTestRootCert())
return false;
started_ = true;
@@ -339,7 +345,7 @@ bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const {
// Check the certificate arguments of the HTTPS server.
FilePath certificate_path(certificates_dir_);
- FilePath certificate_file(https_options_.GetCertificateFile());
+ FilePath certificate_file(ssl_options_.GetCertificateFile());
if (!certificate_file.value().empty()) {
certificate_path = certificate_path.Append(certificate_file);
if (certificate_path.IsAbsolute() &&
@@ -351,18 +357,18 @@ bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const {
arguments->SetString("cert-and-key-file", certificate_path.value());
}
- std::string ocsp_arg = https_options_.GetOCSPArgument();
+ std::string ocsp_arg = ssl_options_.GetOCSPArgument();
if (!ocsp_arg.empty())
arguments->SetString("ocsp", ocsp_arg);
// Check the client certificate related arguments.
- if (https_options_.request_client_certificate)
+ if (ssl_options_.request_client_certificate)
arguments->Set("ssl-client-auth", base::Value::CreateNullValue());
scoped_ptr<base::ListValue> ssl_client_certs(new base::ListValue());
std::vector<FilePath>::const_iterator it;
- for (it = https_options_.client_authorities.begin();
- it != https_options_.client_authorities.end(); ++it) {
+ for (it = ssl_options_.client_authorities.begin();
+ it != ssl_options_.client_authorities.end(); ++it) {
if (it->IsAbsolute() && !file_util::PathExists(*it)) {
LOG(ERROR) << "Client authority path " << it->value()
<< " doesn't exist. Can't launch https server.";
@@ -376,14 +382,14 @@ bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const {
// Check bulk cipher argument.
scoped_ptr<base::ListValue> bulk_cipher_values(new base::ListValue());
- GetCiphersList(https_options_.bulk_ciphers, bulk_cipher_values.get());
+ GetCiphersList(ssl_options_.bulk_ciphers, bulk_cipher_values.get());
if (bulk_cipher_values->GetSize())
arguments->Set("ssl-bulk-cipher", bulk_cipher_values.release());
- if (https_options_.record_resume)
+ if (ssl_options_.record_resume)
arguments->Set("https-record-resume", base::Value::CreateNullValue());
- if (https_options_.tls_intolerant != HTTPSOptions::TLS_INTOLERANT_NONE) {
+ if (ssl_options_.tls_intolerant != SSLOptions::TLS_INTOLERANT_NONE) {
arguments->Set("tls-intolerant",
- base::Value::CreateIntegerValue(https_options_.tls_intolerant));
+ base::Value::CreateIntegerValue(ssl_options_.tls_intolerant));
}
}
return true;
diff --git a/net/test/base_test_server.h b/net/test/base_test_server.h
index 3547465..cd996cb 100644
--- a/net/test/base_test_server.h
+++ b/net/test/base_test_server.h
@@ -35,14 +35,16 @@ class BaseTestServer {
TYPE_GDATA,
TYPE_HTTP,
TYPE_HTTPS,
+ TYPE_WS,
+ TYPE_WSS,
TYPE_SYNC,
TYPE_TCP_ECHO,
TYPE_UDP_ECHO,
};
- // Container for various options to control how the HTTPS server is
+ // Container for various options to control how the HTTPS or WSS server is
// initialized.
- struct HTTPSOptions {
+ struct SSLOptions {
enum ServerCertificate {
CERT_OK,
@@ -95,12 +97,12 @@ class BaseTestServer {
TLS_INTOLERANT_TLS1_2 = 3, // Intolerant of TLS 1.2 or higher.
};
- // Initialize a new HTTPSOptions using CERT_OK as the certificate.
- HTTPSOptions();
+ // Initialize a new SSLOptions using CERT_OK as the certificate.
+ SSLOptions();
- // Initialize a new HTTPSOptions that will use the specified certificate.
- explicit HTTPSOptions(ServerCertificate cert);
- ~HTTPSOptions();
+ // Initialize a new SSLOptions that will use the specified certificate.
+ explicit SSLOptions(ServerCertificate cert);
+ ~SSLOptions();
// Returns the relative filename of the file that contains the
// |server_certificate|.
@@ -151,8 +153,8 @@ class BaseTestServer {
// Initialize a TestServer listening on a specific host (IP or hostname).
BaseTestServer(Type type, const std::string& host);
- // Initialize a HTTPS TestServer with a specific set of HTTPSOptions.
- explicit BaseTestServer(const HTTPSOptions& https_options);
+ // Initialize a TestServer with a specific set of SSLOptions for HTTPS or WSS.
+ explicit BaseTestServer(Type type, const SSLOptions& ssl_options);
// Returns the host port pair used by current Python based test server only
// if the server is started.
@@ -225,8 +227,9 @@ class BaseTestServer {
// Holds the data sent from the server (e.g., port number).
scoped_ptr<base::DictionaryValue> server_data_;
- // If |type_| is TYPE_HTTPS, the TLS settings to use for the test server.
- HTTPSOptions https_options_;
+ // If |type_| is TYPE_HTTPS or TYPE_WSS, the TLS settings to use for the test
+ // server.
+ SSLOptions ssl_options_;
Type type_;
diff --git a/net/test/local_test_server.cc b/net/test/local_test_server.cc
index e67d4f9..a1a1bc8 100644
--- a/net/test/local_test_server.cc
+++ b/net/test/local_test_server.cc
@@ -65,9 +65,10 @@ LocalTestServer::LocalTestServer(Type type,
NOTREACHED();
}
-LocalTestServer::LocalTestServer(const HTTPSOptions& https_options,
+LocalTestServer::LocalTestServer(Type type,
+ const SSLOptions& ssl_options,
const FilePath& document_root)
- : BaseTestServer(https_options) {
+ : BaseTestServer(type, ssl_options) {
if (!Init(document_root))
NOTREACHED();
}
@@ -152,9 +153,9 @@ bool LocalTestServer::Init(const FilePath& document_root) {
return false;
SetResourcePath(src_dir.Append(document_root),
src_dir.AppendASCII("net")
- .AppendASCII("data")
- .AppendASCII("ssl")
- .AppendASCII("certificates"));
+ .AppendASCII("data")
+ .AppendASCII("ssl")
+ .AppendASCII("certificates"));
return true;
}
@@ -226,6 +227,10 @@ bool LocalTestServer::AddCommandLineArguments(CommandLine* command_line) const {
case TYPE_HTTPS:
// The default type is HTTP, no argument required.
break;
+ case TYPE_WS:
+ case TYPE_WSS:
+ // TODO(toyoshim): Handle correctly. See, http://crbug.com/137639 .
+ break;
case TYPE_FTP:
command_line->AppendArg("-f");
break;
diff --git a/net/test/local_test_server.h b/net/test/local_test_server.h
index 99aa448..2663668 100644
--- a/net/test/local_test_server.h
+++ b/net/test/local_test_server.h
@@ -29,9 +29,10 @@ class LocalTestServer : public BaseTestServer {
const std::string& host,
const FilePath& document_root);
- // Initialize a HTTPS TestServer with a specific set of HTTPSOptions.
+ // Initialize a TestServer with a specific set of SSLOptions.
// |document_root| must be a relative path under the root tree.
- LocalTestServer(const HTTPSOptions& https_options,
+ LocalTestServer(Type type,
+ const SSLOptions& ssl_options,
const FilePath& document_root);
virtual ~LocalTestServer();
diff --git a/net/test/remote_test_server.cc b/net/test/remote_test_server.cc
index f9fc969..178b174 100644
--- a/net/test/remote_test_server.cc
+++ b/net/test/remote_test_server.cc
@@ -63,10 +63,10 @@ RemoteTestServer::RemoteTestServer(Type type,
NOTREACHED();
}
-RemoteTestServer::RemoteTestServer(
- const HTTPSOptions& https_options,
- const FilePath& document_root)
- : BaseTestServer(https_options),
+RemoteTestServer::RemoteTestServer(Type type,
+ const SSLOptions& ssl_options,
+ const FilePath& document_root)
+ : BaseTestServer(type, ssl_options),
spawner_server_port_(0) {
if (!Init(document_root))
NOTREACHED();
diff --git a/net/test/remote_test_server.h b/net/test/remote_test_server.h
index b617bab..417eda8b 100644
--- a/net/test/remote_test_server.h
+++ b/net/test/remote_test_server.h
@@ -23,9 +23,10 @@ class RemoteTestServer : public BaseTestServer {
const std::string& host,
const FilePath& document_root);
- // Initialize a HTTPS TestServer with a specific set of HTTPSOptions.
+ // Initialize a TestServer with a specific set of SSLOptions.
// |document_root| must be a relative path under the root tree.
- RemoteTestServer(const HTTPSOptions& https_options,
+ RemoteTestServer(Type type,
+ const SSLOptions& ssl_options,
const FilePath& document_root);
virtual ~RemoteTestServer();