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 for aff_id in device_affiliation_ids: | |
820 policy_data.device_affiliation_ids.append(aff_id) | |
Mattias Nissler (ping if slow)
2015/07/29 20:08:13
Doesn't this work?
policy_data.device_affiliation
peletskyi
2015/07/30 11:02:27
Done.
| |
821 | |
822 user_affiliation_ids = policy.get('user_affiliation_ids') | |
823 if user_affiliation_ids: | |
824 for aff_id in user_affiliation_ids: | |
Mattias Nissler (ping if slow)
2015/07/29 20:08:13
ditto
peletskyi
2015/07/30 11:02:27
Done.
| |
825 policy_data.user_affiliation_ids.append(aff_id) | |
826 | |
815 signed_data = policy_data.SerializeToString() | 827 signed_data = policy_data.SerializeToString() |
816 | 828 |
817 response.policy_data = signed_data | 829 response.policy_data = signed_data |
818 if signing_key: | 830 if signing_key: |
819 response.policy_data_signature = ( | 831 response.policy_data_signature = ( |
820 bytes(signing_key['private_key'].hashAndSign(signed_data))) | 832 bytes(signing_key['private_key'].hashAndSign(signed_data))) |
821 if msg.public_key_version != current_key_index + 1: | 833 if msg.public_key_version != current_key_index + 1: |
822 response.new_public_key = signing_key['public_key'] | 834 response.new_public_key = signing_key['public_key'] |
823 | 835 |
824 # Set the verification signature appropriate for the policy domain. | 836 # Set the verification signature appropriate for the policy domain. |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1303 if (self.options.log_to_console): | 1315 if (self.options.log_to_console): |
1304 logger.addHandler(logging.StreamHandler()) | 1316 logger.addHandler(logging.StreamHandler()) |
1305 if (self.options.log_file): | 1317 if (self.options.log_file): |
1306 logger.addHandler(logging.FileHandler(self.options.log_file)) | 1318 logger.addHandler(logging.FileHandler(self.options.log_file)) |
1307 | 1319 |
1308 testserver_base.TestServerRunner.run_server(self) | 1320 testserver_base.TestServerRunner.run_server(self) |
1309 | 1321 |
1310 | 1322 |
1311 if __name__ == '__main__': | 1323 if __name__ == '__main__': |
1312 sys.exit(PolicyServerRunner().main()) | 1324 sys.exit(PolicyServerRunner().main()) |
OLD | NEW |