Index: client/cros/cros_ui_test.py |
diff --git a/client/cros/cros_ui_test.py b/client/cros/cros_ui_test.py |
index 9c92d1f4ac342846162416aed67b8e2d906fe45c..eee49d15c5c44cfba1b9cea6f4b9745037752f00 100644 |
--- a/client/cros/cros_ui_test.py |
+++ b/client/cros/cros_ui_test.py |
@@ -202,13 +202,10 @@ class UITest(test.test): |
# Determine the module directory. |
dirname = os.path.dirname(__file__) |
mock_certfile = os.path.join(dirname, 'mock_owner_cert.pem') |
- mock_signedprefsfile = os.path.join(dirname, 'mock_owner.preferences') |
mock_signedpolicyfile = os.path.join(dirname, 'mock_owner.policy') |
utils.open_write_close( |
constants.OWNER_KEY_FILE, |
ownership.cert_extract_pubkey_der(mock_certfile)) |
- shutil.copy(mock_signedprefsfile, |
- constants.SIGNED_PREFERENCES_FILE) |
shutil.copy(mock_signedpolicyfile, |
constants.SIGNED_POLICY_FILE) |
@@ -311,6 +308,34 @@ class UITest(test.test): |
return cros_ui.get_autox() |
+ def validate_basic_policy(self, basic_policy): |
+ # Pull in protobuf definitions. |
+ sys.path.append(self.srcdir) |
+ from device_management_backend_pb2 import PolicyFetchResponse |
+ from device_management_backend_pb2 import PolicyData |
+ from chrome_device_policy_pb2 import ChromeDeviceSettingsProto |
+ from chrome_device_policy_pb2 import UserWhitelistProto |
+ |
+ policy_proto = PolicyFetchResponse() |
+ policy_proto.ParseFromString(basic_policy) |
+ poldata = PolicyData() |
+ poldata.ParseFromString(policy_proto.policy_data) |
+ if (not poldata.HasField('username') or |
+ poldata.username != self.username): |
+ raise error.TestFail('Username not appropriately set in policy') |
+ |
+ polval = ChromeDeviceSettingsProto() |
+ polval.ParseFromString(poldata.policy_value) |
+ if (not polval.HasField('allow_new_users') or |
+ not polval.allow_new_users.HasField('allow_new_users') or |
+ not polval.allow_new_users): |
+ raise error.TestFail('Whitelisting not disabled in policy') |
+ |
+ if (not polval.HasField('user_whitelist') or |
+ not self.username in polval.user_whitelist.user_whitelist): |
+ raise error.TestFail('Owner not whitelisted') |
+ |
+ |
def stop_authserver(self): |
"""Tears down fake dns and fake Google Accounts server. If your |
subclass does not create these objects, you will want to override this |