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

[Passwords] Move credentials when PSL match existing in both

Move credentials from the profile store to the account store when
the credentials exists only in the profile but a PSL matched one exists
in both stores.
In this case, the credential should be move, and local PSL match should
be deleted.

The functionality has been already implemented, this patch is
effectively only adding a test.

Bug: 1032992
Change-Id: Ibb02e496493cb1091ed2e09b1f52c93ea0f253d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089780
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748166}
parent e6876cc0
......@@ -146,12 +146,9 @@ bool MultiStorePasswordSaveManager::IsAccountStoreEnabled() {
}
void MultiStorePasswordSaveManager::MoveCredentialsToAccountStore() {
// TODO(crbug.com/1032992): There are other rare corner cases that should
// still be handled:
// 1. Credential exists only in the profile store but a PSL matched one exists
// in both profile and account store.
// 2. Moving credentials upon an update. FormFetch will have an outdated
// credentials. Fix it if this turns out to be a product requirement.
// TODO(crbug.com/1032992): Moving credentials upon an update. FormFetch will
// have an outdated credentials. Fix it if this turns out to be a product
// requirement.
std::vector<const PasswordForm*> account_store_matches =
AccountStoreMatches(form_fetcher_->GetNonFederatedMatches());
......
......@@ -577,4 +577,35 @@ TEST_F(MultiStorePasswordSaveManagerTest,
password_save_manager()->MoveCredentialsToAccountStore();
}
TEST_F(MultiStorePasswordSaveManagerTest,
MoveCredentialsFromProfileToAccountStoreWhenPSLMatchExistsInBothStores) {
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;
PasswordForm psl_saved_match_in_account_store(psl_saved_match_);
psl_saved_match_in_account_store.in_store =
PasswordForm::Store::kAccountStore;
SetNonFederatedAndNotifyFetchCompleted({&saved_match_in_profile_store,
&psl_saved_match_in_profile_store,
&psl_saved_match_in_account_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, _, _));
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