Home | History | Annotate | Download | only in cros
      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 
      5 import logging
      6 
      7 from autotest_lib.client.bin import utils
      8 from autotest_lib.client.common_lib.cros import chrome
      9 
     10 
     11 def _ExecuteOobeCmd(browser, cmd):
     12     logging.info('Invoking ' + cmd)
     13     oobe = browser.oobe
     14     oobe.WaitForJavaScriptExpression('typeof Oobe !== \'undefined\'', 10)
     15     oobe.ExecuteJavaScript(cmd)
     16 
     17 
     18 def SwitchToRemora(browser):
     19     """Switch to Remora enrollment.
     20 
     21     @param browser: telemetry browser object.
     22     """
     23     chrome.Chrome.wait_for_browser_restart(
     24             lambda: _ExecuteOobeCmd(browser,
     25                                     'Oobe.remoraRequisitionForTesting();'))
     26     utils.poll_for_condition(lambda: browser.oobe_exists, timeout=30)
     27 
     28 
     29 def RemoraEnrollment(browser, user_id, password):
     30     """Enterprise login for a Remora device.
     31 
     32     @param browser: telemetry browser object.
     33     @param user_id: login credentials user_id.
     34     @param password: login credentials password.
     35     """
     36     SwitchToRemora(browser)
     37     chrome.Chrome.wait_for_browser_restart(
     38             lambda: browser.oobe.NavigateGaiaLogin(
     39                     user_id, password, enterprise_enroll=True,
     40                     for_user_triggered_enrollment=False))
     41