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

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

Issue 1978513003: Save federated credential's signon_realm in the correct format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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_dispatcher_unittest.cc
diff --git a/components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc b/components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc
index 16fa3b3ac5d077b21749ad09ef8d94e5043865b0..91cd4d6adccec73c5d78fe1fbd2308d2ff780945 100644
--- a/components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc
+++ b/components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc
@@ -206,6 +206,7 @@ class CredentialManagerDispatcherTest
form_.username_value = base::ASCIIToUTF16("Username");
form_.display_name = base::ASCIIToUTF16("Display Name");
+ form_.icon_url = GURL("https://example.com/icon.png");
form_.password_value = base::ASCIIToUTF16("Password");
form_.origin = web_contents()->GetLastCommittedURL().GetOrigin();
form_.signon_realm = form_.origin.spec();
@@ -363,6 +364,44 @@ TEST_F(CredentialManagerDispatcherTest, CredentialManagerOnStore) {
EXPECT_EQ(form_.password_value, new_form.password_value);
EXPECT_EQ(form_.origin, new_form.origin);
EXPECT_EQ(form_.signon_realm, new_form.signon_realm);
+ EXPECT_TRUE(new_form.federation_origin.unique());
+ EXPECT_EQ(form_.icon_url, new_form.icon_url);
+ EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, new_form.scheme);
+}
+
+TEST_F(CredentialManagerDispatcherTest, CredentialManagerOnStoreFederated) {
+ EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
+ _, CredentialSourceType::CREDENTIAL_SOURCE_API))
+ .Times(testing::Exactly(1));
+ EXPECT_CALL(*client_, NotifyStorePasswordCalled());
+
+ form_.federation_origin = url::Origin(GURL("https://google.com/"));
+ form_.password_value = base::string16();
+ form_.signon_realm = "federation://example.com/google.com";
+ CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_FEDERATED);
+ dispatcher()->OnStore(kRequestId, info);
+
+ const uint32_t kMsgID = CredentialManagerMsg_AcknowledgeStore::ID;
+ const IPC::Message* message =
+ process()->sink().GetFirstMessageMatching(kMsgID);
+ EXPECT_TRUE(message);
+ process()->sink().ClearMessages();
+
+ // Allow the PasswordFormManager to talk to the password store, determine
+ // that the form is new, and set it as pending.
+ RunAllPendingTasks();
+
+ EXPECT_TRUE(client_->pending_manager()->HasCompletedMatching());
+
+ autofill::PasswordForm new_form =
+ client_->pending_manager()->pending_credentials();
+ EXPECT_EQ(form_.username_value, new_form.username_value);
+ EXPECT_EQ(form_.display_name, new_form.display_name);
+ EXPECT_EQ(form_.password_value, new_form.password_value);
+ EXPECT_EQ(form_.origin, new_form.origin);
+ EXPECT_EQ(form_.signon_realm, new_form.signon_realm);
+ EXPECT_EQ(form_.federation_origin, new_form.federation_origin);
+ EXPECT_EQ(form_.icon_url, new_form.icon_url);
EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, new_form.scheme);
}
@@ -429,6 +468,7 @@ TEST_F(CredentialManagerDispatcherTest,
client_->set_zero_click_enabled(true);
client_->set_first_run_seen(true);
form_.federation_origin = url::Origin(GURL("https://example.com/"));
+ form_.password_value = base::string16();
form_.skip_zero_click = true;
form_.signon_realm = "federation://example.com/example.com";
store_->AddLogin(form_);
@@ -727,6 +767,7 @@ TEST_F(CredentialManagerDispatcherTest,
TEST_F(CredentialManagerDispatcherTest,
CredentialManagerOnRequestCredentialFederatedMatch) {
form_.federation_origin = url::Origin(GURL("https://example.com/"));
+ form_.password_value = base::string16();
store_->AddLogin(form_);
client_->set_first_run_seen(true);
@@ -742,6 +783,7 @@ TEST_F(CredentialManagerDispatcherTest,
TEST_F(CredentialManagerDispatcherTest,
CredentialManagerOnRequestCredentialFederatedNoMatch) {
form_.federation_origin = url::Origin(GURL("https://example.com/"));
+ form_.password_value = base::string16();
store_->AddLogin(form_);
client_->set_first_run_seen(true);
@@ -800,6 +842,7 @@ TEST_F(CredentialManagerDispatcherTest,
CredentialManagerOnRequestCredentialAffiliatedFederatedMatch) {
affiliated_form1_.federation_origin =
url::Origin(GURL("https://example.com/"));
+ affiliated_form1_.password_value = base::string16();
store_->AddLogin(affiliated_form1_);
client_->set_first_run_seen(true);
auto mock_helper = base::WrapUnique(new MockAffiliatedMatchHelper);
@@ -823,6 +866,7 @@ TEST_F(CredentialManagerDispatcherTest,
CredentialManagerOnRequestCredentialAffiliatedFederatedNoMatch) {
affiliated_form1_.federation_origin =
url::Origin(GURL("https://example.com/"));
+ affiliated_form1_.password_value = base::string16();
store_->AddLogin(affiliated_form1_);
client_->set_first_run_seen(true);
auto mock_helper = base::WrapUnique(new MockAffiliatedMatchHelper);
@@ -1234,6 +1278,7 @@ TEST_F(CredentialManagerDispatcherTest, BlacklistPasswordCredential) {
TEST_F(CredentialManagerDispatcherTest, BlacklistFederatedCredential) {
form_.federation_origin = url::Origin(GURL("https://example.com/"));
+ form_.password_value = base::string16();
form_.signon_realm = "federation://example.com/example.com";
EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
@@ -1294,6 +1339,7 @@ TEST_F(CredentialManagerDispatcherTest,
store_->AddLogin(blacklisted);
form_.federation_origin = url::Origin(GURL("https://example.com/"));
+ form_.password_value = base::string16();
form_.signon_realm = "federation://example.com/example.com";
CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_FEDERATED);
EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
« 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