OLD | NEW |
(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 dbus.glib |
| 7 import gobject |
| 8 import logging |
| 9 import random |
| 10 import string |
| 11 import os |
| 12 |
| 13 from autotest_lib.client.bin import test, utils |
| 14 from autotest_lib.client.common_lib import error |
| 15 from autotest_lib.client.cros import cryptohome, cros_ownership_test, ownership |
| 16 |
| 17 |
| 18 class login_RemoteOwnership(cros_ownership_test.OwnershipTest): |
| 19 version = 1 |
| 20 |
| 21 _poldata = 'hooberbloob' |
| 22 |
| 23 def setup(self): |
| 24 os.chdir(self.srcdir) |
| 25 utils.make('OUT_DIR=.') |
| 26 |
| 27 |
| 28 def run_once(self): |
| 29 sm = self.connect_to_session_manager() |
| 30 |
| 31 # Initial policy setup. |
| 32 (priv, pub) = ownership.pairgen_as_data() |
| 33 self.push_policy(self.generate_policy(priv, pub, self._poldata), sm) |
| 34 |
| 35 # Force re-key the device |
| 36 (priv, pub) = ownership.pairgen_as_data() |
| 37 self.push_policy(self.generate_policy(priv, pub, self._poldata), sm) |
| 38 |
| 39 # Rotate key gracefully. |
| 40 username = ''.join(random.sample(string.ascii_uppercase,6)) + "@foo.com" |
| 41 password = ''.join(random.sample(string.ascii_uppercase,6)) |
| 42 cryptohome.remove_vault(username) |
| 43 cryptohome.mount_vault(username, password, create=True) |
| 44 |
| 45 (new_priv, new_pub) = ownership.pairgen_as_data() |
| 46 |
| 47 if not sm.StartSession(username, ''): |
| 48 raise error.TestFail('Could not start session for random user') |
| 49 |
| 50 self.push_policy(self.generate_policy(key=new_priv, |
| 51 pubkey=new_pub, |
| 52 policy=self._poldata, |
| 53 old_key=priv), |
| 54 sm) |
| 55 |
| 56 if not sm.StopSession(''): |
| 57 raise error.TestFail('Could not stop session for random user') |
| 58 |
| 59 |
| 60 def cleanup(self): |
| 61 cryptohome.unmount_vault() |
| 62 super(login_RemoteOwnership, self).cleanup() |
OLD | NEW |