blob: 9973099737817f7e8ce83ff107cf251b557a4ff6 [file] [log] [blame]
Achuith Bhandarkar06b98e22014-05-13 11:56:16 -07001# 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
Achuith Bhandarkar6cb16162014-06-04 17:22:14 -07005import logging
Achuith Bhandarkar06b98e22014-05-13 11:56:16 -07006
7from autotest_lib.client.bin import utils
Achuith Bhandarkar88a2bab2015-07-09 17:36:25 -07008from autotest_lib.client.common_lib.cros import chrome
Achuith Bhandarkar06b98e22014-05-13 11:56:16 -07009
10
Achuith Bhandarkar06b98e22014-05-13 11:56:16 -070011def _ExecuteOobeCmd(browser, cmd):
12 logging.info('Invoking ' + cmd)
13 oobe = browser.oobe
Achuith Bhandarkar0309dc92017-02-02 16:05:18 -080014 oobe.WaitForJavaScriptCondition('typeof Oobe !== \'undefined\'',
15 timeout=10)
Achuith Bhandarkar06b98e22014-05-13 11:56:16 -070016 oobe.ExecuteJavaScript(cmd)
17
18
19def SwitchToRemora(browser):
20 """Switch to Remora enrollment.
21
22 @param browser: telemetry browser object.
23 """
Achuith Bhandarkar88a2bab2015-07-09 17:36:25 -070024 chrome.Chrome.wait_for_browser_restart(
Achuith Bhandarkar16ee9772015-01-23 17:18:18 -080025 lambda: _ExecuteOobeCmd(browser,
26 'Oobe.remoraRequisitionForTesting();'))
Achuith Bhandarkar06b98e22014-05-13 11:56:16 -070027 utils.poll_for_condition(lambda: browser.oobe_exists, timeout=30)
28
Achuith Bhandarkar06b98e22014-05-13 11:56:16 -070029
30def RemoraEnrollment(browser, user_id, password):
31 """Enterprise login for a Remora device.
32
33 @param browser: telemetry browser object.
34 @param user_id: login credentials user_id.
35 @param password: login credentials password.
36 """
37 SwitchToRemora(browser)
Achuith Bhandarkar88a2bab2015-07-09 17:36:25 -070038 chrome.Chrome.wait_for_browser_restart(
39 lambda: browser.oobe.NavigateGaiaLogin(
40 user_id, password, enterprise_enroll=True,
41 for_user_triggered_enrollment=False))
harpreet20b41202016-06-13 17:36:43 -070042
43
44def EnterpriseEnrollment(browser, user_id, password):
45 """Enterprise login for a kiosk device.
46
47 @param browser: telemetry browser object.
48 @param user_id: login credentials user_id.
49 @param password: login credentials password.
50 """
51 chrome.Chrome.wait_for_browser_restart(
52 lambda: browser.oobe.NavigateGaiaLogin(
53 user_id, password, enterprise_enroll=True,
54 for_user_triggered_enrollment=True))