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 5import logging 6 7from autotest_lib.client.bin import utils 8from autotest_lib.client.common_lib.cros import chrome 9 10 11def _ExecuteOobeCmd(browser, cmd): 12 logging.info('Invoking ' + cmd) 13 oobe = browser.oobe 14 oobe.WaitForJavaScriptCondition('typeof Oobe !== \'undefined\'', 15 timeout=10) 16 oobe.ExecuteJavaScript(cmd) 17 18 19def SwitchToRemora(browser): 20 """Switch to Remora enrollment. 21 22 @param browser: telemetry browser object. 23 """ 24 chrome.Chrome.wait_for_browser_restart( 25 lambda: _ExecuteOobeCmd(browser, 26 'Oobe.remoraRequisitionForTesting();')) 27 utils.poll_for_condition(lambda: browser.oobe_exists, timeout=30) 28 29 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) 38 chrome.Chrome.wait_for_browser_restart( 39 lambda: browser.oobe.NavigateGaiaLogin( 40 user_id, password, enterprise_enroll=True, 41 for_user_triggered_enrollment=False)) 42 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)) 55