Commit 7e5a2201 authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] Migrating PSL matched credentials to the account store

Before this patch:
BestMatches were used to decide which credentials to migrate. However,
BestMatches don't necessarily contains all credential. They get flitered
out such that they contain only one credential per username and store.

After this patch:
NonFederatedMatched are used instead to make sure all credentials are
actually moved to the account store.

Bug: 1032992
Change-Id: I754f0b52000edf918c13c1704aa1531c976e091f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087344
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747648}
parent 105a222b
......@@ -141,11 +141,12 @@ void MultiStorePasswordSaveManager::MoveCredentialsToAccountStore() {
// in both profile and account store.
// 3. Moving credentials upon an update. FormFetch will have an outdated
// credentials. Fix it if this turns out to be a product requirement.
// 4. Migrating federated matches if applicable.
const std::vector<const PasswordForm*> account_store_matches =
AccountStoreMatches(form_fetcher_->GetBestMatches());
AccountStoreMatches(form_fetcher_->GetNonFederatedMatches());
for (const PasswordForm* match :
ProfileStoreMatches(form_fetcher_->GetBestMatches())) {
ProfileStoreMatches(form_fetcher_->GetNonFederatedMatches())) {
DCHECK(!match->IsUsingAccountStore());
// Ignore credentials matches for other usernames.
if (match->username_value != pending_credentials_.username_value)
......
......@@ -492,4 +492,30 @@ TEST_F(
password_save_manager()->MoveCredentialsToAccountStore();
}
TEST_F(MultiStorePasswordSaveManagerTest,
MovePSLMatchedCredentialsFromProfileToAccountStore) {
PasswordForm saved_match_in_profile_store(saved_match_);
saved_match_in_profile_store.in_store = PasswordForm::Store::kProfileStore;
PasswordForm psl_saved_match_in_profile_store(psl_saved_match_);
psl_saved_match_in_profile_store.in_store =
PasswordForm::Store::kProfileStore;
SetNonFederatedAndNotifyFetchCompleted(
{&saved_match_in_profile_store, &psl_saved_match_in_profile_store});
password_save_manager()->CreatePendingCredentials(
saved_match_in_profile_store, observed_form_, submitted_form_,
/*is_http_auth=*/false,
/*is_credential_api_save=*/false);
EXPECT_CALL(*mock_profile_form_saver(), Remove(saved_match_in_profile_store));
EXPECT_CALL(*mock_profile_form_saver(),
Remove(psl_saved_match_in_profile_store));
EXPECT_CALL(*mock_account_form_saver(),
Save(saved_match_in_profile_store, _, _));
EXPECT_CALL(*mock_account_form_saver(),
Save(psl_saved_match_in_profile_store, _, _));
password_save_manager()->MoveCredentialsToAccountStore();
}
} // namespace password_manager
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment