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

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

Issue 5162006: Always send the device ID when making device management requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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
« no previous file with comments | « chrome/browser/policy/mock_device_management_backend.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python2.5 1 #!/usr/bin/python2.5
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """A bare-bones test server for testing cloud policy support. 6 """A bare-bones test server for testing cloud policy support.
7 7
8 This implements a simple cloud policy test server that can be used to test 8 This implements a simple cloud policy test server that can be used to test
9 chrome's device management service client. The policy information is read from 9 chrome's device management service client. The policy information is read from
10 from files in a directory. The files should contain policy definitions in JSON 10 from files in a directory. The files should contain policy definitions in JSON
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 Extracts the token from the request and passed to the server in order to 220 Extracts the token from the request and passed to the server in order to
221 look up the client. Returns a pair of token and error response. If the token 221 look up the client. Returns a pair of token and error response. If the token
222 is None, the error response is a pair of status code and error message. 222 is None, the error response is a pair of status code and error message.
223 223
224 Returns: 224 Returns:
225 A pair of DM token and error response. If the token is None, the message 225 A pair of DM token and error response. If the token is None, the message
226 will contain the error response to send back. 226 will contain the error response to send back.
227 """ 227 """
228 error = None 228 error = None
229 dmtoken = None 229 dmtoken = None
230 request_device_id = self.GetUniqueParam('deviceid')
230 match = re.match('GoogleDMToken token=(\\w+)', 231 match = re.match('GoogleDMToken token=(\\w+)',
231 self._headers.getheader('Authorization', '')) 232 self._headers.getheader('Authorization', ''))
232 if match: 233 if match:
233 dmtoken = match.group(1) 234 dmtoken = match.group(1)
234 if not dmtoken: 235 if not dmtoken:
235 error = dm.DeviceManagementResponse.DEVICE_MANAGEMENT_TOKEN_INVALID 236 error = dm.DeviceManagementResponse.DEVICE_MANAGEMENT_TOKEN_INVALID
236 elif not self._server.LookupDevice(dmtoken): 237 elif (not request_device_id or
238 not self._server.LookupDevice(dmtoken) == request_device_id):
237 error = dm.DeviceManagementResponse.DEVICE_NOT_FOUND 239 error = dm.DeviceManagementResponse.DEVICE_NOT_FOUND
238 else: 240 else:
239 return (dmtoken, None) 241 return (dmtoken, None)
240 242
241 response = dm.DeviceManagementResponse() 243 response = dm.DeviceManagementResponse()
242 response.error = error 244 response.error = error
243 245
244 self.DumpMessage('Response', response) 246 self.DumpMessage('Response', response)
245 247
246 return (None, (200, response.SerializeToString())) 248 return (None, (200, response.SerializeToString()))
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 return self._registered_devices.get(dmtoken, None) 311 return self._registered_devices.get(dmtoken, None)
310 312
311 def UnregisterDevice(self, dmtoken): 313 def UnregisterDevice(self, dmtoken):
312 """Unregisters a device identified by the given DM token. 314 """Unregisters a device identified by the given DM token.
313 315
314 Args: 316 Args:
315 dmtoken: The device management token provided by the client. 317 dmtoken: The device management token provided by the client.
316 """ 318 """
317 if dmtoken in self._registered_devices: 319 if dmtoken in self._registered_devices:
318 del self._registered_devices[dmtoken] 320 del self._registered_devices[dmtoken]
OLDNEW
« no previous file with comments | « chrome/browser/policy/mock_device_management_backend.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698