summaryrefslogtreecommitdiffstats
path: root/net/test
diff options
context:
space:
mode:
authorricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-29 07:42:29 +0000
committerricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-29 07:42:29 +0000
commite69c1cd33dee41835499a5130c3431a059b4ac7d (patch)
tree45a0bd23c30d455d99c45909d05329b18800d6b7 /net/test
parente0cc8e2ac33e2943920e8b0f0184cce62c01fd5a (diff)
downloadchromium_src-e69c1cd33dee41835499a5130c3431a059b4ac7d.zip
chromium_src-e69c1cd33dee41835499a5130c3431a059b4ac7d.tar.gz
chromium_src-e69c1cd33dee41835499a5130c3431a059b4ac7d.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@286108 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test')
-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 c0fc6c5..26608c6 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);