• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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.
4from autotest_lib.client.common_lib import error
5from autotest_lib.client.common_lib.cros import retry
6
7from autotest_lib.client.cros import cryptohome
8from autotest_lib.client.cros.enterprise import enterprise_policy_base
9
10from py_utils import TimeoutException
11
12class policy_DeviceEphemeralUsersEnabled(
13        enterprise_policy_base.EnterprisePolicyTest):
14    """Test for the DeviceEphemeralUsersEnabled policy."""
15    version = 1
16    _POLICY = 'DeviceEphemeralUsersEnabled'
17
18    def verify_permanent_vault(self, case):
19        if case and cryptohome.is_permanent_vault_mounted(
20            user=enterprise_policy_base.USERNAME):
21                raise error.TestFail(
22                    'User should not be permanently vaulted in '
23                    'Ephemeral mode.')
24
25        if not case:
26            cryptohome.is_permanent_vault_mounted(
27                user=enterprise_policy_base.USERNAME, allow_fail=True)
28
29    # Prevents client tests that are kicked off via server tests from flaking.
30    @retry.retry(TimeoutException, timeout_min=5, delay_sec=10)
31    def _run_setup_case(self, case):
32        self.setup_case(device_policies={self._POLICY: case}, enroll=True)
33
34    def run_once(self, case):
35        """
36        Entry point of this test.
37
38        @param case: True, False, or None for the value of the policy.
39
40        """
41        self._run_setup_case(case)
42        self.verify_permanent_vault(case)