• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5from autotest_lib.client.bin import test
6from autotest_lib.client.common_lib import error
7from autotest_lib.client.cros import cryptohome
8
9class platform_CryptohomeMount(test.test):
10    """Validates basic cryptohome creation and mounting."""
11    version = 1
12
13
14    def run_once(self):
15        test_user = 'this_is_a_local_test_account@chromium.org';
16        test_password = 'this_is_a_test_password';
17        # Get the hash for the test user account
18        user_hash = cryptohome.get_user_hash(test_user)
19        proxy = cryptohome.CryptohomeProxy()
20
21        # Remove the test user account
22        proxy.remove(test_user)
23
24        # Mount the test user account
25        if not proxy.mount(test_user, test_password, create=True):
26          raise error.TestFail('Failed to create and mount the test user')
27
28        # Unmount the directory
29        if not proxy.unmount(test_user):
30          raise error.TestFail('Failed to unmount test user')
31
32        # Ensure that the user directory is not mounted
33        if proxy.is_mounted(test_user):
34          raise error.TestFail('Cryptohome mounted after unmount!')
35
36        # Make sure that an incorrect password fails
37        incorrect_password = 'this_is_an_incorrect_password'
38        if proxy.mount(test_user, incorrect_password):
39          raise error.TestFail('Cryptohome mounted with a bad password.')
40        # Ensure that the user directory is not mounted
41        if proxy.is_mounted(test_user):
42          raise error.TestFail('Cryptohome mounted even though mount() failed')
43
44        # Remove the test user account
45        if not proxy.remove(test_user):
46          raise error.TestFail('Cryptohome could not clean up vault')
47