| 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 66c30d36bee799f85bd3f81baa80471b5854a190..cfd372840685025edfbe94abfa522cbc215e4918 100644
|
| --- a/components/password_manager/content/browser/credential_manager_impl_unittest.cc
|
| +++ b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
|
| @@ -1160,4 +1160,105 @@ TEST_F(CredentialManagerImplTest, GetSynthesizedFormForOrigin) {
|
| EXPECT_TRUE(synthesized.ssl_valid);
|
| }
|
|
|
| +TEST_F(CredentialManagerImplTest, BlacklistPasswordCredential) {
|
| + EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
|
| + _, CredentialSourceType::CREDENTIAL_SOURCE_API));
|
| +
|
| + CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
|
| + bool called = false;
|
| + CallStore(info, base::Bind(&RespondCallback, &called));
|
| + // Allow the PasswordFormManager to talk to the password store
|
| + RunAllPendingTasks();
|
| +
|
| + ASSERT_TRUE(client_->pending_manager());
|
| + client_->pending_manager()->PermanentlyBlacklist();
|
| + // Allow the PasswordFormManager to talk to the password store.
|
| + RunAllPendingTasks();
|
| +
|
| + // Verify that the site is blacklisted.
|
| + autofill::PasswordForm blacklisted;
|
| + TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
|
| + blacklisted.blacklisted_by_user = true;
|
| + blacklisted.origin = form_.origin;
|
| + blacklisted.signon_realm = form_.signon_realm;
|
| + blacklisted.type = autofill::PasswordForm::TYPE_API;
|
| + blacklisted.ssl_valid = true;
|
| + blacklisted.date_created = passwords[form_.signon_realm][0].date_created;
|
| + EXPECT_THAT(passwords[form_.signon_realm], testing::ElementsAre(blacklisted));
|
| +}
|
| +
|
| +TEST_F(CredentialManagerImplTest, BlacklistFederatedCredential) {
|
| + form_.federation_origin = url::Origin(GURL("https://example.com/"));
|
| + form_.signon_realm = "federation://example.com/example.com";
|
| +
|
| + EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
|
| + _, CredentialSourceType::CREDENTIAL_SOURCE_API));
|
| + CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_FEDERATED);
|
| + bool called = false;
|
| + CallStore(info, base::Bind(&RespondCallback, &called));
|
| + // Allow the PasswordFormManager to talk to the password store
|
| + RunAllPendingTasks();
|
| +
|
| + ASSERT_TRUE(client_->pending_manager());
|
| + client_->pending_manager()->PermanentlyBlacklist();
|
| + // Allow the PasswordFormManager to talk to the password store.
|
| + RunAllPendingTasks();
|
| +
|
| + // Verify that the site is blacklisted.
|
| + TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
|
| + ASSERT_TRUE(passwords.count(form_.origin.spec()));
|
| + autofill::PasswordForm blacklisted;
|
| + blacklisted.blacklisted_by_user = true;
|
| + blacklisted.origin = form_.origin;
|
| + blacklisted.signon_realm = blacklisted.origin.spec();
|
| + blacklisted.type = autofill::PasswordForm::TYPE_API;
|
| + blacklisted.ssl_valid = true;
|
| + blacklisted.date_created =
|
| + passwords[blacklisted.signon_realm][0].date_created;
|
| + EXPECT_THAT(passwords[blacklisted.signon_realm],
|
| + testing::ElementsAre(blacklisted));
|
| +}
|
| +
|
| +TEST_F(CredentialManagerImplTest, RespectBlacklistingPasswordCredential) {
|
| + autofill::PasswordForm blacklisted;
|
| + blacklisted.blacklisted_by_user = true;
|
| + blacklisted.origin = form_.origin;
|
| + blacklisted.signon_realm = blacklisted.origin.spec();
|
| + blacklisted.ssl_valid = true;
|
| + store_->AddLogin(blacklisted);
|
| +
|
| + CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
|
| + bool called = false;
|
| + EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
|
| + _, CredentialSourceType::CREDENTIAL_SOURCE_API));
|
| + CallStore(info, base::Bind(&RespondCallback, &called));
|
| + // Allow the PasswordFormManager to talk to the password store
|
| + RunAllPendingTasks();
|
| +
|
| + ASSERT_TRUE(client_->pending_manager());
|
| + EXPECT_TRUE(client_->pending_manager()->IsBlacklisted());
|
| +}
|
| +
|
| +TEST_F(CredentialManagerImplTest, RespectBlacklistingFederatedCredential) {
|
| + autofill::PasswordForm blacklisted;
|
| + blacklisted.blacklisted_by_user = true;
|
| + blacklisted.origin = form_.origin;
|
| + blacklisted.signon_realm = blacklisted.origin.spec();
|
| + blacklisted.ssl_valid = true;
|
| + store_->AddLogin(blacklisted);
|
| +
|
| + form_.federation_origin = url::Origin(GURL("https://example.com/"));
|
| + form_.signon_realm = "federation://example.com/example.com";
|
| + CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_FEDERATED);
|
| + bool called = false;
|
| + EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
|
| + _, CredentialSourceType::CREDENTIAL_SOURCE_API));
|
| + CallStore(info, base::Bind(&RespondCallback, &called));
|
| + // Allow the PasswordFormManager to talk to the password store
|
| + RunAllPendingTasks();
|
| +
|
| + ASSERT_TRUE(client_->pending_manager());
|
| + EXPECT_TRUE(client_->pending_manager()->IsBlacklisted());
|
| +}
|
| +
|
| } // namespace password_manager
|
|
|