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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 dmtoken_chars = [] | 612 dmtoken_chars = [] |
613 while len(dmtoken_chars) < 32: | 613 while len(dmtoken_chars) < 32: |
614 dmtoken_chars.append(random.choice('0123456789abcdef')) | 614 dmtoken_chars.append(random.choice('0123456789abcdef')) |
615 dmtoken = ''.join(dmtoken_chars) | 615 dmtoken = ''.join(dmtoken_chars) |
616 allowed_policy_types = { | 616 allowed_policy_types = { |
617 dm.DeviceRegisterRequest.USER: ['google/chromeos/user'], | 617 dm.DeviceRegisterRequest.USER: ['google/chromeos/user'], |
618 dm.DeviceRegisterRequest.DEVICE: ['google/chromeos/device'], | 618 dm.DeviceRegisterRequest.DEVICE: ['google/chromeos/device'], |
619 dm.DeviceRegisterRequest.TT: ['google/chromeos/user'], | 619 dm.DeviceRegisterRequest.TT: ['google/chromeos/user'], |
620 } | 620 } |
621 if machine_id in KIOSK_MACHINE_IDS: | 621 if machine_id in KIOSK_MACHINE_IDS: |
622 enrollment_mode = dm.DeviceRegisterResponse.KIOSK | 622 enrollment_mode = dm.DeviceRegisterResponse.RETAIL |
623 else: | 623 else: |
624 enrollment_mode = dm.DeviceRegisterResponse.ENTERPRISE | 624 enrollment_mode = dm.DeviceRegisterResponse.ENTERPRISE |
625 self._registered_tokens[dmtoken] = { | 625 self._registered_tokens[dmtoken] = { |
626 'device_id': device_id, | 626 'device_id': device_id, |
627 'device_token': dmtoken, | 627 'device_token': dmtoken, |
628 'allowed_policy_types': allowed_policy_types[type], | 628 'allowed_policy_types': allowed_policy_types[type], |
629 'machine_name': 'chromeos-' + machine_id, | 629 'machine_name': 'chromeos-' + machine_id, |
630 'machine_id': machine_id, | 630 'machine_id': machine_id, |
631 'enrollment_mode': enrollment_mode, | 631 'enrollment_mode': enrollment_mode, |
632 } | 632 } |
(...skipping 22 matching lines...) Expand all Loading... |
655 return self._registered_tokens.get(dmtoken, None) | 655 return self._registered_tokens.get(dmtoken, None) |
656 | 656 |
657 def UnregisterDevice(self, dmtoken): | 657 def UnregisterDevice(self, dmtoken): |
658 """Unregisters a device identified by the given DM token. | 658 """Unregisters a device identified by the given DM token. |
659 | 659 |
660 Args: | 660 Args: |
661 dmtoken: The device management token provided by the client. | 661 dmtoken: The device management token provided by the client. |
662 """ | 662 """ |
663 if dmtoken in self._registered_tokens.keys(): | 663 if dmtoken in self._registered_tokens.keys(): |
664 del self._registered_tokens[dmtoken] | 664 del self._registered_tokens[dmtoken] |
OLD | NEW |