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

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

Issue 2425243002: CM API: disallow a federated credential to update a password credential. (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « no previous file | components/password_manager/core/browser/password_form_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6a3808e892e53384fc3e1f0b256d209abb923e8d..20fa985f5b69beb439895834e6ba793f2e82304a 100644
--- a/components/password_manager/content/browser/credential_manager_impl_unittest.cc
+++ b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
@@ -40,6 +40,7 @@ using content::BrowserContext;
using content::WebContents;
using testing::_;
+using testing::ElementsAre;
using testing::Pointee;
using testing::UnorderedElementsAre;
@@ -451,6 +452,41 @@ TEST_F(CredentialManagerImplTest, CredentialManagerOnStoreFederated) {
EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, new_form.scheme);
}
+TEST_F(CredentialManagerImplTest, StoreFederatedAfterPassword) {
+ // Populate the PasswordStore with a form.
+ store_->AddLogin(form_);
+
+ autofill::PasswordForm federated = form_;
+ federated.password_value.clear();
+ federated.type = autofill::PasswordForm::TYPE_API;
+ federated.preferred = true;
+ federated.federation_origin = url::Origin(GURL("https://google.com/"));
+ federated.signon_realm = "federation://example.com/google.com";
+ CredentialInfo info(federated, CredentialType::CREDENTIAL_TYPE_FEDERATED);
+ EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
+ _, CredentialSourceType::CREDENTIAL_SOURCE_API));
+ EXPECT_CALL(*client_, NotifyStorePasswordCalled());
+
+ bool called = false;
+ CallStore(info, base::Bind(&RespondCallback, &called));
+
+ // Allow the PasswordFormManager to talk to the password store, determine
+ // that the form is new, and set it as pending.
+ RunAllPendingTasks();
+
+ EXPECT_TRUE(called);
+ EXPECT_TRUE(client_->pending_manager()->HasCompletedMatching());
+ client_->pending_manager()->Save();
+
+ RunAllPendingTasks();
+ TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
+ EXPECT_THAT(passwords["https://example.com/"], ElementsAre(form_));
+ federated.date_created =
+ passwords["federation://example.com/google.com"][0].date_created;
+ EXPECT_THAT(passwords["federation://example.com/google.com"],
+ ElementsAre(federated));
+}
+
TEST_F(CredentialManagerImplTest, CredentialManagerStoreOverwrite) {
// Populate the PasswordStore with a form.
store_->AddLogin(form_);
« no previous file with comments | « no previous file | components/password_manager/core/browser/password_form_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698