1 # Copyright (c) 2012 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 from autotest_lib.client.bin import test 6 from autotest_lib.client.common_lib import error, utils 7 from autotest_lib.client.cros import cryptohome 8 9 10 def run_cmd(cmd): 11 return utils.system_output(cmd + ' 2>&1', retain_output=True, 12 ignore_status=True) 13 14 class platform_CryptohomeChangePassword(test.test): 15 version = 1 16 17 18 def run_once(self): 19 test_user = 'this_is_a_local_test_account (at] chromium.org' 20 test_password = 'this_is_a_test_password' 21 22 # Remove any old test user account 23 cryptohome.remove_vault(test_user) 24 25 # Create a fresh test user account 26 cryptohome.mount_vault(test_user, test_password, create=True) 27 cryptohome.unmount_vault(test_user) 28 29 # Try to migrate the password 30 new_password = 'this_is_a_new_password' 31 cryptohome.change_password(test_user, test_password, new_password) 32 33 # Mount the test user account with the new password 34 cryptohome.mount_vault(test_user, new_password) 35 cryptohome.unmount_vault(test_user) 36 37 # Ensure the old password doesn't work 38 try: 39 cryptohome.mount_vault(test_user, test_password) 40 except cryptohome.ChromiumOSError: 41 pass 42 else: 43 raise error.TestFail("Mount with old password worked") 44 45 # Remove the test user account 46 cryptohome.remove_vault(test_user) 47