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

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

Issue 7481009: Test birtday error. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed typos in testserver.py Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 # Copyright (c) 2011 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/FTP/SYNC/TCP ECHO/UDP ECHO/ server used for testing 6 """This is a simple HTTP/FTP/SYNC/TCP ECHO/UDP ECHO/ server used for testing
7 Chrome. 7 Chrome.
8 8
9 It supports several test URLs, as specified by the handlers in TestPageHandler. 9 It supports several test URLs, as specified by the handlers in TestPageHandler.
10 By default, it listens on an ephemeral port and sends the port number back to 10 By default, it listens on an ephemeral port and sends the port number back to
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 self.wfile.write('%X\r\n' % len(chunk)) 1397 self.wfile.write('%X\r\n' % len(chunk))
1398 self.wfile.write(chunk) 1398 self.wfile.write(chunk)
1399 self.wfile.write('\r\n') 1399 self.wfile.write('\r\n')
1400 1400
1401 1401
1402 class SyncPageHandler(BasePageHandler): 1402 class SyncPageHandler(BasePageHandler):
1403 """Handler for the main HTTP sync server.""" 1403 """Handler for the main HTTP sync server."""
1404 1404
1405 def __init__(self, request, client_address, sync_http_server): 1405 def __init__(self, request, client_address, sync_http_server):
1406 get_handlers = [self.ChromiumSyncMigrationOpHandler, 1406 get_handlers = [self.ChromiumSyncMigrationOpHandler,
1407 self.ChromiumSyncTimeHandler] 1407 self.ChromiumSyncTimeHandler,
1408 self.ChromiumSyncBirthdayErrorOpHanlder]
1408 post_handlers = [self.ChromiumSyncCommandHandler, 1409 post_handlers = [self.ChromiumSyncCommandHandler,
1409 self.ChromiumSyncTimeHandler] 1410 self.ChromiumSyncTimeHandler]
1410 BasePageHandler.__init__(self, request, client_address, 1411 BasePageHandler.__init__(self, request, client_address,
1411 sync_http_server, [], get_handlers, 1412 sync_http_server, [], get_handlers,
1412 post_handlers, []) 1413 post_handlers, [])
1413 1414
1414 def ChromiumSyncTimeHandler(self): 1415 def ChromiumSyncTimeHandler(self):
1415 """Handle Chromium sync .../time requests. 1416 """Handle Chromium sync .../time requests.
1416 1417
1417 The syncer sometimes checks server reachability by examining /time. 1418 The syncer sometimes checks server reachability by examining /time.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 1461
1461 http_response, raw_reply = self.server._sync_handler.HandleMigrate( 1462 http_response, raw_reply = self.server._sync_handler.HandleMigrate(
1462 self.path) 1463 self.path)
1463 self.send_response(http_response) 1464 self.send_response(http_response)
1464 self.send_header('Content-Type', 'text/html') 1465 self.send_header('Content-Type', 'text/html')
1465 self.send_header('Content-Length', len(raw_reply)) 1466 self.send_header('Content-Length', len(raw_reply))
1466 self.end_headers() 1467 self.end_headers()
1467 self.wfile.write(raw_reply) 1468 self.wfile.write(raw_reply)
1468 return True 1469 return True
1469 1470
1471 def ChromiumSyncBirthdayErrorOpHanlder(self):
tim (not reviewing) 2011/07/26 19:32:17 OpHandler typo
lipalani1 2011/07/27 01:15:22 Done.
1472 test_name = "/chromiumsync/birthdayerror"
1473 if not self._ShouldHandleRequest(test_name):
1474 return False
1475 result, raw_reply = self.server._sync_handler.HandleCreateBirthdayError()
1476 self.send_response(result)
1477 self.send_header('Content-Type', 'text/html')
1478 self.send_header('Content-Length', len(raw_reply))
1479 self.end_headers()
1480 self.wfile.write(raw_reply)
1481 return True;
1482
1483 def ChromiumsyncTransientErrorOpHandler(self):
1484 test_name = "/chromiumsync/birthdayerror"
1485 if not self._shouldHandleRequest(test_name):
1486 return False
1487 result, raw_reply = self.server._sync_handler.HandleSetTransientError
1488
1470 1489
1471 def MakeDataDir(): 1490 def MakeDataDir():
1472 if options.data_dir: 1491 if options.data_dir:
1473 if not os.path.isdir(options.data_dir): 1492 if not os.path.isdir(options.data_dir):
1474 print 'specified data dir not found: ' + options.data_dir + ' exiting...' 1493 print 'specified data dir not found: ' + options.data_dir + ' exiting...'
1475 return None 1494 return None
1476 my_data_dir = options.data_dir 1495 my_data_dir = options.data_dir
1477 else: 1496 else:
1478 # Create the default path to our data dir, relative to the exe dir. 1497 # Create the default path to our data dir, relative to the exe dir.
1479 my_data_dir = os.path.dirname(sys.argv[0]) 1498 my_data_dir = os.path.dirname(sys.argv[0])
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 'random key if none is specified on the command ' 1719 'random key if none is specified on the command '
1701 'line.') 1720 'line.')
1702 option_parser.add_option('', '--policy-user', default='user@example.com', 1721 option_parser.add_option('', '--policy-user', default='user@example.com',
1703 dest='policy_user', 1722 dest='policy_user',
1704 help='Specify the user name the server should ' 1723 help='Specify the user name the server should '
1705 'report back to the client as the user owning the ' 1724 'report back to the client as the user owning the '
1706 'token used for making the policy request.') 1725 'token used for making the policy request.')
1707 options, args = option_parser.parse_args() 1726 options, args = option_parser.parse_args()
1708 1727
1709 sys.exit(main(options, args)) 1728 sys.exit(main(options, args))
OLDNEW
« net/tools/testserver/chromiumsync.py ('K') | « net/tools/testserver/chromiumsync.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698