| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 return None | 222 return None |
| 223 | 223 |
| 224 def do_GET(self): | 224 def do_GET(self): |
| 225 """Handles GET requests. | 225 """Handles GET requests. |
| 226 | 226 |
| 227 Currently this is only used to serve external policy data.""" | 227 Currently this is only used to serve external policy data.""" |
| 228 sep = self.path.find('?') | 228 sep = self.path.find('?') |
| 229 path = self.path if sep == -1 else self.path[:sep] | 229 path = self.path if sep == -1 else self.path[:sep] |
| 230 if path == '/externalpolicydata': | 230 if path == '/externalpolicydata': |
| 231 http_response, raw_reply = self.HandleExternalPolicyDataRequest() | 231 http_response, raw_reply = self.HandleExternalPolicyDataRequest() |
| 232 elif path == '/configuration/test/exit': |
| 233 # This is not part of the standard DM server protocol. |
| 234 # This extension is added to make the test server exit gracefully |
| 235 # when the test is complete. |
| 236 self.server.stop = True |
| 237 http_response = 200 |
| 238 raw_reply = 'OK' |
| 232 else: | 239 else: |
| 233 http_response = 404 | 240 http_response = 404 |
| 234 raw_reply = 'Invalid path' | 241 raw_reply = 'Invalid path' |
| 235 self.send_response(http_response) | 242 self.send_response(http_response) |
| 236 self.end_headers() | 243 self.end_headers() |
| 237 self.wfile.write(raw_reply) | 244 self.wfile.write(raw_reply) |
| 238 | 245 |
| 239 def do_POST(self): | 246 def do_POST(self): |
| 240 http_response, raw_reply = self.HandleRequest() | 247 http_response, raw_reply = self.HandleRequest() |
| 241 self.send_response(http_response) | 248 self.send_response(http_response) |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 if (self.options.log_to_console): | 1246 if (self.options.log_to_console): |
| 1240 logger.addHandler(logging.StreamHandler()) | 1247 logger.addHandler(logging.StreamHandler()) |
| 1241 if (self.options.log_file): | 1248 if (self.options.log_file): |
| 1242 logger.addHandler(logging.FileHandler(self.options.log_file)) | 1249 logger.addHandler(logging.FileHandler(self.options.log_file)) |
| 1243 | 1250 |
| 1244 testserver_base.TestServerRunner.run_server(self) | 1251 testserver_base.TestServerRunner.run_server(self) |
| 1245 | 1252 |
| 1246 | 1253 |
| 1247 if __name__ == '__main__': | 1254 if __name__ == '__main__': |
| 1248 sys.exit(PolicyServerRunner().main()) | 1255 sys.exit(PolicyServerRunner().main()) |
| OLD | NEW |