OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """A bare-bones test server for testing cloud policy support. | 5 """A bare-bones test server for testing cloud policy support. |
6 | 6 |
7 This implements a simple cloud policy test server that can be used to test | 7 This implements a simple cloud policy test server that can be used to test |
8 chrome's device management service client. The policy information is read from | 8 chrome's device management service client. The policy information is read from |
9 the file named device_management in the server's data directory. It contains | 9 the file named device_management in the server's data directory. It contains |
10 enforced and recommended policies for the device and user scope, and a list | 10 enforced and recommended policies for the device and user scope, and a list |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 | 664 |
665 logging.debug('Token check failed with error %d' % error) | 665 logging.debug('Token check failed with error %d' % error) |
666 | 666 |
667 return (None, (error, 'Server error %d' % error)) | 667 return (None, (error, 'Server error %d' % error)) |
668 | 668 |
669 def DumpMessage(self, label, msg): | 669 def DumpMessage(self, label, msg): |
670 """Helper for logging an ASCII dump of a protobuf message.""" | 670 """Helper for logging an ASCII dump of a protobuf message.""" |
671 logging.debug('%s\n%s' % (label, str(msg))) | 671 logging.debug('%s\n%s' % (label, str(msg))) |
672 | 672 |
673 | 673 |
674 class PolicyTestServer(testserver_base.ClientRestrictingServerMixIn, | 674 class PolicyTestServer(testserver_base.BrokenPipeHandlerMixIn, |
675 testserver_base.BrokenPipeHandlerMixIn, | |
676 testserver_base.StoppableHTTPServer): | 675 testserver_base.StoppableHTTPServer): |
677 """Handles requests and keeps global service state.""" | 676 """Handles requests and keeps global service state.""" |
678 | 677 |
679 def __init__(self, server_address, data_dir, policy_path, client_state_file, | 678 def __init__(self, server_address, data_dir, policy_path, client_state_file, |
680 private_key_paths, server_base_url): | 679 private_key_paths, server_base_url): |
681 """Initializes the server. | 680 """Initializes the server. |
682 | 681 |
683 Args: | 682 Args: |
684 server_address: Server host and port. | 683 server_address: Server host and port. |
685 policy_path: Names the file to read JSON-formatted policy from. | 684 policy_path: Names the file to read JSON-formatted policy from. |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 if (self.options.log_to_console): | 967 if (self.options.log_to_console): |
969 logger.addHandler(logging.StreamHandler()) | 968 logger.addHandler(logging.StreamHandler()) |
970 if (self.options.log_file): | 969 if (self.options.log_file): |
971 logger.addHandler(logging.FileHandler(self.options.log_file)) | 970 logger.addHandler(logging.FileHandler(self.options.log_file)) |
972 | 971 |
973 testserver_base.TestServerRunner.run_server(self) | 972 testserver_base.TestServerRunner.run_server(self) |
974 | 973 |
975 | 974 |
976 if __name__ == '__main__': | 975 if __name__ == '__main__': |
977 sys.exit(PolicyServerRunner().main()) | 976 sys.exit(PolicyServerRunner().main()) |
OLD | NEW |