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/08 20:59:17
nit: remove this line
sunandt
2010/12/08 22:46:34
Done.
|
| + |
| 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.""" |
|
Nirnimesh
2010/12/08 20:59:17
s/details/fields/
sunandt
2010/12/08 22:46:34
Done.
|
| + 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. |
| + # http://crbug.com/64603 |
| + # 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,30 @@ |
| 'window.domAutomationController.send("done")') |
| test_utils.ClearPasswords(self) |
| + def testNeverSavePasswords(self): |
| + """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'], |
|
Nirnimesh
2010/12/08 20:59:17
move all args to next line
sunandt
2010/12/08 22:46:34
Done.
|
| + creds1['username'], creds1['password']) |
| + self.WaitForInfobarCount(1) |
| + self.PerformActionOnInfobar('accept', infobar_index=0) |
| + self.assertEquals(1, len(self.GetSavedPasswords())) |
| + self.AppendTab(pyauto.GURL(creds1['logout_url'])) |
| + creds2 = self.GetPrivateInfo()['etouchqa_google_account'] |
| + test_utils.GoogleAccountsLogin(self, creds2['login_url'], |
| + creds2['username'], creds2['password'], |
| + tab_index=1, windex=0) |
| + self.WaitForInfobarCount(1, windex=0, tab_index=1) |
|
Nirnimesh
2010/12/08 20:59:17
can skip the windex arg
sunandt
2010/12/08 22:46:34
Done.
|
| + self.PerformActionOnInfobar('cancel', infobar_index=0, |
|
Nirnimesh
2010/12/08 20:59:17
Mention (in comment) that this is equivalent to se
sunandt
2010/12/08 22:46:34
Done.
|
| + windex=0, tab_index=1) |
|
Nirnimesh
2010/12/08 20:59:17
can skip the windex arg
sunandt
2010/12/08 22:46:34
Done.
|
| + |
| + # TODO: GetSavedPasswords() doesn't return anything when empty. |
| + # http://crbug.com/64603 |
| + # self.assertFalse(self.GetSavedPasswords()) |
| + # TODO: Check the exceptions list |
| + |
| + |
| if __name__ == '__main__': |
| pyauto_functional.Main() |