1# Copyright 2014 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.server import afe_utils
6from autotest_lib.server import autotest
7from autotest_lib.server import test
8
9class platform_CryptohomeMigrateChapsToken(test.test):
10    """ This test checks to see if Chaps generated keys are
11        available after a ChromeOS autoupdate.
12    """
13    version = 1
14
15    CLIENT_TEST = 'platform_CryptohomeMigrateChapsTokenClient'
16
17
18    def run_once(self, host, baseline_version=None):
19        # Save the build on the DUT, because we want to provision it after
20        # the test.
21        final_version = afe_utils.get_build(host)
22        if baseline_version:
23            version = baseline_version
24        else:
25            board_name = host.get_board().split(':')[1]
26            version = "%s-release/R37-3773.0.0" % board_name
27
28        # Downgrade to baseline version and run client side test.
29        self.job.run_test('provision_AutoUpdate', host=host,
30                          value=version)
31        client_at = autotest.Autotest(host)
32        client_at.run_test(self.CLIENT_TEST, generate_key=True)
33        # Upgrade back to latest version and see if the key migration
34        # succeeded.
35        self.job.run_test('provision_AutoUpdate', host=host,
36                          value=final_version)
37        client_at.run_test(self.CLIENT_TEST, generate_key=False)
38