| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 self.headers.getheader('Authorization', '')) | 271 self.headers.getheader('Authorization', '')) |
| 272 logging.debug('oauth token -> ' + str(self.GetUniqueParam('oauth_token'))) | 272 logging.debug('oauth token -> ' + str(self.GetUniqueParam('oauth_token'))) |
| 273 logging.debug('deviceid -> ' + str(self.GetUniqueParam('deviceid'))) | 273 logging.debug('deviceid -> ' + str(self.GetUniqueParam('deviceid'))) |
| 274 self.DumpMessage('Request', rmsg) | 274 self.DumpMessage('Request', rmsg) |
| 275 | 275 |
| 276 request_type = self.GetUniqueParam('request') | 276 request_type = self.GetUniqueParam('request') |
| 277 # Check server side requirements, as defined in | 277 # Check server side requirements, as defined in |
| 278 # device_management_backend.proto. | 278 # device_management_backend.proto. |
| 279 if (self.GetUniqueParam('devicetype') != '2' or | 279 if (self.GetUniqueParam('devicetype') != '2' or |
| 280 self.GetUniqueParam('apptype') != 'Chrome' or | 280 self.GetUniqueParam('apptype') != 'Chrome' or |
| 281 len(self.GetUniqueParam('deviceid')) >= 64 or | 281 len(self.GetUniqueParam('deviceid')) >= 64): |
| 282 len(self.GetUniqueParam('agent')) >= 64): | |
| 283 return (400, 'Invalid request parameter') | 282 return (400, 'Invalid request parameter') |
| 284 if request_type == 'register': | 283 if request_type == 'register': |
| 285 response = self.ProcessRegister(rmsg.register_request) | 284 response = self.ProcessRegister(rmsg.register_request) |
| 286 elif request_type == 'api_authorization': | 285 elif request_type == 'api_authorization': |
| 287 response = self.ProcessApiAuthorization(rmsg.service_api_access_request) | 286 response = self.ProcessApiAuthorization(rmsg.service_api_access_request) |
| 288 elif request_type == 'unregister': | 287 elif request_type == 'unregister': |
| 289 response = self.ProcessUnregister(rmsg.unregister_request) | 288 response = self.ProcessUnregister(rmsg.unregister_request) |
| 290 elif request_type == 'policy': | 289 elif request_type == 'policy': |
| 291 response = self.ProcessPolicy(rmsg, request_type) | 290 response = self.ProcessPolicy(rmsg, request_type) |
| 292 elif request_type == 'enterprise_check': | 291 elif request_type == 'enterprise_check': |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 if (self.options.log_to_console): | 1239 if (self.options.log_to_console): |
| 1241 logger.addHandler(logging.StreamHandler()) | 1240 logger.addHandler(logging.StreamHandler()) |
| 1242 if (self.options.log_file): | 1241 if (self.options.log_file): |
| 1243 logger.addHandler(logging.FileHandler(self.options.log_file)) | 1242 logger.addHandler(logging.FileHandler(self.options.log_file)) |
| 1244 | 1243 |
| 1245 testserver_base.TestServerRunner.run_server(self) | 1244 testserver_base.TestServerRunner.run_server(self) |
| 1246 | 1245 |
| 1247 | 1246 |
| 1248 if __name__ == '__main__': | 1247 if __name__ == '__main__': |
| 1249 sys.exit(PolicyServerRunner().main()) | 1248 sys.exit(PolicyServerRunner().main()) |
| OLD | NEW |