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

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

Issue 2416783002: 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 a4492d3b4e68682f84abedc6f9eaf8d47f23e07a..a03315ec1ee635a3073c04d1c176a8014a573f55 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;
@@ -450,6 +451,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
vabr (Chromium) 2016/10/13 07:59:43 Just wanted to say that this is a very well writte
vasilii 2016/10/13 13:59:37 written by Mike, I just copy pasted. Kudos to me t
vabr (Chromium) 2016/10/13 14:04:25 :D
+ // 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