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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 if signing_key: | 805 if signing_key: |
806 policy_data.public_key_version = current_key_index + 1 | 806 policy_data.public_key_version = current_key_index + 1 |
807 | 807 |
808 if username: | 808 if username: |
809 policy_data.username = username | 809 policy_data.username = username |
810 else: | 810 else: |
811 # If the correct |username| is unknown, rely on a manually-configured | 811 # If the correct |username| is unknown, rely on a manually-configured |
812 # username from the configuration file or use a default. | 812 # username from the configuration file or use a default. |
813 policy_data.username = policy.get('policy_user', 'user@example.com') | 813 policy_data.username = policy.get('policy_user', 'user@example.com') |
814 policy_data.device_id = token_info['device_id'] | 814 policy_data.device_id = token_info['device_id'] |
815 | |
816 # Set affiliation IDs so that user was managed on the device. | |
817 device_affiliation_ids = policy.get('device_affiliation_ids') | |
818 if device_affiliation_ids: | |
819 policy_data.device_affiliation_ids.extend(device_affiliation_ids) | |
820 | |
821 user_affiliation_ids = policy.get('user_affiliation_ids') | |
822 if user_affiliation_ids: | |
823 policy_data.user_affiliation_ids.extend(user_affiliation_ids) | |
824 | |
825 signed_data = policy_data.SerializeToString() | 815 signed_data = policy_data.SerializeToString() |
826 | 816 |
827 response.policy_data = signed_data | 817 response.policy_data = signed_data |
828 if signing_key: | 818 if signing_key: |
829 response.policy_data_signature = ( | 819 response.policy_data_signature = ( |
830 bytes(signing_key['private_key'].hashAndSign(signed_data))) | 820 bytes(signing_key['private_key'].hashAndSign(signed_data))) |
831 if msg.public_key_version != current_key_index + 1: | 821 if msg.public_key_version != current_key_index + 1: |
832 response.new_public_key = signing_key['public_key'] | 822 response.new_public_key = signing_key['public_key'] |
833 | 823 |
834 # Set the verification signature appropriate for the policy domain. | 824 # Set the verification signature appropriate for the policy domain. |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 if (self.options.log_to_console): | 1303 if (self.options.log_to_console): |
1314 logger.addHandler(logging.StreamHandler()) | 1304 logger.addHandler(logging.StreamHandler()) |
1315 if (self.options.log_file): | 1305 if (self.options.log_file): |
1316 logger.addHandler(logging.FileHandler(self.options.log_file)) | 1306 logger.addHandler(logging.FileHandler(self.options.log_file)) |
1317 | 1307 |
1318 testserver_base.TestServerRunner.run_server(self) | 1308 testserver_base.TestServerRunner.run_server(self) |
1319 | 1309 |
1320 | 1310 |
1321 if __name__ == '__main__': | 1311 if __name__ == '__main__': |
1322 sys.exit(PolicyServerRunner().main()) | 1312 sys.exit(PolicyServerRunner().main()) |
OLD | NEW |