Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: client/cros/cros_ui_test.py

Issue 6880288: [autotest] Add test for the re-taking of ownership after the owner key is lost (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: cleanup more unneeded vars Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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, logging, os, re, shutil, socket, sys 5 import dbus, logging, os, re, shutil, socket, sys
6 import common 6 import common
7 import auth_server, constants, cryptohome, dns_server 7 import auth_server, constants, cryptohome, dns_server
8 import cros_logging, cros_ui, login, ownership 8 import cros_logging, cros_ui, login, ownership
9 from autotest_lib.client.bin import test, utils 9 from autotest_lib.client.bin import test, utils
10 from autotest_lib.client.common_lib import error 10 from autotest_lib.client.common_lib import error
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 if self.auto_login: 195 if self.auto_login:
196 self.login(self.username, self.password) 196 self.login(self.username, self.password)
197 if is_creating_owner: 197 if is_creating_owner:
198 login.wait_for_ownership() 198 login.wait_for_ownership()
199 199
200 def __fake_ownership(self): 200 def __fake_ownership(self):
201 """Fake ownership by generating the necessary magic files.""" 201 """Fake ownership by generating the necessary magic files."""
202 # Determine the module directory. 202 # Determine the module directory.
203 dirname = os.path.dirname(__file__) 203 dirname = os.path.dirname(__file__)
204 mock_certfile = os.path.join(dirname, 'mock_owner_cert.pem') 204 mock_certfile = os.path.join(dirname, 'mock_owner_cert.pem')
205 mock_signedprefsfile = os.path.join(dirname, 'mock_owner.preferences')
206 mock_signedpolicyfile = os.path.join(dirname, 'mock_owner.policy') 205 mock_signedpolicyfile = os.path.join(dirname, 'mock_owner.policy')
207 utils.open_write_close( 206 utils.open_write_close(
208 constants.OWNER_KEY_FILE, 207 constants.OWNER_KEY_FILE,
209 ownership.cert_extract_pubkey_der(mock_certfile)) 208 ownership.cert_extract_pubkey_der(mock_certfile))
210 shutil.copy(mock_signedprefsfile,
211 constants.SIGNED_PREFERENCES_FILE)
212 shutil.copy(mock_signedpolicyfile, 209 shutil.copy(mock_signedpolicyfile,
213 constants.SIGNED_POLICY_FILE) 210 constants.SIGNED_POLICY_FILE)
214 211
215 212
216 def __canonicalize(self, credential): 213 def __canonicalize(self, credential):
217 """Perform basic canonicalization of |email_address| 214 """Perform basic canonicalization of |email_address|
218 215
219 Perform basic canonicalization of |email_address|, taking 216 Perform basic canonicalization of |email_address|, taking
220 into account that gmail does not consider '.' or caps inside a 217 into account that gmail does not consider '.' or caps inside a
221 username to matter. It also ignores everything after a '+'. 218 username to matter. It also ignores everything after a '+'.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 def get_autox(self): 301 def get_autox(self):
305 """Return a new autox instance. 302 """Return a new autox instance.
306 303
307 Explicitly cache this in your testcase if you want to reuse the 304 Explicitly cache this in your testcase if you want to reuse the
308 object, but beware that logging out will invalidate any existing 305 object, but beware that logging out will invalidate any existing
309 sessions. 306 sessions.
310 """ 307 """
311 return cros_ui.get_autox() 308 return cros_ui.get_autox()
312 309
313 310
311 def validate_basic_policy(self, basic_policy):
312 # Pull in protobuf definitions.
313 sys.path.append(self.srcdir)
314 from device_management_backend_pb2 import PolicyFetchResponse
315 from device_management_backend_pb2 import PolicyData
316 from chrome_device_policy_pb2 import ChromeDeviceSettingsProto
317 from chrome_device_policy_pb2 import UserWhitelistProto
318
319 policy_proto = PolicyFetchResponse()
320 policy_proto.ParseFromString(basic_policy)
321 poldata = PolicyData()
322 poldata.ParseFromString(policy_proto.policy_data)
323 if (not poldata.HasField('username') or
324 poldata.username != self.username):
325 raise error.TestFail('Username not appropriately set in policy')
326
327 polval = ChromeDeviceSettingsProto()
328 polval.ParseFromString(poldata.policy_value)
329 if (not polval.HasField('allow_new_users') or
330 not polval.allow_new_users.HasField('allow_new_users') or
331 not polval.allow_new_users):
332 raise error.TestFail('Whitelisting not disabled in policy')
333
334 if (not polval.HasField('user_whitelist') or
335 not self.username in polval.user_whitelist.user_whitelist):
336 raise error.TestFail('Owner not whitelisted')
337
338
314 def stop_authserver(self): 339 def stop_authserver(self):
315 """Tears down fake dns and fake Google Accounts server. If your 340 """Tears down fake dns and fake Google Accounts server. If your
316 subclass does not create these objects, you will want to override this 341 subclass does not create these objects, you will want to override this
317 method as well. 342 method as well.
318 """ 343 """
319 if hasattr(self, '_authServer'): 344 if hasattr(self, '_authServer'):
320 self.revert_dns() 345 self.revert_dns()
321 self._authServer.stop() 346 self._authServer.stop()
322 self._dnsServer.stop() 347 self._dnsServer.stop()
323 348
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 417
393 self.stop_authserver() 418 self.stop_authserver()
394 self.__log_crashed_processes(self.crash_blacklist) 419 self.__log_crashed_processes(self.crash_blacklist)
395 420
396 421
397 def get_auth_endpoint_misses(self): 422 def get_auth_endpoint_misses(self):
398 if hasattr(self, '_authServer'): 423 if hasattr(self, '_authServer'):
399 return self._authServer.get_endpoint_misses() 424 return self._authServer.get_endpoint_misses()
400 else: 425 else:
401 return {} 426 return {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698