OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 import subprocess | 7 import subprocess |
8 import sys | 8 import sys |
9 | 9 |
10 import pyauto_functional # Must be imported before pyauto | 10 import pyauto_functional # Must be imported before pyauto |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 self.SetProxySettingOnChromeOS(proxy_dict) | 310 self.SetProxySettingOnChromeOS(proxy_dict) |
311 | 311 |
312 """Test that login fails.""" | 312 """Test that login fails.""" |
313 credentials = self._ValidCredentials() | 313 credentials = self._ValidCredentials() |
314 self.assertRaises( | 314 self.assertRaises( |
315 pyauto_errors.JSONInterfaceError, | 315 pyauto_errors.JSONInterfaceError, |
316 lambda: self.Login(credentials['username'], | 316 lambda: self.Login(credentials['username'], |
317 credentials['password']) | 317 credentials['password']) |
318 ) | 318 ) |
319 | 319 |
320 class ChromeosLoginCachedCredentialsUserPod(pyauto.PyUITest): | 320 class ChromeosLoginCachedCredentialsUserPod(ChromeosLogin): |
321 """TestCase for Logging into ChromeOS with cached credentials and | 321 """TestCase for Logging into ChromeOS with cached credentials and |
322 invalid proxy settings. | 322 invalid proxy settings. |
323 """ | 323 """ |
324 assert os.geteuid() == 0, 'Need to run this test as root' | 324 assert os.geteuid() == 0, 'Need to run this test as root' |
325 | 325 |
326 def ShouldAutoLogin(self): | 326 def ShouldAutoLogin(self): |
327 return False | 327 return False |
328 | 328 |
329 def setUp(self): | 329 def setUp(self): |
330 # We want a clean session_manager instance for every run, | 330 # We want a clean session_manager instance for every run, |
331 # so restart ui now. | 331 # so restart ui now. |
332 cros_ui.stop(allow_fail=True) | 332 cros_ui.stop(allow_fail=True) |
333 cryptohome.remove_all_vaults() | 333 cryptohome.remove_all_vaults() |
334 cros_ui.start(wait_for_login_prompt=False) | 334 cros_ui.start(wait_for_login_prompt=True) |
335 pyauto.PyUITest.setUp(self) | 335 pyauto.PyUITest.setUp(self) |
336 | 336 |
337 def tearDown(self): | 337 def tearDown(self): |
338 self.ResetProxySettingsOnChromeOS() | 338 self.ResetProxySettingsOnChromeOS() |
339 pyauto.PyUITest.tearDown(self) | 339 pyauto.PyUITest.tearDown(self) |
340 | 340 |
341 def _ValidCredentials(self, account_type='test_google_account'): | 341 def _ValidCredentials(self, account_type='test_google_account'): |
342 """Obtains a valid username and password from a data file. | 342 """Obtains a valid username and password from a data file. |
343 | 343 |
344 Returns: | 344 Returns: |
345 A dictionary with the keys 'username' and 'password' | 345 A dictionary with the keys 'username' and 'password' |
346 """ | 346 """ |
347 return self.GetPrivateInfo()[account_type] | 347 return self.GetPrivateInfo()[account_type] |
348 | 348 |
349 def testCachedCredentialsUserPod(self): | 349 def testCachedCredentialsUserPod(self): |
350 """Test that we can login without connectivity if we have so before. | 350 """Test that we can login without connectivity if we have so before. |
351 | 351 |
352 This test is currently disabled because testGoodLogin tries to | 352 This test is currently disabled because testGoodLogin tries to |
353 add a user after setting proxies, which is supposed to fail. To | 353 add a user after setting proxies, which is supposed to fail. To |
354 make it pass we need a hook that simply calls Login on the delegate | 354 make it pass we need a hook that simply calls Login on the delegate |
355 in webui_login_display.cc ::ShowSigninScreenForCreds. | 355 in webui_login_display.cc ::ShowSigninScreenForCreds. |
356 """ | 356 """ |
| 357 credentials = self._ValidCredentials() |
357 self.testGoodLogin() | 358 self.testGoodLogin() |
358 self.Logout() | 359 self.Logout() |
359 self.SetProxySettingOnChromeOS('singlehttp', '127.0.0.1') | 360 proxy_dict = { |
360 self.testGoodLogin() | 361 'url_path': 'singlehttp', |
361 self.ResetProxySettingsOnChromeOS() | 362 'proxy_url': '127.0.0.1', |
362 | 363 } |
| 364 self.SetProxySettingOnChromeOS(proxy_dict) |
| 365 self.LoginWithCachedCredentials(credentials['username'], |
| 366 credentials['password']) |
| 367 login_info = self.GetLoginInfo() |
| 368 self.assertTrue(login_info['is_logged_in'], msg='Login failed.') |
363 | 369 |
364 if __name__ == '__main__': | 370 if __name__ == '__main__': |
365 pyauto_functional.Main() | 371 pyauto_functional.Main() |
OLD | NEW |