• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 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
5import logging
6import os
7import time
8
9from autotest_lib.client.bin import test, utils
10from autotest_lib.client.common_lib import error
11from autotest_lib.client.common_lib.cros import chrome
12from autotest_lib.client.common_lib.cros import enrollment
13from autotest_lib.client.common_lib.cros import kiosk_utils
14from autotest_lib.client.common_lib import utils as utils2
15
16KIOSK_MODE = 'Starting kiosk mode...'
17
18
19class enterprise_KioskEnrollment(test.test):
20    """Enroll the device in enterprise."""
21    version = 1
22
23    APP_NAME = 'chromesign'
24    EXT_ID = 'odjaaghiehpobimgdjjfofmablbaleem'
25    EXT_PAGE = 'viewer.html'
26
27    def run_once(self, kiosk_app_attributes=None):
28        if kiosk_app_attributes:
29            self.APP_NAME, self.EXT_ID, self.EXT_PAGE = \
30                    kiosk_app_attributes.rstrip().split(':')
31        user_id, password = utils.get_signin_credentials(os.path.join(
32                os.path.dirname(os.path.realpath(__file__)),
33                'credentials.' + self.APP_NAME))
34        if not (user_id and password):
35            logging.warn('No credentials found - exiting test.')
36            return
37
38        with chrome.Chrome(auto_login=False,
39                           disable_gaia_services=False) as cr:
40            enrollment.EnterpriseEnrollment(cr.browser, user_id, password)
41
42        time.sleep(15)
43        running_apps = utils2.system_output(
44            'cat /var/log/messages | grep kiosk')
45        if KIOSK_MODE not in running_apps:
46            raise error.TestFail(
47                'DUT did not enter kiosk mode. and it should have.')
48