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

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

Issue 12209070: Fix cloud policy duplicate registrations issue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Loads of tests Created 7 years, 10 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 | Annotate | Revision Log
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 SHA256_0 = hashlib.sha256('0').digest() 83 SHA256_0 = hashlib.sha256('0').digest()
84 84
85 # List of bad machine identifiers that trigger the |valid_serial_number_missing| 85 # List of bad machine identifiers that trigger the |valid_serial_number_missing|
86 # flag to be set set in the policy fetch response. 86 # flag to be set set in the policy fetch response.
87 BAD_MACHINE_IDS = [ '123490EN400015' ]; 87 BAD_MACHINE_IDS = [ '123490EN400015' ];
88 88
89 # List of machines that trigger the server to send kiosk enrollment response 89 # List of machines that trigger the server to send kiosk enrollment response
90 # for the register request. 90 # for the register request.
91 KIOSK_MACHINE_IDS = [ 'KIOSK' ]; 91 KIOSK_MACHINE_IDS = [ 'KIOSK' ];
92 92
93 # A special authentication token whose register request must have the
94 # re-register flag set. If that flag is not set when a register request with
95 # this token is received then the register is refused.
96 RE_REGISTER_MAGIC_TOKEN = 'reregistertoken'
97
93 class RequestHandler(object): 98 class RequestHandler(object):
94 """Decodes and handles device management requests from clients. 99 """Decodes and handles device management requests from clients.
95 100
96 The handler implements all the request parsing and protobuf message decoding 101 The handler implements all the request parsing and protobuf message decoding
97 and encoding. It calls back into the server to lookup, register, and 102 and encoding. It calls back into the server to lookup, register, and
98 unregister clients. 103 unregister clients.
99 """ 104 """
100 105
101 def __init__(self, server, path, headers, request): 106 def __init__(self, server, path, headers, request):
102 """Initialize the handler. 107 """Initialize the handler.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 209
205 policy = self._server.GetPolicies() 210 policy = self._server.GetPolicies()
206 if ('*' not in policy['managed_users'] and 211 if ('*' not in policy['managed_users'] and
207 auth not in policy['managed_users']): 212 auth not in policy['managed_users']):
208 return (403, 'Unmanaged') 213 return (403, 'Unmanaged')
209 214
210 device_id = self.GetUniqueParam('deviceid') 215 device_id = self.GetUniqueParam('deviceid')
211 if not device_id: 216 if not device_id:
212 return (400, 'Missing device identifier') 217 return (400, 'Missing device identifier')
213 218
219 if (auth == RE_REGISTER_MAGIC_TOKEN and
220 msg.reregister != True):
221 return (400, 'Expected reregister request')
Mattias Nissler (ping if slow) 2013/02/11 18:23:50 I'm concerned that we keep adding weirdness to the
Joao da Silva 2013/02/12 16:33:41 Reverted.
222
214 token_info = self._server.RegisterDevice(device_id, 223 token_info = self._server.RegisterDevice(device_id,
215 msg.machine_id, 224 msg.machine_id,
216 msg.type) 225 msg.type)
217 226
218 # Send back the reply. 227 # Send back the reply.
219 response = dm.DeviceManagementResponse() 228 response = dm.DeviceManagementResponse()
220 response.register_response.device_management_token = ( 229 response.register_response.device_management_token = (
221 token_info['device_token']) 230 token_info['device_token'])
222 response.register_response.machine_name = token_info['machine_name'] 231 response.register_response.machine_name = token_info['machine_name']
223 response.register_response.enrollment_type = token_info['enrollment_mode'] 232 response.register_response.enrollment_type = token_info['enrollment_mode']
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 return self._registered_tokens.get(dmtoken, None) 685 return self._registered_tokens.get(dmtoken, None)
677 686
678 def UnregisterDevice(self, dmtoken): 687 def UnregisterDevice(self, dmtoken):
679 """Unregisters a device identified by the given DM token. 688 """Unregisters a device identified by the given DM token.
680 689
681 Args: 690 Args:
682 dmtoken: The device management token provided by the client. 691 dmtoken: The device management token provided by the client.
683 """ 692 """
684 if dmtoken in self._registered_tokens.keys(): 693 if dmtoken in self._registered_tokens.keys():
685 del self._registered_tokens[dmtoken] 694 del self._registered_tokens[dmtoken]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698