| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/core/browser/password_reuse_detector.h" | 5 #include "components/password_manager/core/browser/password_reuse_detector.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 "https://evil.com", &mockConsumer); | 202 "https://evil.com", &mockConsumer); |
| 203 } | 203 } |
| 204 | 204 |
| 205 TEST(PasswordReuseDetectorTest, SyncPasswordReuseFound) { | 205 TEST(PasswordReuseDetectorTest, SyncPasswordReuseFound) { |
| 206 PasswordReuseDetector reuse_detector(nullptr); | 206 PasswordReuseDetector reuse_detector(nullptr); |
| 207 reuse_detector.OnGetPasswordStoreResults(GetForms(GetTestDomainsPasswords())); | 207 reuse_detector.OnGetPasswordStoreResults(GetForms(GetTestDomainsPasswords())); |
| 208 MockPasswordReuseDetectorConsumer mockConsumer; | 208 MockPasswordReuseDetectorConsumer mockConsumer; |
| 209 | 209 |
| 210 reuse_detector.SaveSyncPasswordHash(ASCIIToUTF16("sync_password")); | 210 reuse_detector.SaveSyncPasswordHash(ASCIIToUTF16("sync_password")); |
| 211 | 211 |
| 212 EXPECT_CALL(mockConsumer, OnReuseFound(ASCIIToUTF16("sync_password"), | 212 EXPECT_CALL(mockConsumer, |
| 213 "accounts.google.com", 1, 0)); | 213 OnReuseFound(ASCIIToUTF16("sync_password"), |
| 214 std::string(kSyncPasswordDomain), 1, 0)); |
| 214 reuse_detector.CheckReuse(ASCIIToUTF16("sync_password"), "https://evil.com", | 215 reuse_detector.CheckReuse(ASCIIToUTF16("sync_password"), "https://evil.com", |
| 215 &mockConsumer); | 216 &mockConsumer); |
| 216 } | 217 } |
| 217 | 218 |
| 218 TEST(PasswordReuseDetectorTest, SavedPasswordsReuseSyncPasswordAvailable) { | 219 TEST(PasswordReuseDetectorTest, SavedPasswordsReuseSyncPasswordAvailable) { |
| 219 // Check that reuse of saved passwords is detected also if the sync password | 220 // Check that reuse of saved passwords is detected also if the sync password |
| 220 // hash is saved. | 221 // hash is saved. |
| 221 PasswordReuseDetector reuse_detector(nullptr); | 222 PasswordReuseDetector reuse_detector(nullptr); |
| 222 reuse_detector.OnGetPasswordStoreResults(GetForms(GetTestDomainsPasswords())); | 223 reuse_detector.OnGetPasswordStoreResults(GetForms(GetTestDomainsPasswords())); |
| 223 MockPasswordReuseDetectorConsumer mockConsumer; | 224 MockPasswordReuseDetectorConsumer mockConsumer; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 236 PrefRegistry::NO_REGISTRATION_FLAGS); | 237 PrefRegistry::NO_REGISTRATION_FLAGS); |
| 237 ASSERT_FALSE(prefs.HasPrefPath(prefs::kSyncPasswordHash)); | 238 ASSERT_FALSE(prefs.HasPrefPath(prefs::kSyncPasswordHash)); |
| 238 PasswordReuseDetector reuse_detector(&prefs); | 239 PasswordReuseDetector reuse_detector(&prefs); |
| 239 reuse_detector.SaveSyncPasswordHash(ASCIIToUTF16("sync_password")); | 240 reuse_detector.SaveSyncPasswordHash(ASCIIToUTF16("sync_password")); |
| 240 EXPECT_TRUE(prefs.HasPrefPath(prefs::kSyncPasswordHash)); | 241 EXPECT_TRUE(prefs.HasPrefPath(prefs::kSyncPasswordHash)); |
| 241 } | 242 } |
| 242 | 243 |
| 243 } // namespace | 244 } // namespace |
| 244 | 245 |
| 245 } // namespace password_manager | 246 } // namespace password_manager |
| OLD | NEW |