Chromium Code Reviews| 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_dispatc her.h" | 5 #include "components/password_manager/content/browser/credential_manager_dispatc her.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 667 | 667 |
| 668 std::vector<GURL> federations; | 668 std::vector<GURL> federations; |
| 669 federations.push_back(GURL("https://not-example.com/")); | 669 federations.push_back(GURL("https://not-example.com/")); |
| 670 | 670 |
| 671 EXPECT_CALL(*client_, NotifyUserAutoSigninBlockedOnFirstRunPtr(_)).Times(0); | 671 EXPECT_CALL(*client_, NotifyUserAutoSigninBlockedOnFirstRunPtr(_)).Times(0); |
| 672 dispatcher()->OnRequestCredential(kRequestId, true, true, federations); | 672 dispatcher()->OnRequestCredential(kRequestId, true, true, federations); |
| 673 | 673 |
| 674 ExpectZeroClickSignInFailure(); | 674 ExpectZeroClickSignInFailure(); |
| 675 } | 675 } |
| 676 | 676 |
| 677 TEST_F(CredentialManagerDispatcherTest, | |
| 678 CredentialManagerOnRequestCredentialAffiliatedPasswordMatch) { | |
| 679 store_->AddLogin(affiliated_form1_); | |
| 680 client_->set_first_run_seen(true); | |
| 681 MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper; | |
| 682 store_->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper)); | |
|
vabr (Chromium)
2016/02/23 09:24:54
nit: Here and below, please either inline mock_hel
| |
| 683 | |
| 684 std::vector<GURL> federations; | |
| 685 std::vector<std::string> affiliated_realms; | |
| 686 affiliated_realms.push_back(kTestAndroidRealm1); | |
| 687 mock_helper->ExpectCallToGetAffiliatedAndroidRealms( | |
| 688 dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); | |
| 689 | |
| 690 dispatcher()->OnRequestCredential(kRequestId, true, true, federations); | |
| 691 | |
| 692 ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_PASSWORD); | |
| 693 } | |
| 694 | |
| 695 TEST_F(CredentialManagerDispatcherTest, | |
| 696 CredentialManagerOnRequestCredentialAffiliatedPasswordNoMatch) { | |
| 697 store_->AddLogin(affiliated_form1_); | |
| 698 client_->set_first_run_seen(true); | |
| 699 MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper; | |
| 700 store_->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper)); | |
| 701 | |
| 702 std::vector<GURL> federations; | |
| 703 std::vector<std::string> affiliated_realms; | |
| 704 affiliated_realms.push_back(kTestAndroidRealm1); | |
| 705 mock_helper->ExpectCallToGetAffiliatedAndroidRealms( | |
| 706 dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); | |
| 707 | |
| 708 dispatcher()->OnRequestCredential(kRequestId, true, false, federations); | |
|
vabr (Chromium)
2016/02/23 09:24:54
nit: The "false" here is the only difference to th
| |
| 709 | |
| 710 ExpectZeroClickSignInFailure(); | |
| 711 } | |
| 712 | |
| 713 TEST_F(CredentialManagerDispatcherTest, | |
| 714 CredentialManagerOnRequestCredentialAffiliatedFederatedMatch) { | |
| 715 affiliated_form1_.federation_url = GURL("https://example.com/"); | |
| 716 store_->AddLogin(affiliated_form1_); | |
| 717 client_->set_first_run_seen(true); | |
| 718 MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper; | |
| 719 store_->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper)); | |
| 720 | |
| 721 std::vector<GURL> federations; | |
| 722 federations.push_back(GURL("https://example.com/")); | |
| 723 | |
| 724 std::vector<std::string> affiliated_realms; | |
| 725 affiliated_realms.push_back(kTestAndroidRealm1); | |
| 726 mock_helper->ExpectCallToGetAffiliatedAndroidRealms( | |
| 727 dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); | |
| 728 | |
| 729 dispatcher()->OnRequestCredential(kRequestId, true, true, federations); | |
| 730 | |
| 731 ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_FEDERATED); | |
| 732 } | |
| 733 | |
| 734 TEST_F(CredentialManagerDispatcherTest, | |
| 735 CredentialManagerOnRequestCredentialAffiliatedFederatedNoMatch) { | |
| 736 affiliated_form1_.federation_url = GURL("https://example.com/"); | |
| 737 store_->AddLogin(affiliated_form1_); | |
| 738 client_->set_first_run_seen(true); | |
| 739 MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper; | |
| 740 store_->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper)); | |
| 741 | |
| 742 std::vector<GURL> federations; | |
| 743 federations.push_back(GURL("https://not-example.com/")); | |
| 744 | |
| 745 std::vector<std::string> affiliated_realms; | |
| 746 affiliated_realms.push_back(kTestAndroidRealm1); | |
| 747 mock_helper->ExpectCallToGetAffiliatedAndroidRealms( | |
| 748 dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); | |
| 749 | |
| 750 dispatcher()->OnRequestCredential(kRequestId, true, true, federations); | |
| 751 | |
| 752 ExpectZeroClickSignInFailure(); | |
| 753 } | |
| 754 | |
| 677 TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithoutFirstRun) { | 755 TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithoutFirstRun) { |
| 678 client_->set_first_run_seen(false); | 756 client_->set_first_run_seen(false); |
| 679 | 757 |
| 680 store_->AddLogin(form_); | 758 store_->AddLogin(form_); |
| 681 | 759 |
| 682 std::vector<GURL> federations; | 760 std::vector<GURL> federations; |
| 683 EXPECT_CALL(*client_, | 761 EXPECT_CALL(*client_, |
| 684 NotifyUserAutoSigninBlockedOnFirstRunPtr(testing::Pointee(form_))) | 762 NotifyUserAutoSigninBlockedOnFirstRunPtr(testing::Pointee(form_))) |
| 685 .Times(1); | 763 .Times(1); |
| 686 dispatcher()->OnRequestCredential(kRequestId, true, true, federations); | 764 dispatcher()->OnRequestCredential(kRequestId, true, true, federations); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1012 TEST_F(CredentialManagerDispatcherTest, GetSynthesizedFormForOrigin) { | 1090 TEST_F(CredentialManagerDispatcherTest, GetSynthesizedFormForOrigin) { |
| 1013 autofill::PasswordForm synthesized = | 1091 autofill::PasswordForm synthesized = |
| 1014 dispatcher_->GetSynthesizedFormForOrigin(); | 1092 dispatcher_->GetSynthesizedFormForOrigin(); |
| 1015 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec()); | 1093 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec()); |
| 1016 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm); | 1094 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm); |
| 1017 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme); | 1095 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme); |
| 1018 EXPECT_TRUE(synthesized.ssl_valid); | 1096 EXPECT_TRUE(synthesized.ssl_valid); |
| 1019 } | 1097 } |
| 1020 | 1098 |
| 1021 } // namespace password_manager | 1099 } // namespace password_manager |
| OLD | NEW |