OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdarg.h> | 5 #include <stdarg.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 STLDeleteElements(&form_list); | 526 STLDeleteElements(&form_list); |
527 return true; | 527 return true; |
528 } | 528 } |
529 | 529 |
530 // Test that updating does not use PSL matching: Add a www.facebook.com | 530 // Test that updating does not use PSL matching: Add a www.facebook.com |
531 // password, then use PSL matching to get a copy of it for m.facebook.com, and | 531 // password, then use PSL matching to get a copy of it for m.facebook.com, and |
532 // add that copy as well. Now update the www.facebook.com password -- the | 532 // add that copy as well. Now update the www.facebook.com password -- the |
533 // m.facebook.com password should not get updated. Depending on the argument, | 533 // m.facebook.com password should not get updated. Depending on the argument, |
534 // the credential update is done via UpdateLogin or AddLogin. | 534 // the credential update is done via UpdateLogin or AddLogin. |
535 void CheckPSLUpdate(UpdateType update_type) { | 535 void CheckPSLUpdate(UpdateType update_type) { |
536 password_manager::PSLMatchingHelper helper; | |
537 ASSERT_TRUE(helper.IsMatchingEnabled()); | |
538 | |
539 NativeBackendGnome backend(321); | 536 NativeBackendGnome backend(321); |
540 backend.Init(); | 537 backend.Init(); |
541 | 538 |
542 // Add |form_facebook_| to saved logins. | 539 // Add |form_facebook_| to saved logins. |
543 BrowserThread::PostTask( | 540 BrowserThread::PostTask( |
544 BrowserThread::DB, | 541 BrowserThread::DB, |
545 FROM_HERE, | 542 FROM_HERE, |
546 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), | 543 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), |
547 base::Unretained(&backend), | 544 base::Unretained(&backend), |
548 form_facebook_)); | 545 form_facebook_)); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 | 790 |
794 EXPECT_EQ(1u, mock_keyring_items.size()); | 791 EXPECT_EQ(1u, mock_keyring_items.size()); |
795 if (mock_keyring_items.size() > 0) | 792 if (mock_keyring_items.size() > 0) |
796 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); | 793 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); |
797 } | 794 } |
798 | 795 |
799 // Save a password for www.facebook.com and see it suggested for m.facebook.com. | 796 // Save a password for www.facebook.com and see it suggested for m.facebook.com. |
800 TEST_F(NativeBackendGnomeTest, PSLMatchingPositive) { | 797 TEST_F(NativeBackendGnomeTest, PSLMatchingPositive) { |
801 PasswordForm result; | 798 PasswordForm result; |
802 const GURL kMobileURL("http://m.facebook.com/"); | 799 const GURL kMobileURL("http://m.facebook.com/"); |
803 password_manager::PSLMatchingHelper helper; | |
804 ASSERT_TRUE(helper.IsMatchingEnabled()); | |
805 EXPECT_TRUE(CheckCredentialAvailability( | 800 EXPECT_TRUE(CheckCredentialAvailability( |
806 form_facebook_, kMobileURL, PasswordForm::SCHEME_HTML, &result)); | 801 form_facebook_, kMobileURL, PasswordForm::SCHEME_HTML, &result)); |
807 EXPECT_EQ(kMobileURL, result.origin); | 802 EXPECT_EQ(kMobileURL, result.origin); |
808 EXPECT_EQ(kMobileURL.spec(), result.signon_realm); | 803 EXPECT_EQ(kMobileURL.spec(), result.signon_realm); |
809 } | 804 } |
810 | 805 |
811 // Save a password for www.facebook.com and see it not suggested for | 806 // Save a password for www.facebook.com and see it not suggested for |
812 // m-facebook.com. | 807 // m-facebook.com. |
813 TEST_F(NativeBackendGnomeTest, PSLMatchingNegativeDomainMismatch) { | 808 TEST_F(NativeBackendGnomeTest, PSLMatchingNegativeDomainMismatch) { |
814 password_manager::PSLMatchingHelper helper; | |
815 ASSERT_TRUE(helper.IsMatchingEnabled()); | |
816 EXPECT_FALSE(CheckCredentialAvailability( | 809 EXPECT_FALSE(CheckCredentialAvailability( |
817 form_facebook_, GURL("http://m-facebook.com/"), | 810 form_facebook_, GURL("http://m-facebook.com/"), |
818 PasswordForm::SCHEME_HTML, NULL)); | 811 PasswordForm::SCHEME_HTML, NULL)); |
819 } | 812 } |
820 | 813 |
821 // Test PSL matching is off for domains excluded from it. | 814 // Test PSL matching is off for domains excluded from it. |
822 TEST_F(NativeBackendGnomeTest, PSLMatchingDisabledDomains) { | 815 TEST_F(NativeBackendGnomeTest, PSLMatchingDisabledDomains) { |
823 password_manager::PSLMatchingHelper helper; | |
824 ASSERT_TRUE(helper.IsMatchingEnabled()); | |
825 EXPECT_FALSE(CheckCredentialAvailability( | 816 EXPECT_FALSE(CheckCredentialAvailability( |
826 form_google_, GURL("http://one.google.com/"), | 817 form_google_, GURL("http://one.google.com/"), |
827 PasswordForm::SCHEME_HTML, NULL)); | 818 PasswordForm::SCHEME_HTML, NULL)); |
828 } | 819 } |
829 | 820 |
830 // Make sure PSL matches aren't available for non-HTML forms. | 821 // Make sure PSL matches aren't available for non-HTML forms. |
831 TEST_F(NativeBackendGnomeTest, PSLMatchingDisabledForNonHTMLForms) { | 822 TEST_F(NativeBackendGnomeTest, PSLMatchingDisabledForNonHTMLForms) { |
832 password_manager::PSLMatchingHelper helper; | |
833 ASSERT_TRUE(helper.IsMatchingEnabled()); | |
834 | |
835 CheckMatchingWithScheme(PasswordForm::SCHEME_BASIC); | 823 CheckMatchingWithScheme(PasswordForm::SCHEME_BASIC); |
836 CheckMatchingWithScheme(PasswordForm::SCHEME_DIGEST); | 824 CheckMatchingWithScheme(PasswordForm::SCHEME_DIGEST); |
837 CheckMatchingWithScheme(PasswordForm::SCHEME_OTHER); | 825 CheckMatchingWithScheme(PasswordForm::SCHEME_OTHER); |
838 | 826 |
839 } | 827 } |
840 | 828 |
841 TEST_F(NativeBackendGnomeTest, PSLUpdatingStrictUpdateLogin) { | 829 TEST_F(NativeBackendGnomeTest, PSLUpdatingStrictUpdateLogin) { |
842 CheckPSLUpdate(UPDATE_BY_UPDATELOGIN); | 830 CheckPSLUpdate(UPDATE_BY_UPDATELOGIN); |
843 } | 831 } |
844 | 832 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 | 1071 |
1084 TEST_F(NativeBackendGnomeTest, RemoveLoginsCreatedBetween) { | 1072 TEST_F(NativeBackendGnomeTest, RemoveLoginsCreatedBetween) { |
1085 CheckRemoveLoginsBetween(CREATED); | 1073 CheckRemoveLoginsBetween(CREATED); |
1086 } | 1074 } |
1087 | 1075 |
1088 TEST_F(NativeBackendGnomeTest, RemoveLoginsSyncedBetween) { | 1076 TEST_F(NativeBackendGnomeTest, RemoveLoginsSyncedBetween) { |
1089 CheckRemoveLoginsBetween(SYNCED); | 1077 CheckRemoveLoginsBetween(SYNCED); |
1090 } | 1078 } |
1091 | 1079 |
1092 // TODO(mdm): add more basic tests here at some point. | 1080 // TODO(mdm): add more basic tests here at some point. |
OLD | NEW |