| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/password_manager/content/browser/credential_manager_impl.h" | 5 #include "components/password_manager/content/browser/credential_manager_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 duplicate.username_element = base::ASCIIToUTF16("different_username_element"); | 706 duplicate.username_element = base::ASCIIToUTF16("different_username_element"); |
| 707 store_->AddLogin(duplicate); | 707 store_->AddLogin(duplicate); |
| 708 | 708 |
| 709 std::vector<GURL> federations; | 709 std::vector<GURL> federations; |
| 710 ExpectZeroClickSignInSuccess(false, true, federations, | 710 ExpectZeroClickSignInSuccess(false, true, federations, |
| 711 CredentialType::CREDENTIAL_TYPE_PASSWORD); | 711 CredentialType::CREDENTIAL_TYPE_PASSWORD); |
| 712 } | 712 } |
| 713 | 713 |
| 714 TEST_F(CredentialManagerImplTest, | 714 TEST_F(CredentialManagerImplTest, |
| 715 CredentialManagerOnRequestCredentialWithDuplicates) { | 715 CredentialManagerOnRequestCredentialWithDuplicates) { |
| 716 // Add 7 credentials. Two buckets of duplicates and one empty username. There | 716 // Add 8 credentials. Two buckets of duplicates, one empty username and one |
| 717 // should be just two in the account chooser. | 717 // federated one. There should be just 3 in the account chooser. |
| 718 form_.preferred = true; | 718 form_.preferred = true; |
| 719 form_.username_element = base::ASCIIToUTF16("username_element"); | 719 form_.username_element = base::ASCIIToUTF16("username_element"); |
| 720 store_->AddLogin(form_); | 720 store_->AddLogin(form_); |
| 721 autofill::PasswordForm empty = form_; | 721 autofill::PasswordForm empty = form_; |
| 722 empty.username_value.clear(); | 722 empty.username_value.clear(); |
| 723 store_->AddLogin(empty); | 723 store_->AddLogin(empty); |
| 724 autofill::PasswordForm duplicate = form_; | 724 autofill::PasswordForm duplicate = form_; |
| 725 duplicate.username_element = base::ASCIIToUTF16("username_element1"); | 725 duplicate.username_element = base::ASCIIToUTF16("username_element1"); |
| 726 duplicate.is_public_suffix_match = true; | 726 duplicate.is_public_suffix_match = true; |
| 727 store_->AddLogin(duplicate); | 727 store_->AddLogin(duplicate); |
| 728 duplicate = form_; | 728 duplicate = form_; |
| 729 duplicate.username_element = base::ASCIIToUTF16("username_element2"); | 729 duplicate.username_element = base::ASCIIToUTF16("username_element2"); |
| 730 duplicate.preferred = false; | 730 duplicate.preferred = false; |
| 731 store_->AddLogin(duplicate); | 731 store_->AddLogin(duplicate); |
| 732 | 732 |
| 733 origin_path_form_.preferred = true; | 733 origin_path_form_.preferred = true; |
| 734 store_->AddLogin(origin_path_form_); | 734 store_->AddLogin(origin_path_form_); |
| 735 duplicate = origin_path_form_; | 735 duplicate = origin_path_form_; |
| 736 duplicate.username_element = base::ASCIIToUTF16("username_element3"); | 736 duplicate.username_element = base::ASCIIToUTF16("username_element3"); |
| 737 duplicate.is_public_suffix_match = true; | 737 duplicate.is_public_suffix_match = true; |
| 738 store_->AddLogin(duplicate); | 738 store_->AddLogin(duplicate); |
| 739 duplicate = origin_path_form_; | 739 duplicate = origin_path_form_; |
| 740 duplicate.username_element = base::ASCIIToUTF16("username_element4"); | 740 duplicate.username_element = base::ASCIIToUTF16("username_element4"); |
| 741 duplicate.preferred = false; | 741 duplicate.preferred = false; |
| 742 store_->AddLogin(duplicate); | 742 store_->AddLogin(duplicate); |
| 743 autofill::PasswordForm federated = origin_path_form_; |
| 744 federated.password_value.clear(); |
| 745 federated.federation_origin = url::Origin(GURL("https://google.com/")); |
| 746 federated.signon_realm = |
| 747 "federation://" + federated.origin.host() + "/google.com"; |
| 748 store_->AddLogin(federated); |
| 743 | 749 |
| 744 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr( | 750 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr( |
| 745 UnorderedElementsAre(Pointee(form_), | 751 UnorderedElementsAre(Pointee(form_), |
| 746 Pointee(origin_path_form_)), | 752 Pointee(origin_path_form_), |
| 753 Pointee(federated)), |
| 747 testing::IsEmpty(), _, _)); | 754 testing::IsEmpty(), _, _)); |
| 748 | 755 |
| 749 bool called = false; | 756 bool called = false; |
| 750 mojom::CredentialManagerError error; | 757 mojom::CredentialManagerError error; |
| 751 base::Optional<CredentialInfo> credential; | 758 base::Optional<CredentialInfo> credential; |
| 752 std::vector<GURL> federations; | 759 std::vector<GURL> federations; |
| 760 federations.push_back(GURL("https://google.com/")); |
| 753 CallGet(false, true, federations, | 761 CallGet(false, true, federations, |
| 754 base::Bind(&GetCredentialCallback, &called, &error, &credential)); | 762 base::Bind(&GetCredentialCallback, &called, &error, &credential)); |
| 755 | 763 |
| 756 RunAllPendingTasks(); | 764 RunAllPendingTasks(); |
| 757 } | 765 } |
| 758 | 766 |
| 759 TEST_F(CredentialManagerImplTest, | 767 TEST_F(CredentialManagerImplTest, |
| 760 CredentialManagerOnRequestCredentialWithCrossOriginPasswordStore) { | 768 CredentialManagerOnRequestCredentialWithCrossOriginPasswordStore) { |
| 761 store_->AddLogin(cross_origin_form_); | 769 store_->AddLogin(cross_origin_form_); |
| 762 | 770 |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 _, CredentialSourceType::CREDENTIAL_SOURCE_API)); | 1373 _, CredentialSourceType::CREDENTIAL_SOURCE_API)); |
| 1366 CallStore(info, base::Bind(&RespondCallback, &called)); | 1374 CallStore(info, base::Bind(&RespondCallback, &called)); |
| 1367 // Allow the PasswordFormManager to talk to the password store | 1375 // Allow the PasswordFormManager to talk to the password store |
| 1368 RunAllPendingTasks(); | 1376 RunAllPendingTasks(); |
| 1369 | 1377 |
| 1370 ASSERT_TRUE(client_->pending_manager()); | 1378 ASSERT_TRUE(client_->pending_manager()); |
| 1371 EXPECT_TRUE(client_->pending_manager()->IsBlacklisted()); | 1379 EXPECT_TRUE(client_->pending_manager()->IsBlacklisted()); |
| 1372 } | 1380 } |
| 1373 | 1381 |
| 1374 } // namespace password_manager | 1382 } // namespace password_manager |
| OLD | NEW |