| OLD | NEW |
| 1 #!/usr/bin/python2.5 | 1 #!/usr/bin/python2.5 |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 the file named device_management in the server's data directory. It contains | 10 the file named device_management in the server's data directory. It contains |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 Args: | 345 Args: |
| 346 group_message: The protobuf message. | 346 group_message: The protobuf message. |
| 347 field: The field of the message to set, it shuold be a member of | 347 field: The field of the message to set, it shuold be a member of |
| 348 group_message.DESCRIPTOR.fields. | 348 group_message.DESCRIPTOR.fields. |
| 349 field_value: The value to set. | 349 field_value: The value to set. |
| 350 ''' | 350 ''' |
| 351 if field.type == field.TYPE_BOOL: | 351 if field.type == field.TYPE_BOOL: |
| 352 assert type(field_value) == bool | 352 assert type(field_value) == bool |
| 353 elif field.type == field.TYPE_STRING: | 353 elif field.type == field.TYPE_STRING: |
| 354 assert type(field_value) == str | 354 assert type(field_value) == str or type(field_value) == unicode |
| 355 elif field.type == field.TYPE_INT64: | 355 elif field.type == field.TYPE_INT64: |
| 356 assert type(field_value) == int | 356 assert type(field_value) == int |
| 357 elif (field.type == field.TYPE_MESSAGE and | 357 elif (field.type == field.TYPE_MESSAGE and |
| 358 field.message_type.name == 'StringList'): | 358 field.message_type.name == 'StringList'): |
| 359 assert type(field_value) == list | 359 assert type(field_value) == list |
| 360 entries = group_message.__getattribute__(field.name).entries | 360 entries = group_message.__getattribute__(field.name).entries |
| 361 for list_item in field_value: | 361 for list_item in field_value: |
| 362 entries.append(list_item) | 362 entries.append(list_item) |
| 363 return | 363 return |
| 364 else: | 364 else: |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 return self._registered_tokens.get(dmtoken, None) | 607 return self._registered_tokens.get(dmtoken, None) |
| 608 | 608 |
| 609 def UnregisterDevice(self, dmtoken): | 609 def UnregisterDevice(self, dmtoken): |
| 610 """Unregisters a device identified by the given DM token. | 610 """Unregisters a device identified by the given DM token. |
| 611 | 611 |
| 612 Args: | 612 Args: |
| 613 dmtoken: The device management token provided by the client. | 613 dmtoken: The device management token provided by the client. |
| 614 """ | 614 """ |
| 615 if dmtoken in self._registered_tokens.keys(): | 615 if dmtoken in self._registered_tokens.keys(): |
| 616 del self._registered_tokens[dmtoken] | 616 del self._registered_tokens[dmtoken] |
| OLD | NEW |