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

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

Issue 1275853003: net/testserver.py: Add handler to reply with client auth status. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | 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/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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/TCP/UDP/BASIC_AUTH_PROXY/WEBSOCKET server used for 6 """This is a simple HTTP/FTP/TCP/UDP/BASIC_AUTH_PROXY/WEBSOCKET server used for
7 testing Chrome. 7 testing 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 self.AuthDigestHandler, 329 self.AuthDigestHandler,
330 self.SlowServerHandler, 330 self.SlowServerHandler,
331 self.ChunkedServerHandler, 331 self.ChunkedServerHandler,
332 self.NoContentHandler, 332 self.NoContentHandler,
333 self.ServerRedirectHandler, 333 self.ServerRedirectHandler,
334 self.CrossSiteRedirectHandler, 334 self.CrossSiteRedirectHandler,
335 self.ClientRedirectHandler, 335 self.ClientRedirectHandler,
336 self.GetSSLSessionCacheHandler, 336 self.GetSSLSessionCacheHandler,
337 self.SSLManySmallRecords, 337 self.SSLManySmallRecords,
338 self.GetChannelID, 338 self.GetChannelID,
339 self.GetClientCert,
339 self.ClientCipherListHandler, 340 self.ClientCipherListHandler,
340 self.CloseSocketHandler, 341 self.CloseSocketHandler,
341 self.RangeResetHandler, 342 self.RangeResetHandler,
342 self.DefaultResponseHandler] 343 self.DefaultResponseHandler]
343 post_handlers = [ 344 post_handlers = [
344 self.EchoTitleHandler, 345 self.EchoTitleHandler,
345 self.EchoHandler, 346 self.EchoHandler,
346 self.PostOnlyFileHandler, 347 self.PostOnlyFileHandler,
347 self.EchoMultipartPostHandler] + get_handlers 348 self.EchoMultipartPostHandler] + get_handlers
348 put_handlers = [ 349 put_handlers = [
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 if not self._ShouldHandleRequest('/channel-id'): 1506 if not self._ShouldHandleRequest('/channel-id'):
1506 return False 1507 return False
1507 1508
1508 self.send_response(200) 1509 self.send_response(200)
1509 self.send_header('Content-Type', 'text/plain') 1510 self.send_header('Content-Type', 'text/plain')
1510 self.end_headers() 1511 self.end_headers()
1511 channel_id = bytes(self.server.tlsConnection.channel_id) 1512 channel_id = bytes(self.server.tlsConnection.channel_id)
1512 self.wfile.write(hashlib.sha256(channel_id).digest().encode('base64')) 1513 self.wfile.write(hashlib.sha256(channel_id).digest().encode('base64'))
1513 return True 1514 return True
1514 1515
1516 def GetClientCert(self):
1517 """Send a reply whether a client certificate was provided."""
1518
1519 if not self._ShouldHandleRequest('/client-cert'):
1520 return False
1521
1522 self.send_response(200)
1523 self.send_header('Content-Type', 'text/plain')
1524 self.end_headers()
1525
1526 cert_present = self.server.tlsConnection.session.clientCertChain != None
1527 if cert_present:
1528 self.wfile.write('got a client cert')
1529 else:
1530 self.wfile.write('got no client cert')
Ryan Sleevi 2015/08/06 23:48:52 nit: Would it make more sense to write the SHA-256
pneubeck (no reviews) 2015/08/07 11:47:42 Done.
1531 return True
1532
1515 def ClientCipherListHandler(self): 1533 def ClientCipherListHandler(self):
1516 """Send a reply containing the cipher suite list that the client 1534 """Send a reply containing the cipher suite list that the client
1517 provided. Each cipher suite value is serialized in decimal, followed by a 1535 provided. Each cipher suite value is serialized in decimal, followed by a
1518 newline.""" 1536 newline."""
1519 1537
1520 if not self._ShouldHandleRequest('/client-cipher-list'): 1538 if not self._ShouldHandleRequest('/client-cipher-list'):
1521 return False 1539 return False
1522 1540
1523 self.send_response(200) 1541 self.send_response(200)
1524 self.send_header('Content-Type', 'text/plain') 1542 self.send_header('Content-Type', 'text/plain')
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 'alert immediately after the handshake.') 2299 'alert immediately after the handshake.')
2282 self.option_parser.add_option('--no-anonymous-ftp-user', 2300 self.option_parser.add_option('--no-anonymous-ftp-user',
2283 dest='no_anonymous_ftp_user', 2301 dest='no_anonymous_ftp_user',
2284 default=False, action='store_true', 2302 default=False, action='store_true',
2285 help='If set, the FTP server will not create ' 2303 help='If set, the FTP server will not create '
2286 'an anonymous user.') 2304 'an anonymous user.')
2287 2305
2288 2306
2289 if __name__ == '__main__': 2307 if __name__ == '__main__':
2290 sys.exit(ServerRunner().main()) 2308 sys.exit(ServerRunner().main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698