Commit e4d30341 authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

Reland "[Passwords] Save CompromisedCredentials in the correct store"

This is a reland of a39032ce

It's not 100% clear that this patch the culprit for the failures in
iOS tests, and hence landing again!

Original change's description:
> [Passwords] Save CompromisedCredentials in the correct store
>
> Bug: 1108422
> Change-Id: I3a96f9d3a422590df5c0b0947e6b803c074ef9a0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2372322
> Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
> Reviewed-by: Jan Wilken Dörrie <jdoerrie@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#801346}

TBR=jdoerrie@chromium.org

Bug: 1108422
Change-Id: I373567952e3d040931204b941325a0da1b9992d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2375290
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801428}
parent a6027a95
......@@ -216,7 +216,10 @@ void CompromisedCredentialsManager::SaveCompromisedCredential(
if (saved_password.password_value == credential.password() &&
CanonicalizeUsername(saved_password.username_value) ==
canonicalized_username) {
profile_store_->AddCompromisedCredentials({
PasswordStore& store = saved_password.IsUsingAccountStore()
? *account_store_
: *profile_store_;
store.AddCompromisedCredentials({
.signon_realm = saved_password.signon_realm,
.username = saved_password.username_value,
.create_time = base::Time::Now(),
......
......@@ -605,4 +605,41 @@ TEST_F(CompromisedCredentialsManagerWithTwoStoresTest,
base::ASCIIToUTF16(kPassword2))),
ElementsAreArray(account_store().stored_passwords().at(kExampleOrg)));
}
// Test verifies that saving LeakCheckCredential via provider adds expected
// compromised credential to the correct store.
TEST_F(CompromisedCredentialsManagerWithTwoStoresTest,
SaveCompromisedPassword) {
ASSERT_TRUE(profile_store().compromised_credentials().empty());
ASSERT_TRUE(account_store().compromised_credentials().empty());
// Add `kUsername1`,`kPassword1` to both stores.
// And add `kUsername1`,`kPassword2` to the account store only.
profile_store().AddLogin(
MakeSavedPassword(kExampleCom, kUsername1, kPassword1));
account_store().AddLogin(
MakeSavedPassword(kExampleOrg, kUsername1, kPassword1));
account_store().AddLogin(
MakeSavedPassword(kExampleCom, kUsername1, kPassword2));
RunUntilIdle();
// Mark `kUsername1`, `kPassword1` as compromised, a new entry should be
// added to both stores.
provider().SaveCompromisedCredential(
MakeLeakCredential(kUsername1, kPassword1));
RunUntilIdle();
EXPECT_EQ(1U, profile_store().compromised_credentials().size());
EXPECT_EQ(1U, account_store().compromised_credentials().size());
// Now, mark `kUsername1`, `kPassword2` as compromised, a new entry should be
// added only to the account store.
provider().SaveCompromisedCredential(
MakeLeakCredential(kUsername1, kPassword2));
RunUntilIdle();
EXPECT_EQ(1U, profile_store().compromised_credentials().size());
EXPECT_EQ(2U, account_store().compromised_credentials().size());
}
} // 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