Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: components/password_manager/content/browser/credential_manager_impl_unittest.cc

Issue 2598003002: Suppress save and update bubbles when storing a PSL matched credential (Closed)
Patch Set: Cleanup includes and update doc Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/password_manager/content/browser/credential_manager_impl_unittest.cc
diff --git a/components/password_manager/content/browser/credential_manager_impl_unittest.cc b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
index 4c0840bd5d0529f6676c068b265dc60aa246e7f4..3e7d43ea05f7a1687509796444ba3a6e9212ef03 100644
--- a/components/password_manager/content/browser/credential_manager_impl_unittest.cc
+++ b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
@@ -521,6 +521,79 @@ TEST_F(CredentialManagerImplTest, CredentialManagerStoreOverwrite) {
passwords[form_.signon_realm][0].password_value);
}
+TEST_F(CredentialManagerImplTest,
+ CredentialManagerStorePSLMatchDoesNotTriggerBubble) {
+ autofill::PasswordForm psl_form = subdomain_form_;
+ psl_form.username_value = form_.username_value;
+ psl_form.password_value = form_.password_value;
+ store_->AddLogin(psl_form);
+
+ // Calling 'Store' with a credential that PSL matches |form_| should update
+ // the password without prompting the user.
+ CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
+ EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(_, _))
+ .Times(testing::Exactly(0));
+ EXPECT_CALL(*client_, NotifyStorePasswordCalled());
+ bool called = false;
+ CallStore(info, base::Bind(&RespondCallback, &called));
+
+ // Allow the PasswordFormManager to talk to the password store, determine
+ // that there is an existing PSL match and update the PasswordStore.
+ RunAllPendingTasks();
+
+ EXPECT_TRUE(called);
+}
vasilii 2016/12/22 13:24:59 Check that the credential was actually stored and
jdoerrie 2016/12/22 16:20:01 Done.
+
+TEST_F(CredentialManagerImplTest,
+ CredentialManagerStoreNonPSLMatchWithDifferentUsernameTriggersBubble) {
vasilii 2016/12/22 13:24:59 should it be CredentialManagerStorePSLMatchWithDif
jdoerrie 2016/12/22 16:20:01 Done.
+ base::string16 delta = base::ASCIIToUTF16("_totally_different");
+ autofill::PasswordForm in_valid_psl_form = subdomain_form_;
vasilii 2016/12/22 13:24:59 What is 'in_'?
jdoerrie 2016/12/22 16:20:01 Dropped it, meant to say invalid, but the PSL matc
+ in_valid_psl_form.username_value = form_.username_value + delta;
+ in_valid_psl_form.password_value = form_.password_value;
+ store_->AddLogin(in_valid_psl_form);
+
+ // Calling 'Store' with a credential that does not PSL match |form_| should
+ // prompt the user for an update.
+ CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
+ EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(_, _))
+ .Times(testing::Exactly(1));
+ EXPECT_CALL(*client_, NotifyStorePasswordCalled());
+ bool called = false;
+ CallStore(info, base::Bind(&RespondCallback, &called));
+
+ // Allow the PasswordFormManager to talk to the password store, determine
+ // the form is not a (PSL) match for an existing form, and update the
vasilii 2016/12/22 13:24:59 What kind of 'update' are you expecting? i think i
jdoerrie 2016/12/22 16:20:01 Done.
+ // PasswordStore.
+ RunAllPendingTasks();
+
+ EXPECT_TRUE(called);
vasilii 2016/12/22 13:24:59 Check that client_->pending_manager()->pending_cre
jdoerrie 2016/12/22 16:20:01 Done.
+}
+
+TEST_F(CredentialManagerImplTest,
+ CredentialManagerStoreNonPSLMatchWithDifferentPasswordTriggersBubble) {
+ base::string16 delta = base::ASCIIToUTF16("_totally_different");
+ autofill::PasswordForm in_valid_psl_form = subdomain_form_;
+ in_valid_psl_form.username_value = form_.username_value;
+ in_valid_psl_form.password_value = form_.password_value + delta;
+ store_->AddLogin(in_valid_psl_form);
+
+ // Calling 'Store' with a credential that does not PSL match |form_| should
+ // prompt the user for an update.
+ CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
+ EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(_, _))
+ .Times(testing::Exactly(1));
+ EXPECT_CALL(*client_, NotifyStorePasswordCalled());
+ bool called = false;
+ CallStore(info, base::Bind(&RespondCallback, &called));
+
+ // Allow the PasswordFormManager to talk to the password store, determine
+ // the form is not a (PSL) match for an existing form, and update the
+ // PasswordStore.
+ RunAllPendingTasks();
+
+ EXPECT_TRUE(called);
+}
+
TEST_F(CredentialManagerImplTest, CredentialManagerStoreOverwriteZeroClick) {
form_.skip_zero_click = true;
store_->AddLogin(form_);

Powered by Google App Engine
This is Rietveld 408576698