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

Side by Side Diff: client/site_tests/login_OwnershipRetaken/login_OwnershipRetaken.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, 8 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
(Empty)
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
3 # found in the LICENSE file.
4
5 import dbus
6 import gobject
7 import logging
8 import sys
9 import os
10 import tempfile
11
12 from autotest_lib.client.bin import test, utils
13 from autotest_lib.client.common_lib import autotemp, error
14 from autotest_lib.client.cros import constants, cros_ui, cryptohome, login
15 from autotest_lib.client.cros import cros_ui_test, ownership
16
17 from dbus.mainloop.glib import DBusGMainLoop
18
19
20 class login_OwnershipRetaken(cros_ui_test.UITest):
21 version = 1
22
23 _got_new_key = False
24 _got_new_policy = False
25
26 def setup(self):
27 os.chdir(self.srcdir)
28 utils.make('OUT_DIR=.')
29
30
31 def __handle_new_key(self, success):
32 self._got_new_key = (success == 'success')
33
34
35 def __handle_new_policy(self, success):
36 self._got_new_policy = (success == 'success')
37
38
39 def __received_signals(self):
40 """Process dbus events"""
41 context = gobject.MainLoop().get_context()
42 while context.iteration(False):
43 pass
44 return self._got_new_key and self._got_new_policy
45
46
47 def initialize(self, creds='$mockowner'):
48 assert creds == '$mockowner', "Must use mockowner creds for this test."
49 super(login_OwnershipRetaken, self).initialize(creds)
50 ownership.listen_to_session_manager_signal(self.__handle_new_key,
51 'SetOwnerKeyComplete')
52 ownership.listen_to_session_manager_signal(self.__handle_new_policy,
53 'PropertyChangeComplete')
54
55
56 def run_once(self):
57 # wait for new-owner-key signal, property-changed signal.
58 utils.poll_for_condition(
59 condition=lambda: self.__received_signals(),
60 desc='Retaking of ownership complete.',
61 timeout=constants.DEFAULT_OWNERSHIP_TIMEOUT)
62
63 # grab key, ensure that it's different than known key
64 if (utils.read_file(constants.OWNER_KEY_FILE) ==
65 ownership.known_pubkey()):
66 raise error.TestFail('Owner key should have changed!')
67
68 # RetrievePolicy, check sig against new key, check properties
69 sm = ownership.connect_to_session_manager()
70 retrieved_policy = sm.RetrievePolicy(byte_arrays=True)
71 if retrieved_policy is None:
72 raise error.TestFail('Policy not found')
73 self.validate_basic_policy(retrieved_policy)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698