summaryrefslogtreecommitdiffstats
path: root/net/test/spawned_test_server
diff options
context:
space:
mode:
authorricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-10 11:13:47 +0000
committerricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-10 11:13:47 +0000
commit8d7ed25ca422433e8e4c23262fde158019d1d565 (patch)
treec00cf92e0febc1ee9862a633d1e0b132549e67e5 /net/test/spawned_test_server
parent41c6d548b0bc87e182cb9801510e02c1f3875392 (diff)
downloadchromium_src-8d7ed25ca422433e8e4c23262fde158019d1d565.zip
chromium_src-8d7ed25ca422433e8e4c23262fde158019d1d565.tar.gz
chromium_src-8d7ed25ca422433e8e4c23262fde158019d1d565.tar.bz2
Map WebSocket URL schemes to HTTP URL schemes for auth purposes.
This permits WebSocket connections to inherit credentials from HTTP pages, and matches the behaviour of other browsers. Design doc: https://docs.google.com/a/chromium.org/document/d/129rLtf5x3hvhP5rayLiSxnEjOXS8Z7EnLJgBL4CdwjI/edit Also consider any 401 or 407 results that reach the WebSocketStream URLRequest::Delegate to be unrecoverable errors. Also ensure that the response headers are reported back to the renderer when the developer tools are open and a 401 error happens. BUG=123862 Review URL: https://codereview.chromium.org/336263005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282307 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test/spawned_test_server')
-rw-r--r--net/test/spawned_test_server/base_test_server.cc11
-rw-r--r--net/test/spawned_test_server/base_test_server.h9
2 files changed, 18 insertions, 2 deletions
diff --git a/net/test/spawned_test_server/base_test_server.cc b/net/test/spawned_test_server/base_test_server.cc
index 2ee9adc..62ff180 100644
--- a/net/test/spawned_test_server/base_test_server.cc
+++ b/net/test/spawned_test_server/base_test_server.cc
@@ -165,7 +165,8 @@ const char BaseTestServer::kLocalhost[] = "127.0.0.1";
BaseTestServer::BaseTestServer(Type type, const std::string& host)
: type_(type),
started_(false),
- log_to_console_(false) {
+ log_to_console_(false),
+ ws_basic_auth_(false) {
Init(host);
}
@@ -173,7 +174,8 @@ BaseTestServer::BaseTestServer(Type type, const SSLOptions& ssl_options)
: ssl_options_(ssl_options),
type_(type),
started_(false),
- log_to_console_(false) {
+ log_to_console_(false),
+ ws_basic_auth_(false) {
DCHECK(UsingSSL(type));
Init(GetHostname(type, ssl_options));
}
@@ -384,6 +386,11 @@ bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const {
if (VLOG_IS_ON(1) || log_to_console_)
arguments->Set("log-to-console", base::Value::CreateNullValue());
+ if (ws_basic_auth_) {
+ DCHECK(type_ == TYPE_WS || type_ == TYPE_WSS);
+ arguments->Set("ws-basic-auth", base::Value::CreateNullValue());
+ }
+
if (UsingSSL(type_)) {
// Check the certificate arguments of the HTTPS server.
base::FilePath certificate_path(certificates_dir_);
diff --git a/net/test/spawned_test_server/base_test_server.h b/net/test/spawned_test_server/base_test_server.h
index a5e3287..6dd67db 100644
--- a/net/test/spawned_test_server/base_test_server.h
+++ b/net/test/spawned_test_server/base_test_server.h
@@ -242,6 +242,12 @@ class BaseTestServer {
type == BaseTestServer::TYPE_WSS;
}
+ // Enable HTTP basic authentication. Currently this only works for TYPE_WS and
+ // TYPE_WSS.
+ void set_websocket_basic_auth(bool ws_basic_auth) {
+ ws_basic_auth_ = ws_basic_auth;
+ }
+
protected:
virtual ~BaseTestServer();
Type type() const { return type_; }
@@ -308,6 +314,9 @@ class BaseTestServer {
// Enables logging of the server to the console.
bool log_to_console_;
+ // Is WebSocket basic HTTP authentication enabled?
+ bool ws_basic_auth_;
+
scoped_ptr<ScopedPortException> allowed_port_;
DISALLOW_COPY_AND_ASSIGN(BaseTestServer);