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

Side by Side Diff: net/tools/testserver/testserver.py

Issue 6161007: New protocol and testserver for the Chrome-DMServer protocol (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments + some cleanup Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/tools/testserver/device_management.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 # Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """This is a simple HTTP server used for testing Chrome. 6 """This is a simple HTTP server used for testing Chrome.
7 7
8 It supports several test URLs, as specified by the handlers in TestPageHandler. 8 It supports several test URLs, as specified by the handlers in TestPageHandler.
9 By default, it listens on an ephemeral port and sends the port number back to 9 By default, it listens on an ephemeral port and sends the port number back to
10 the originating process over a pipe. The originating process can specify an 10 the originating process over a pipe. The originating process can specify an
11 explicit port if necessary. 11 explicit port if necessary.
12 It can use https if you specify the flag --https=CERT where CERT is the path 12 It can use https if you specify the flag --https=CERT where CERT is the path
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 """Delegates to the device management service used for cloud policy.""" 1277 """Delegates to the device management service used for cloud policy."""
1278 if not self._ShouldHandleRequest("/device_management"): 1278 if not self._ShouldHandleRequest("/device_management"):
1279 return False 1279 return False
1280 1280
1281 raw_request = self.ReadRequestBody() 1281 raw_request = self.ReadRequestBody()
1282 1282
1283 if not self.server._device_management_handler: 1283 if not self.server._device_management_handler:
1284 import device_management 1284 import device_management
1285 policy_path = os.path.join(self.server.data_dir, 'device_management') 1285 policy_path = os.path.join(self.server.data_dir, 'device_management')
1286 self.server._device_management_handler = ( 1286 self.server._device_management_handler = (
1287 device_management.TestServer(policy_path)) 1287 device_management.TestServer(policy_path,
1288 self.server.policy_cert_chain))
1288 1289
1289 http_response, raw_reply = ( 1290 http_response, raw_reply = (
1290 self.server._device_management_handler.HandleRequest(self.path, 1291 self.server._device_management_handler.HandleRequest(self.path,
1291 self.headers, 1292 self.headers,
1292 raw_request)) 1293 raw_request))
1293 self.send_response(http_response) 1294 self.send_response(http_response)
1294 self.end_headers() 1295 self.end_headers()
1295 self.wfile.write(raw_reply) 1296 self.wfile.write(raw_reply)
1296 return True 1297 return True
1297 1298
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 options.ssl_bulk_cipher) 1413 options.ssl_bulk_cipher)
1413 print 'HTTPS server started on port %d...' % server.server_port 1414 print 'HTTPS server started on port %d...' % server.server_port
1414 else: 1415 else:
1415 server = StoppableHTTPServer(('127.0.0.1', port), TestPageHandler) 1416 server = StoppableHTTPServer(('127.0.0.1', port), TestPageHandler)
1416 print 'HTTP server started on port %d...' % server.server_port 1417 print 'HTTP server started on port %d...' % server.server_port
1417 1418
1418 server.data_dir = MakeDataDir() 1419 server.data_dir = MakeDataDir()
1419 server.file_root_url = options.file_root_url 1420 server.file_root_url = options.file_root_url
1420 server_data['port'] = server.server_port 1421 server_data['port'] = server.server_port
1421 server._device_management_handler = None 1422 server._device_management_handler = None
1423 server.policy_cert_chain = options.policy_cert_chain
1422 elif options.server_type == SERVER_SYNC: 1424 elif options.server_type == SERVER_SYNC:
1423 server = SyncHTTPServer(('127.0.0.1', port), SyncPageHandler) 1425 server = SyncHTTPServer(('127.0.0.1', port), SyncPageHandler)
1424 print 'Sync HTTP server started on port %d...' % server.server_port 1426 print 'Sync HTTP server started on port %d...' % server.server_port
1425 print 'Sync XMPP server started on port %d...' % server.xmpp_port 1427 print 'Sync XMPP server started on port %d...' % server.xmpp_port
1426 server_data['port'] = server.server_port 1428 server_data['port'] = server.server_port
1427 server_data['xmpp_port'] = server.xmpp_port 1429 server_data['xmpp_port'] = server.xmpp_port
1428 # means FTP Server 1430 # means FTP Server
1429 else: 1431 else:
1430 my_data_dir = MakeDataDir() 1432 my_data_dir = MakeDataDir()
1431 1433
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 'that will be accepted by the SSL server. Valid ' 1512 'that will be accepted by the SSL server. Valid '
1511 'values are "aes256", "aes128", "3des", "rc4". If ' 1513 'values are "aes256", "aes128", "3des", "rc4". If '
1512 'omitted, all algorithms will be used. This ' 1514 'omitted, all algorithms will be used. This '
1513 'option may appear multiple times, indicating ' 1515 'option may appear multiple times, indicating '
1514 'multiple algorithms should be enabled.'); 1516 'multiple algorithms should be enabled.');
1515 option_parser.add_option('', '--file-root-url', default='/files/', 1517 option_parser.add_option('', '--file-root-url', default='/files/',
1516 help='Specify a root URL for files served.') 1518 help='Specify a root URL for files served.')
1517 option_parser.add_option('', '--startup-pipe', type='int', 1519 option_parser.add_option('', '--startup-pipe', type='int',
1518 dest='startup_pipe', 1520 dest='startup_pipe',
1519 help='File handle of pipe to parent process') 1521 help='File handle of pipe to parent process')
1522 option_parser.add_option('', '--policy-cert-chain', action='append',
1523 help='Specify a path to a certificate file to sign '
1524 'policy responses. This option may be used '
1525 'multiple times to define a certificate chain. '
1526 'The first element will be used for signing, '
1527 'the last element should be the root '
1528 'certificate.')
1520 options, args = option_parser.parse_args() 1529 options, args = option_parser.parse_args()
1521 1530
1522 sys.exit(main(options, args)) 1531 sys.exit(main(options, args))
OLDNEW
« no previous file with comments | « net/tools/testserver/device_management.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698