| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/password_manager/password_store_mac.h" | 5 #include "chrome/browser/password_manager/password_store_mac.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 base::MessageLoop::current()->Run(); | 1335 base::MessageLoop::current()->Run(); |
| 1336 ::testing::Mock::VerifyAndClearExpectations(&mock_consumer); | 1336 ::testing::Mock::VerifyAndClearExpectations(&mock_consumer); |
| 1337 EXPECT_EQ(form, returned_form); | 1337 EXPECT_EQ(form, returned_form); |
| 1338 | 1338 |
| 1339 PasswordForm query_form = form; | 1339 PasswordForm query_form = form; |
| 1340 query_form.password_value.clear(); | 1340 query_form.password_value.clear(); |
| 1341 query_form.username_value.clear(); | 1341 query_form.username_value.clear(); |
| 1342 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(SizeIs(1u))) | 1342 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(SizeIs(1u))) |
| 1343 .WillOnce( | 1343 .WillOnce( |
| 1344 DoAll(SaveACopyOfFirstForm(&returned_form), QuitUIMessageLoop())); | 1344 DoAll(SaveACopyOfFirstForm(&returned_form), QuitUIMessageLoop())); |
| 1345 store()->GetLogins(query_form, PasswordStore::ALLOW_PROMPT, | 1345 store()->GetLogins(query_form, &mock_consumer); |
| 1346 &mock_consumer); | |
| 1347 base::MessageLoop::current()->Run(); | 1346 base::MessageLoop::current()->Run(); |
| 1348 ::testing::Mock::VerifyAndClearExpectations(&mock_consumer); | 1347 ::testing::Mock::VerifyAndClearExpectations(&mock_consumer); |
| 1349 EXPECT_EQ(form, returned_form); | 1348 EXPECT_EQ(form, returned_form); |
| 1350 | 1349 |
| 1351 store()->RemoveLogin(form); | 1350 store()->RemoveLogin(form); |
| 1352 } | 1351 } |
| 1353 } | 1352 } |
| 1354 | 1353 |
| 1355 base::FilePath test_login_db_file_path() const { | 1354 base::FilePath test_login_db_file_path() const { |
| 1356 return db_dir_.path().Append(FILE_PATH_LITERAL("login.db")); | 1355 return db_dir_.path().Append(FILE_PATH_LITERAL("login.db")); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain()); | 1504 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain()); |
| 1506 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1505 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 1507 owned_keychain_adapter.AddPassword(*www_form); | 1506 owned_keychain_adapter.AddPassword(*www_form); |
| 1508 | 1507 |
| 1509 // 2. Get a password for m.facebook.com. | 1508 // 2. Get a password for m.facebook.com. |
| 1510 PasswordForm m_form(*www_form); | 1509 PasswordForm m_form(*www_form); |
| 1511 m_form.signon_realm = "http://m.facebook.com"; | 1510 m_form.signon_realm = "http://m.facebook.com"; |
| 1512 m_form.origin = GURL("http://m.facebook.com/index.html"); | 1511 m_form.origin = GURL("http://m.facebook.com/index.html"); |
| 1513 | 1512 |
| 1514 MockPasswordStoreConsumer consumer; | 1513 MockPasswordStoreConsumer consumer; |
| 1515 store_->GetLogins(m_form, PasswordStore::ALLOW_PROMPT, &consumer); | 1514 store_->GetLogins(m_form, &consumer); |
| 1516 PasswordForm returned_form; | 1515 PasswordForm returned_form; |
| 1517 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(SizeIs(1u))) | 1516 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(SizeIs(1u))) |
| 1518 .WillOnce( | 1517 .WillOnce( |
| 1519 DoAll(SaveACopyOfFirstForm(&returned_form), QuitUIMessageLoop())); | 1518 DoAll(SaveACopyOfFirstForm(&returned_form), QuitUIMessageLoop())); |
| 1520 base::MessageLoop::current()->Run(); | 1519 base::MessageLoop::current()->Run(); |
| 1521 | 1520 |
| 1522 // 3. Add the returned password for m.facebook.com. | 1521 // 3. Add the returned password for m.facebook.com. |
| 1523 returned_form.signon_realm = "http://m.facebook.com"; | 1522 returned_form.signon_realm = "http://m.facebook.com"; |
| 1524 returned_form.origin = GURL("http://m.facebook.com/index.html"); | 1523 returned_form.origin = GURL("http://m.facebook.com/index.html"); |
| 1525 EXPECT_EQ(AddChangeForForm(returned_form), | 1524 EXPECT_EQ(AddChangeForForm(returned_form), |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 m_form.signon_realm = "http://m.facebook.com"; | 1762 m_form.signon_realm = "http://m.facebook.com"; |
| 1764 m_form.origin = GURL("http://m.facebook.com/index.html"); | 1763 m_form.origin = GURL("http://m.facebook.com/index.html"); |
| 1765 | 1764 |
| 1766 MockPasswordStoreConsumer consumer; | 1765 MockPasswordStoreConsumer consumer; |
| 1767 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) | 1766 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
| 1768 .WillByDefault(QuitUIMessageLoop()); | 1767 .WillByDefault(QuitUIMessageLoop()); |
| 1769 EXPECT_CALL(mock_observer, OnLoginsChanged(_)).Times(0); | 1768 EXPECT_CALL(mock_observer, OnLoginsChanged(_)).Times(0); |
| 1770 // The PSL-matched form isn't returned because there is no actual password in | 1769 // The PSL-matched form isn't returned because there is no actual password in |
| 1771 // the keychain. | 1770 // the keychain. |
| 1772 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); | 1771 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
| 1773 store_->GetLogins(m_form, PasswordStore::ALLOW_PROMPT, &consumer); | 1772 store_->GetLogins(m_form, &consumer); |
| 1774 base::MessageLoop::current()->Run(); | 1773 base::MessageLoop::current()->Run(); |
| 1775 ScopedVector<autofill::PasswordForm> all_forms; | 1774 ScopedVector<autofill::PasswordForm> all_forms; |
| 1776 EXPECT_TRUE(login_db()->GetAutofillableLogins(&all_forms)); | 1775 EXPECT_TRUE(login_db()->GetAutofillableLogins(&all_forms)); |
| 1777 EXPECT_EQ(1u, all_forms.size()); | 1776 EXPECT_EQ(1u, all_forms.size()); |
| 1778 ::testing::Mock::VerifyAndClearExpectations(&mock_observer); | 1777 ::testing::Mock::VerifyAndClearExpectations(&mock_observer); |
| 1779 | 1778 |
| 1780 // 3. Get a password for www.facebook.com. The form is implicitly removed and | 1779 // 3. Get a password for www.facebook.com. The form is implicitly removed and |
| 1781 // the observer is notified. | 1780 // the observer is notified. |
| 1782 password_manager::PasswordStoreChangeList list; | 1781 password_manager::PasswordStoreChangeList list; |
| 1783 list.push_back(password_manager::PasswordStoreChange( | 1782 list.push_back(password_manager::PasswordStoreChange( |
| 1784 password_manager::PasswordStoreChange::REMOVE, *www_form)); | 1783 password_manager::PasswordStoreChange::REMOVE, *www_form)); |
| 1785 EXPECT_CALL(mock_observer, OnLoginsChanged(list)); | 1784 EXPECT_CALL(mock_observer, OnLoginsChanged(list)); |
| 1786 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); | 1785 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
| 1787 store_->GetLogins(*www_form, PasswordStore::ALLOW_PROMPT, &consumer); | 1786 store_->GetLogins(*www_form, &consumer); |
| 1788 base::MessageLoop::current()->Run(); | 1787 base::MessageLoop::current()->Run(); |
| 1789 EXPECT_TRUE(login_db()->GetAutofillableLogins(&all_forms)); | 1788 EXPECT_TRUE(login_db()->GetAutofillableLogins(&all_forms)); |
| 1790 EXPECT_EQ(0u, all_forms.size()); | 1789 EXPECT_EQ(0u, all_forms.size()); |
| 1791 } | 1790 } |
| 1792 | 1791 |
| 1793 // Verify that Android app passwords can be stored, retrieved, and deleted. | 1792 // Verify that Android app passwords can be stored, retrieved, and deleted. |
| 1794 // Regression test for http://crbug.com/455551 | 1793 // Regression test for http://crbug.com/455551 |
| 1795 TEST_F(PasswordStoreMacTest, StoringAndRetrievingAndroidCredentials) { | 1794 TEST_F(PasswordStoreMacTest, StoringAndRetrievingAndroidCredentials) { |
| 1796 PasswordForm form; | 1795 PasswordForm form; |
| 1797 form.signon_realm = "android://7x7IDboo8u9YKraUsbmVkuf1@net.rateflix.app/"; | 1796 form.signon_realm = "android://7x7IDboo8u9YKraUsbmVkuf1@net.rateflix.app/"; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1924 histogram_tester_->ExpectUniqueSample( | 1923 histogram_tester_->ExpectUniqueSample( |
| 1925 "PasswordManager.KeychainMigration.NumPasswordsOnFailure", 1, 1); | 1924 "PasswordManager.KeychainMigration.NumPasswordsOnFailure", 1, 1); |
| 1926 histogram_tester_->ExpectUniqueSample( | 1925 histogram_tester_->ExpectUniqueSample( |
| 1927 "PasswordManager.KeychainMigration.NumFailedPasswords", 1, 1); | 1926 "PasswordManager.KeychainMigration.NumFailedPasswords", 1, 1); |
| 1928 histogram_tester_->ExpectUniqueSample( | 1927 histogram_tester_->ExpectUniqueSample( |
| 1929 "PasswordManager.KeychainMigration.NumChromeOwnedInaccessiblePasswords", | 1928 "PasswordManager.KeychainMigration.NumChromeOwnedInaccessiblePasswords", |
| 1930 2, 1); | 1929 2, 1); |
| 1931 // Don't test the encryption key access. | 1930 // Don't test the encryption key access. |
| 1932 histogram_tester_.reset(); | 1931 histogram_tester_.reset(); |
| 1933 } | 1932 } |
| OLD | NEW |