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

Side by Side Diff: chrome/browser/policy/test/policy_testserver.py

Issue 1767443002: Add enterprise enrollment support for fake users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Check instance before derefing it Created 4 years, 8 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
OLDNEW
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 elif request_type == 'policy': 301 elif request_type == 'policy':
302 response = self.ProcessPolicy(rmsg, request_type) 302 response = self.ProcessPolicy(rmsg, request_type)
303 elif request_type == 'enterprise_check': 303 elif request_type == 'enterprise_check':
304 response = self.ProcessAutoEnrollment(rmsg.auto_enrollment_request) 304 response = self.ProcessAutoEnrollment(rmsg.auto_enrollment_request)
305 elif request_type == 'device_state_retrieval': 305 elif request_type == 'device_state_retrieval':
306 response = self.ProcessDeviceStateRetrievalRequest( 306 response = self.ProcessDeviceStateRetrievalRequest(
307 rmsg.device_state_retrieval_request) 307 rmsg.device_state_retrieval_request)
308 elif request_type == 'status_upload': 308 elif request_type == 'status_upload':
309 response = self.ProcessStatusUploadRequest( 309 response = self.ProcessStatusUploadRequest(
310 rmsg.device_status_report_request, rmsg.session_status_report_request) 310 rmsg.device_status_report_request, rmsg.session_status_report_request)
311 elif request_type == 'device_attribute_update_permission':
312 response = self.ProcessDeviceAttributeUpdatePermissionRequest()
313 elif request_type == 'device_attribute_update':
314 response = self.ProcessDeviceAttributeUpdateRequest()
315 elif request_type == 'remote_commands':
316 response = self.ProcessRemoteCommandsRequest()
311 else: 317 else:
312 return (400, 'Invalid request parameter') 318 return (400, 'Invalid request parameter')
313 319
314 if isinstance(response[1], basestring): 320 if isinstance(response[1], basestring):
315 body = response[1] 321 body = response[1]
316 elif isinstance(response[1], google.protobuf.message.Message): 322 elif isinstance(response[1], google.protobuf.message.Message):
317 self.DumpMessage('Response', response[1]) 323 self.DumpMessage('Response', response[1])
318 body = response[1].SerializeToString() 324 body = response[1].SerializeToString()
319 else: 325 else:
320 body = '' 326 body = ''
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 session_status_report_response = dm.SessionStatusReportResponse() 585 session_status_report_response = dm.SessionStatusReportResponse()
580 586
581 response = dm.DeviceManagementResponse() 587 response = dm.DeviceManagementResponse()
582 response.device_status_report_response.CopyFrom( 588 response.device_status_report_response.CopyFrom(
583 device_status_report_response) 589 device_status_report_response)
584 response.session_status_report_response.CopyFrom( 590 response.session_status_report_response.CopyFrom(
585 session_status_report_response) 591 session_status_report_response)
586 592
587 return (200, response) 593 return (200, response)
588 594
595 def ProcessDeviceAttributeUpdatePermissionRequest(self):
596 """Handles a device attribute update permission request.
597
598 Returns:
599 A tuple of HTTP status code and response data to send to the client.
600 """
601 response = dm.DeviceManagementResponse()
602 response.device_attribute_update_permission_response.result = (
603 dm.DeviceAttributeUpdatePermissionResponse.ATTRIBUTE_UPDATE_ALLOWED)
604
605 return (200, response)
606
607 def ProcessDeviceAttributeUpdateRequest(self):
608 """Handles a device attribute update request.
609
610 Returns:
611 A tuple of HTTP status code and response data to send to the client.
612 """
613 response = dm.DeviceManagementResponse()
614 response.device_attribute_update_response.result = (
615 dm.DeviceAttributeUpdateResponse.ATTRIBUTE_UPDATE_SUCCESS)
616
617 return (200, response)
618
619 def ProcessRemoteCommandsRequest(self):
620 """Handles a remote command request.
621
622 Returns:
623 A tuple of HTTP status code and response data to send to the client.
624 """
625 return (200, '')
626
589 def SetProtobufMessageField(self, group_message, field, field_value): 627 def SetProtobufMessageField(self, group_message, field, field_value):
590 """Sets a field in a protobuf message. 628 """Sets a field in a protobuf message.
591 629
592 Args: 630 Args:
593 group_message: The protobuf message. 631 group_message: The protobuf message.
594 field: The field of the message to set, it should be a member of 632 field: The field of the message to set, it should be a member of
595 group_message.DESCRIPTOR.fields. 633 group_message.DESCRIPTOR.fields.
596 field_value: The value to set. 634 field_value: The value to set.
597 """ 635 """
598 if field.label == field.LABEL_REPEATED: 636 if field.label == field.LABEL_REPEATED:
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 if (self.options.log_to_console): 1353 if (self.options.log_to_console):
1316 logger.addHandler(logging.StreamHandler()) 1354 logger.addHandler(logging.StreamHandler())
1317 if (self.options.log_file): 1355 if (self.options.log_file):
1318 logger.addHandler(logging.FileHandler(self.options.log_file)) 1356 logger.addHandler(logging.FileHandler(self.options.log_file))
1319 1357
1320 testserver_base.TestServerRunner.run_server(self) 1358 testserver_base.TestServerRunner.run_server(self)
1321 1359
1322 1360
1323 if __name__ == '__main__': 1361 if __name__ == '__main__':
1324 sys.exit(PolicyServerRunner().main()) 1362 sys.exit(PolicyServerRunner().main())
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/policy/wildcard_login_checker.cc ('k') | chrome/browser/resources/chromeos/login/login_shared.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698