Chromium Code Reviews| Index: functional/passwords.py |
| =================================================================== |
| --- functional/passwords.py (revision 67497) |
| +++ functional/passwords.py (working copy) |
| @@ -3,13 +3,14 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
|
Nirnimesh
2010/12/09 00:25:14
no need to add another blank line here
sunandt
2010/12/09 00:47:46
I already did remove this. Forgot to update. :)
|
| + |
| import pyauto_functional # Must be imported before pyauto |
| import pyauto |
| import test_utils |
| class PasswordTest(pyauto.PyUITest): |
| - """Tests that passwords work correctly""" |
| + """Tests that passwords work correctly.""" |
| def Debug(self): |
| """Test method for experimentation. |
| @@ -28,21 +29,54 @@ |
| 'Times not within an acceptable range. ' |
| 'First was %lf, second was %lf' % (time1, time2)) |
| + def _ConstructPasswordDictionary(self, username_value, password_value, |
| + signon_realm, origin_url, username_element, |
| + password_element, action_target, |
| + time=1279650942.0, submit_element='submit', |
| + blacklist=False): |
| + """Construct a password dictionary with all the required details.""" |
| + return {'username_value': username_value, |
| + 'password_value': password_value, |
| + 'signon_realm': signon_realm, |
| + 'time': time, |
| + 'origin_url': origin_url, |
| + 'username_element': username_element, |
| + 'password_element': password_element, |
| + 'submit_element': submit_element, |
| + 'action_target': action_target, |
| + 'blacklist': blacklist} |
| + |
| def testSavePassword(self): |
| """Test saving a password and getting saved passwords.""" |
| - password1 = { 'username_value': 'user@example.com', |
| - 'password_value': 'test.password', |
| - 'signon_realm': 'https://www.example.com/', |
| - 'time': 1279650942.0, |
| - 'origin_url': 'https://www.example.com/login', |
| - 'username_element': 'username', |
| - 'password_element': 'password', |
| - 'submit_element': 'submit', |
| - 'action_target': 'https://www.example.com/login/', |
| - 'blacklist': False } |
| + password1 = self._ConstructPasswordDictionary( |
| + 'user@example.com', 'test.password', |
| + 'https://www.example.com/', 'https://www.example.com/login', |
| + 'username', 'password', 'https://www.example.com/login/') |
| self.assertTrue(self.AddSavedPassword(password1)) |
| self.assertEquals(self.GetSavedPasswords(), [password1]) |
| + def testRemovePasswords(self): |
| + """Verify that saved passwords can be removed.""" |
| + password1 = self._ConstructPasswordDictionary( |
| + 'user1@example.com', 'test1.password', |
| + 'https://www.example.com/', 'https://www.example.com/login', |
| + 'username1', 'password', 'https://www.example.com/login/') |
| + password2 = self._ConstructPasswordDictionary( |
| + 'user2@example.com', 'test2.password', |
| + 'https://www.example.com/', 'https://www.example.com/login', |
| + 'username2', 'password2', 'https://www.example.com/login/') |
| + self.AddSavedPassword(password1) |
| + self.AddSavedPassword(password2) |
| + self.assertEquals(2, len(self.GetSavedPasswords())) |
| + self.assertEquals([password1, password2], self.GetSavedPasswords()) |
| + self.RemoveSavedPassword(password1) |
| + self.assertEquals(1, len(self.GetSavedPasswords())) |
| + self.assertEquals([password2], self.GetSavedPasswords()) |
| + self.RemoveSavedPassword(password2) |
| + # TODO: GetSavedPasswords() doesn't return anything when empty. |
| + # Remove the comment when that gets fixed. |
|
Nirnimesh
2010/11/29 22:42:58
add the bug# here
sunandt
2010/12/07 23:47:45
Done.
|
| + # self.assertFalse(self.GetSavedPasswords()) |
| + |
| def testDisplayAndSavePasswordInfobar(self): |
| """Verify password infobar displays and able to save password.""" |
| url_https = 'https://www.google.com/accounts/' |
| @@ -66,6 +100,58 @@ |
| 'window.domAutomationController.send("done")') |
| test_utils.ClearPasswords(self) |
| + def testFetchAnotherUser(self): |
| + """Verify that another user's password is autofilled when |
| + username is selected.""" |
| + # Save credentials of first account |
| + creds1 = self.GetPrivateInfo()['test_google_account'] |
| + test_utils.GoogleAccountsLogin(self, creds1['login_url'], |
|
Nirnimesh
2010/11/29 22:42:58
You should directly call AddSavedPassword, instead
sunandt
2010/12/07 23:47:45
Removing this testcase.
|
| + creds1['username'], creds1['password']) |
| + self.WaitForInfobarCount(1) |
| + self.PerformActionOnInfobar('accept', 0) |
| + # Logout |
| + self.AppendTab(pyauto.GURL(creds1['logout_url'])) |
| + # Save credentials of second account |
| + creds2 = self.GetPrivateInfo()['etouchqa_google_account'] |
|
Nirnimesh
2010/11/29 22:42:58
Please create an internal CL for adding this entry
|
| + test_utils.GoogleAccountsLogin(self, creds2['login_url'], |
| + creds2['username'], creds2['password'], 0, 1) |
|
Nirnimesh
2010/11/29 22:42:58
pass as named args:
tab_index=1, windex=0
Repeat e
sunandt
2010/12/07 23:47:45
Removing this testcase.
|
| + self.WaitForInfobarCount(1, 0, 1) |
| + self.PerformActionOnInfobar('accept', 0, 0, 1) |
| + self.AppendTab(pyauto.GURL(creds2['logout_url'])) |
| + |
| + # Populate the username field with the first saved credentials. |
|
Nirnimesh
2010/11/29 22:42:58
This comment is misleading.
Wait for username fie
sunandt
2010/12/07 23:47:45
Removing this testcase.
|
| + self.WaitUntil( |
| + lambda: self.GetDOMValue('document.getElementById("Email").value', 0, 2), |
|
Nirnimesh
2010/11/29 22:42:58
80+ chars
sunandt
2010/12/07 23:47:45
Removing this testcase.
|
| + expect_retval=creds2['username']) |
| + email_id = 'document.getElementById("Email").value = \"%s\"; ' \ |
| + 'window.domAutomationController.send("done")' % creds1['username'] |
| + self.ExecuteJavascript(email_id, 0, 2); |
| + self.assertEqual(creds2['password'], |
| + self.GetDOMValue('document.getElementById("Passwd").value', 0, 2)) |
| + |
| + def testNeverSavePasswords(self): |
|
Nirnimesh
2010/11/29 22:42:58
testNeverSavePasswordsPref
sunandt
2010/12/07 23:47:45
This is not the preference test.
|
| + """Verify that we don't save passwords and delete saved passwords |
| + for a domain when 'never for this site' is chosen.""" |
| + creds1 = self.GetPrivateInfo()['test_google_account'] |
| + test_utils.GoogleAccountsLogin(self, creds1['login_url'], |
| + creds1['username'], creds1['password']) |
| + self.WaitForInfobarCount(1) |
| + self.PerformActionOnInfobar('accept', 0) |
| + self.assertEquals(1, len(self.GetSavedPasswords())) |
| + self.AppendTab(pyauto.GURL(creds1['logout_url'])) |
| + |
| + self.RunCommand(pyauto.IDC_NEW_TAB) |
|
Nirnimesh
2010/11/29 22:42:58
use AppendTab
sunandt
2010/12/07 23:47:45
Removed.
|
| + creds2 = self.GetPrivateInfo()['etouchqa_google_account'] |
| + test_utils.GoogleAccountsLogin(self, creds2['login_url'], |
| + creds2['username'], creds2['password'], 0, 2) |
|
Nirnimesh
2010/11/29 22:42:58
use named args for windex, tab_index
sunandt
2010/12/07 23:47:45
Done.
|
| + self.WaitForInfobarCount(1, 0, 2) |
| + self.PerformActionOnInfobar('cancel', 0, 0, 2) |
| + |
| + # TODO: Remove comment when GetSavedPasswords() is fixed. |
|
Nirnimesh
2010/11/29 22:42:58
won't this have 1 entry at this point?
sunandt
2010/12/07 23:47:45
GetSavedPasswords() isn't returning anything from
|
| + # self.assertFalse(self.GetSavedPasswords()) |
| + # TODO: Check the exceptions list |
| + |
| + |
| if __name__ == '__main__': |
| pyauto_functional.Main() |