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, os, time 6 7 from autotest_lib.client.bin import test, utils 8 from autotest_lib.client.common_lib import error 9 from autotest_lib.client.common_lib.cros import chrome, enrollment, kiosk_utils 10 11 TIMEOUT = 20 12 13 class enterprise_RemoraRequisition(test.test): 14 """Enroll as a Remora device.""" 15 version = 1 16 17 _HANGOUTS_EXT_ID = 'ikfcpmgefdpheiiomgmhlmmkihchmdlj' 18 19 def _CheckHangoutsExtensionContexts(self, browser): 20 ext_contexts = kiosk_utils.wait_for_kiosk_ext( 21 browser, self._HANGOUTS_EXT_ID) 22 ext_urls = set([context.EvaluateJavaScript('location.href;') 23 for context in ext_contexts]) 24 expected_urls = set( 25 ['chrome-extension://' + self._HANGOUTS_EXT_ID + '/' + path 26 for path in ['hangoutswindow.html?windowid=0', 27 '_generated_background_page.html']]) 28 if expected_urls != ext_urls: 29 raise error.TestFail( 30 'Unexpected extension context urls, expected %s, got %s' 31 % (expected_urls, ext_urls)) 32 33 34 def run_once(self): 35 user_id, password = utils.get_signin_credentials(os.path.join( 36 os.path.dirname(os.path.realpath(__file__)), 'credentials.txt')) 37 if not (user_id and password): 38 logging.warn('No credentials found - exiting test.') 39 return 40 41 with chrome.Chrome(auto_login=False, 42 disable_gaia_services=False) as cr: 43 enrollment.RemoraEnrollment(cr.browser, user_id, password) 44 # Timeout to allow for the device to stablize and go back to the 45 # login screen before proceeding. 46 time.sleep(TIMEOUT) 47 48 # This is a workaround fix for crbug.com/495847. A more permanent fix 49 # should be to get the hotrod app to auto launch after enrollment. 50 with chrome.Chrome(clear_enterprise_policy=False, 51 dont_override_profile=True, 52 disable_gaia_services=False, 53 disable_default_apps=False, 54 auto_login=False) as cr: 55 self._CheckHangoutsExtensionContexts(cr.browser) 56