| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium OS 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 import dbus | 5 import dbus |
| 6 import dbus.glib | 6 import dbus.glib |
| 7 import logging | 7 import logging |
| 8 import sys | 8 import sys |
| 9 import os | 9 import os |
| 10 from autotest_lib.client.bin import utils | 10 from autotest_lib.client.bin import utils |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 is_creating_owner=True) | 26 is_creating_owner=True) |
| 27 if os.access(constants.OWNER_KEY_FILE, os.F_OK): | 27 if os.access(constants.OWNER_KEY_FILE, os.F_OK): |
| 28 raise error.TestFail("Ownership already taken!") | 28 raise error.TestFail("Ownership already taken!") |
| 29 self.login(self.username, self.password) | 29 self.login(self.username, self.password) |
| 30 | 30 |
| 31 | 31 |
| 32 def run_once(self): | 32 def run_once(self): |
| 33 login.wait_for_ownership() | 33 login.wait_for_ownership() |
| 34 | 34 |
| 35 sm = ownership.connect_to_session_manager() | 35 sm = ownership.connect_to_session_manager() |
| 36 | |
| 37 retrieved_policy = sm.RetrievePolicy(byte_arrays=True) | 36 retrieved_policy = sm.RetrievePolicy(byte_arrays=True) |
| 38 if retrieved_policy is None: | 37 if retrieved_policy is None: |
| 39 raise error.TestFail('Policy not found') | 38 raise error.TestFail('Policy not found') |
| 40 | 39 self.validate_basic_policy(retrieved_policy) |
| 41 # Pull in protobuf definitions. | |
| 42 sys.path.append(self.srcdir) | |
| 43 from device_management_backend_pb2 import PolicyFetchResponse | |
| 44 from device_management_backend_pb2 import PolicyData | |
| 45 from chrome_device_policy_pb2 import ChromeDeviceSettingsProto | |
| 46 from chrome_device_policy_pb2 import UserWhitelistProto | |
| 47 | |
| 48 policy_proto = PolicyFetchResponse() | |
| 49 policy_proto.ParseFromString(retrieved_policy) | |
| 50 poldata = PolicyData() | |
| 51 poldata.ParseFromString(policy_proto.policy_data) | |
| 52 if (not poldata.HasField('username') or | |
| 53 poldata.username != self.username): | |
| 54 raise error.TestFail('Username not appropriately set in policy') | |
| 55 | |
| 56 polval = ChromeDeviceSettingsProto() | |
| 57 polval.ParseFromString(poldata.policy_value) | |
| 58 if (not polval.HasField('allow_new_users') or | |
| 59 not polval.allow_new_users.HasField('allow_new_users') or | |
| 60 not polval.allow_new_users): | |
| 61 raise error.TestFail('Whitelisting not disabled in policy') | |
| 62 | |
| 63 if (not polval.HasField('user_whitelist') or | |
| 64 not self.username in polval.user_whitelist.user_whitelist): | |
| 65 raise error.TestFail('Owner not whitelisted') | |
| OLD | NEW |