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

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

Issue 879913004: Credential Management: Support zeroclick credential in 'request()'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test. Created 5 years, 11 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
Index: components/password_manager/content/browser/content_credential_manager_dispatcher_unittest.cc
diff --git a/components/password_manager/content/browser/content_credential_manager_dispatcher_unittest.cc b/components/password_manager/content/browser/content_credential_manager_dispatcher_unittest.cc
index 42956adc2ad4ae925252aee15b7fbddd86842d7b..552621a2e85e270dd2bf7b31d9350347a2e608c4 100644
--- a/components/password_manager/content/browser/content_credential_manager_dispatcher_unittest.cc
+++ b/components/password_manager/content/browser/content_credential_manager_dispatcher_unittest.cc
@@ -302,6 +302,70 @@ TEST_F(CredentialManagerDispatcherTest,
EXPECT_TRUE(client_->did_prompt_user_to_choose());
}
+TEST_F(
+ CredentialManagerDispatcherTest,
+ CredentialManagerOnRequestCredentialWithZeroClickOnlyEmptyPasswordStore) {
+ form_.is_zero_click = false;
+ store_->AddLogin(form_);
+
+ std::vector<GURL> federations;
+ dispatcher()->OnRequestCredential(kRequestId, true, federations);
vabr (Chromium) 2015/01/28 13:37:51 nit: I guess that "true" is the "require 0-click"
+
+ RunAllPendingTasks();
+
+ const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID;
+ const IPC::Message* message =
+ process()->sink().GetFirstMessageMatching(kMsgID);
+ EXPECT_TRUE(message);
+ EXPECT_FALSE(client_->did_prompt_user_to_choose());
+ CredentialManagerMsg_SendCredential::Param send_param;
+ CredentialManagerMsg_SendCredential::Read(message, &send_param);
+ EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, get<1>(send_param).type);
+}
+
+TEST_F(CredentialManagerDispatcherTest,
+ CredentialManagerOnRequestCredentialWithZeroClickOnlyFullPasswordStore) {
+ form_.is_zero_click = true;
+ store_->AddLogin(form_);
+
+ std::vector<GURL> federations;
+ dispatcher()->OnRequestCredential(kRequestId, true, federations);
+
+ RunAllPendingTasks();
+
+ const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID;
+ const IPC::Message* message =
+ process()->sink().GetFirstMessageMatching(kMsgID);
+ EXPECT_TRUE(message);
+ EXPECT_FALSE(client_->did_prompt_user_to_choose());
+ CredentialManagerMsg_SendCredential::Param send_param;
+ CredentialManagerMsg_SendCredential::Read(message, &send_param);
+ EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_LOCAL, get<1>(send_param).type);
+}
+
+TEST_F(CredentialManagerDispatcherTest,
+ CredentialManagerOnRequestCredentialWithZeroClickOnlyTwoPasswordStore) {
+ form_.is_zero_click = true;
+ store_->AddLogin(form_);
+ store_->AddLogin(form_);
+
+ std::vector<GURL> federations;
+ dispatcher()->OnRequestCredential(kRequestId, true, federations);
+
+ RunAllPendingTasks();
+
+ const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID;
+ const IPC::Message* message =
+ process()->sink().GetFirstMessageMatching(kMsgID);
+ EXPECT_TRUE(message);
+ EXPECT_FALSE(client_->did_prompt_user_to_choose());
+ CredentialManagerMsg_SendCredential::Param send_param;
+ CredentialManagerMsg_SendCredential::Read(message, &send_param);
+
+ // With two items in the password store, we shouldn't get credentials back.
+ EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, get<1>(send_param).type);
+}
+
TEST_F(CredentialManagerDispatcherTest,
CredentialManagerOnRequestCredentialWhileRequestPending) {
store_->AddLogin(form_);

Powered by Google App Engine
This is Rietveld 408576698