Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: net/tools/testserver/testserver.py

Issue 336263005: Map WebSocket URL schemes to HTTP URL schemes for auth purposes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Factor out WebSocketDispatchOnFinishOpeningHandshake() into a separate function. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/tools/testserver/testserver.py
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 83920d8dd95fb5c5b0bf85bba79598b07e4c426f..150a3cf3773d75abc3c00224bd04413dc05e8eb9 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -103,6 +103,7 @@ class WebSocketOptions:
self.tls_client_ca = None
self.tls_module = 'ssl'
self.use_basic_auth = False
+ self.basic_auth_credential = 'Basic ' + base64.b64encode('test:test')
class RecordingSSLSessionCache(object):
@@ -2024,6 +2025,7 @@ class ServerRunner(testserver_base.TestServerRunner):
print 'WebSocket server started on %s://%s:%d...' % \
(scheme, host, server.server_port)
server_data['port'] = server.server_port
+ websocket_options.use_basic_auth = self.options.ws_basic_auth
elif self.options.server_type == SERVER_TCP_ECHO:
# Used for generating the key (randomly) that encodes the "echo request"
# message.
@@ -2205,6 +2207,10 @@ class ServerRunner(testserver_base.TestServerRunner):
'support for exactly one protocol, http/1.1')
self.option_parser.add_option('--file-root-url', default='/files/',
help='Specify a root URL for files served.')
+ # TODO(ricea): Generalise this to support basic auth for HTTP too.
Johnny 2014/07/08 20:27:40 nit: s/Generalise/Generalize/
Adam Rice 2014/07/09 06:35:01 Done.
+ self.option_parser.add_option('--ws-basic-auth', action='store_true',
+ dest='ws_basic_auth',
+ help='Enable basic-auth for WebSocket')
if __name__ == '__main__':

Powered by Google App Engine
This is Rietveld 408576698