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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 testGoodLogin(self): |
| 342 """Test that login is successful with valid credentials.""" |
| 343 credentials = self._ValidCredentials() |
| 344 self.Login(credentials['username'], credentials['password']) |
| 345 login_info = self.GetLoginInfo() |
| 346 self.assertTrue(login_info['is_logged_in'], msg='Login failed.') |
| 347 |
341 def _ValidCredentials(self, account_type='test_google_account'): | 348 def _ValidCredentials(self, account_type='test_google_account'): |
342 """Obtains a valid username and password from a data file. | 349 """Obtains a valid username and password from a data file. |
343 | 350 |
344 Returns: | 351 Returns: |
345 A dictionary with the keys 'username' and 'password' | 352 A dictionary with the keys 'username' and 'password' |
346 """ | 353 """ |
347 return self.GetPrivateInfo()[account_type] | 354 return self.GetPrivateInfo()[account_type] |
348 | 355 |
349 def testCachedCredentialsUserPod(self): | 356 def testCachedCredentialsUserPod(self): |
350 """Test that we can login without connectivity if we have so before. | 357 """Test that we can login without connectivity if we have so before.""" |
351 | 358 credentials = self._ValidCredentials() |
352 This test is currently disabled because testGoodLogin tries 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 | |
355 in webui_login_display.cc ::ShowSigninScreenForCreds. | |
356 """ | |
357 self.testGoodLogin() | 359 self.testGoodLogin() |
358 self.Logout() | 360 self.Logout() |
359 self.SetProxySettingOnChromeOS('singlehttp', '127.0.0.1') | 361 proxy_dict = { |
360 self.testGoodLogin() | 362 'url_path': 'singlehttp', |
361 self.ResetProxySettingsOnChromeOS() | 363 'proxy_url': '127.0.0.1', |
362 | 364 } |
| 365 self.SetProxySettingOnChromeOS(proxy_dict) |
| 366 self.Login( |
| 367 username=credentials['username'], |
| 368 password=credentials['password'], |
| 369 use_cached_credentials=True) |
| 370 login_info = self.GetLoginInfo() |
| 371 self.assertTrue(login_info['is_logged_in'], msg='Login failed.') |
363 | 372 |
364 if __name__ == '__main__': | 373 if __name__ == '__main__': |
365 pyauto_functional.Main() | 374 pyauto_functional.Main() |
OLD | NEW |