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

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: rework 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..eaf37c9a062161f8fbb109986f63376d12699c27 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
@@ -36,6 +36,7 @@ class TestPasswordManagerClient
: did_prompt_user_to_save_(false),
did_prompt_user_to_choose_(false),
is_off_the_record_(false),
+ is_zero_click_disabled_(false),
store_(store) {}
~TestPasswordManagerClient() override {}
@@ -75,6 +76,7 @@ class TestPasswordManagerClient
}
bool IsOffTheRecord() override { return is_off_the_record_; }
+ bool IsZeroClickDisabled() override { return is_zero_click_disabled_; }
bool did_prompt_user_to_save() const { return did_prompt_user_to_save_; }
bool did_prompt_user_to_choose() const { return did_prompt_user_to_choose_; }
@@ -87,10 +89,15 @@ class TestPasswordManagerClient
is_off_the_record_ = off_the_record;
}
+ void set_zero_click_disabled(bool zero_click_disabled) {
+ is_zero_click_disabled_ = zero_click_disabled;
+ }
+
private:
bool did_prompt_user_to_save_;
bool did_prompt_user_to_choose_;
bool is_off_the_record_;
+ bool is_zero_click_disabled_;
password_manager::PasswordStore* store_;
scoped_ptr<password_manager::PasswordFormManager> manager_;
};
@@ -288,6 +295,7 @@ TEST_F(CredentialManagerDispatcherTest,
TEST_F(CredentialManagerDispatcherTest,
CredentialManagerOnRequestCredentialWithFullPasswordStore) {
+ client_->set_zero_click_disabled(true);
Mike West 2015/01/28 14:42:14 Since we don't check the 'is_zero_click' attribute
store_->AddLogin(form_);
std::vector<GURL> federations;
@@ -302,8 +310,68 @@ TEST_F(CredentialManagerDispatcherTest,
EXPECT_TRUE(client_->did_prompt_user_to_choose());
}
+TEST_F(
+ CredentialManagerDispatcherTest,
+ CredentialManagerOnRequestCredentialWithZeroClickOnlyEmptyPasswordStore) {
+ 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_EMPTY, get<1>(send_param).type);
+}
+
+TEST_F(CredentialManagerDispatcherTest,
+ CredentialManagerOnRequestCredentialWithZeroClickOnlyFullPasswordStore) {
+ 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) {
+ 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) {
+ client_->set_zero_click_disabled(true);
Mike West 2015/01/28 14:42:14 Ditto.
store_->AddLogin(form_);
std::vector<GURL> federations;

Powered by Google App Engine
This is Rietveld 408576698