diff options
author | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-22 02:31:06 +0000 |
---|---|---|
committer | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-22 02:31:06 +0000 |
commit | 166baa486853862fb409a52af004ff45f6114625 (patch) | |
tree | b27e5142f9b9e1fdcf67f13dc38e4e4b9088731b /chrome/browser/password_manager | |
parent | 589a0fa2abd9d8594d5826bd792f75d92ad6d559 (diff) | |
download | chromium_src-166baa486853862fb409a52af004ff45f6114625.zip chromium_src-166baa486853862fb409a52af004ff45f6114625.tar.gz chromium_src-166baa486853862fb409a52af004ff45f6114625.tar.bz2 |
Linux: add an additional unit test for the password store bug fixed in r93300.
Review URL: http://codereview.chromium.org/7472021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93522 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/password_manager')
-rw-r--r-- | chrome/browser/password_manager/native_backend_gnome_x_unittest.cc | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc b/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc index be5aaba..6d4ffe1 100644 --- a/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc +++ b/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc @@ -766,3 +766,101 @@ TEST_F(NativeBackendGnomeTest, NoMigrationWithPrefSet) { if (mock_keyring_items.size() > 1) CheckMockKeyringItem(&mock_keyring_items[1], form_isc_, "chrome-42"); } + +TEST_F(NativeBackendGnomeTest, DeleteMigratedPasswordIsIsolated) { + // Reject attempts to migrate so we can populate the store. + mock_keyring_reject_local_ids = true; + + { + NativeBackendGnome backend(42, profile_->GetPrefs()); + backend.Init(); + + BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, + NewRunnableMethod(&backend, + &NativeBackendGnome::AddLogin, + form_google_)); + + RunBothThreads(); + } + + EXPECT_EQ(1u, mock_keyring_items.size()); + if (mock_keyring_items.size() > 0) + CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); + + // Now allow the migration. + mock_keyring_reject_local_ids = false; + + { + NativeBackendGnome backend(42, profile_->GetPrefs()); + backend.Init(); + + // Trigger the migration by looking something up. + std::vector<PasswordForm*> form_list; + BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, + NewRunnableMethod(&backend, + &NativeBackendGnome::GetAutofillableLogins, + &form_list)); + + RunBothThreads(); + + // Quick check that we got something back. + EXPECT_EQ(1u, form_list.size()); + STLDeleteElements(&form_list); + } + + EXPECT_EQ(2u, mock_keyring_items.size()); + if (mock_keyring_items.size() > 0) + CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); + if (mock_keyring_items.size() > 1) + CheckMockKeyringItem(&mock_keyring_items[1], form_google_, "chrome-42"); + + // Check that we have set the persistent preference. + EXPECT_TRUE( + profile_->GetPrefs()->GetBoolean(prefs::kPasswordsUseLocalProfileId)); + + // Normally we'd actually have a different profile. But in the test just reset + // the profile's persistent pref; we pass in the local profile id anyway. + profile_->GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, false); + + { + NativeBackendGnome backend(24, profile_->GetPrefs()); + backend.Init(); + + // Trigger the migration by looking something up. + std::vector<PasswordForm*> form_list; + BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, + NewRunnableMethod(&backend, + &NativeBackendGnome::GetAutofillableLogins, + &form_list)); + + RunBothThreads(); + + // Quick check that we got something back. + EXPECT_EQ(1u, form_list.size()); + STLDeleteElements(&form_list); + + // There should be three passwords now. + EXPECT_EQ(3u, mock_keyring_items.size()); + if (mock_keyring_items.size() > 0) + CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); + if (mock_keyring_items.size() > 1) + CheckMockKeyringItem(&mock_keyring_items[1], form_google_, "chrome-42"); + if (mock_keyring_items.size() > 2) + CheckMockKeyringItem(&mock_keyring_items[2], form_google_, "chrome-24"); + + // Now delete the password from this second profile. + BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, + NewRunnableMethod(&backend, + &NativeBackendGnome::RemoveLogin, + form_google_)); + + RunBothThreads(); + + // The other two copies of the password in different profiles should remain. + EXPECT_EQ(2u, mock_keyring_items.size()); + if (mock_keyring_items.size() > 0) + CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); + if (mock_keyring_items.size() > 1) + CheckMockKeyringItem(&mock_keyring_items[1], form_google_, "chrome-42"); + } +} |