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

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

Issue 1723583003: CREDENTIAL: Filter affiliated credentials. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/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 da2ab7026c2221e64b48aef3ca01c554e1513b3e..fd7aca92178a7d2bd056250fd8b1eecad436c412 100644
--- a/components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc
+++ b/components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc
@@ -674,6 +674,84 @@ TEST_F(CredentialManagerDispatcherTest,
ExpectZeroClickSignInFailure();
}
+TEST_F(CredentialManagerDispatcherTest,
+ CredentialManagerOnRequestCredentialAffiliatedPasswordMatch) {
+ store_->AddLogin(affiliated_form1_);
+ client_->set_first_run_seen(true);
+ MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper;
+ store_->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper));
vabr (Chromium) 2016/02/23 09:24:54 nit: Here and below, please either inline mock_hel
+
+ std::vector<GURL> federations;
+ std::vector<std::string> affiliated_realms;
+ affiliated_realms.push_back(kTestAndroidRealm1);
+ mock_helper->ExpectCallToGetAffiliatedAndroidRealms(
+ dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
+
+ dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
+
+ ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_PASSWORD);
+}
+
+TEST_F(CredentialManagerDispatcherTest,
+ CredentialManagerOnRequestCredentialAffiliatedPasswordNoMatch) {
+ store_->AddLogin(affiliated_form1_);
+ client_->set_first_run_seen(true);
+ MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper;
+ store_->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper));
+
+ std::vector<GURL> federations;
+ std::vector<std::string> affiliated_realms;
+ affiliated_realms.push_back(kTestAndroidRealm1);
+ mock_helper->ExpectCallToGetAffiliatedAndroidRealms(
+ dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
+
+ dispatcher()->OnRequestCredential(kRequestId, true, false, federations);
vabr (Chromium) 2016/02/23 09:24:54 nit: The "false" here is the only difference to th
+
+ ExpectZeroClickSignInFailure();
+}
+
+TEST_F(CredentialManagerDispatcherTest,
+ CredentialManagerOnRequestCredentialAffiliatedFederatedMatch) {
+ affiliated_form1_.federation_url = GURL("https://example.com/");
+ store_->AddLogin(affiliated_form1_);
+ client_->set_first_run_seen(true);
+ MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper;
+ store_->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper));
+
+ std::vector<GURL> federations;
+ federations.push_back(GURL("https://example.com/"));
+
+ std::vector<std::string> affiliated_realms;
+ affiliated_realms.push_back(kTestAndroidRealm1);
+ mock_helper->ExpectCallToGetAffiliatedAndroidRealms(
+ dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
+
+ dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
+
+ ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_FEDERATED);
+}
+
+TEST_F(CredentialManagerDispatcherTest,
+ CredentialManagerOnRequestCredentialAffiliatedFederatedNoMatch) {
+ affiliated_form1_.federation_url = GURL("https://example.com/");
+ store_->AddLogin(affiliated_form1_);
+ client_->set_first_run_seen(true);
+ MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper;
+ store_->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper));
+
+ std::vector<GURL> federations;
+ federations.push_back(GURL("https://not-example.com/"));
+
+ std::vector<std::string> affiliated_realms;
+ affiliated_realms.push_back(kTestAndroidRealm1);
+ mock_helper->ExpectCallToGetAffiliatedAndroidRealms(
+ dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
+
+ dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
+
+ ExpectZeroClickSignInFailure();
+}
+
TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithoutFirstRun) {
client_->set_first_run_seen(false);

Powered by Google App Engine
This is Rietveld 408576698