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

Side by Side Diff: components/password_manager/core/browser/password_reuse_detector_unittest.cc

Issue 2912383004: Fill is_chrome_signin_password field in the password entry pings. (Closed)
Patch Set: Fix deps Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "components/autofill/core/common/password_form.h" 12 #include "components/autofill/core/common/password_form.h"
13 #include "components/password_manager/core/browser/password_manager_test_utils.h " 13 #include "components/password_manager/core/browser/password_manager_test_utils.h "
14 #include "components/password_manager/core/common/password_manager_pref_names.h" 14 #include "components/password_manager/core/common/password_manager_pref_names.h"
15 #include "components/prefs/pref_registry_simple.h" 15 #include "components/prefs/pref_registry_simple.h"
16 #include "components/prefs/testing_pref_service.h" 16 #include "components/prefs/testing_pref_service.h"
17 #include "components/safe_browsing/common/safebrowsing_constants.h"
17 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 using autofill::PasswordForm; 21 using autofill::PasswordForm;
21 using base::ASCIIToUTF16; 22 using base::ASCIIToUTF16;
22 using testing::_; 23 using testing::_;
23 24
24 namespace password_manager { 25 namespace password_manager {
25 26
26 namespace { 27 namespace {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 "https://evil.com", &mockConsumer); 203 "https://evil.com", &mockConsumer);
203 } 204 }
204 205
205 TEST(PasswordReuseDetectorTest, SyncPasswordReuseFound) { 206 TEST(PasswordReuseDetectorTest, SyncPasswordReuseFound) {
206 PasswordReuseDetector reuse_detector(nullptr); 207 PasswordReuseDetector reuse_detector(nullptr);
207 reuse_detector.OnGetPasswordStoreResults(GetForms(GetTestDomainsPasswords())); 208 reuse_detector.OnGetPasswordStoreResults(GetForms(GetTestDomainsPasswords()));
208 MockPasswordReuseDetectorConsumer mockConsumer; 209 MockPasswordReuseDetectorConsumer mockConsumer;
209 210
210 reuse_detector.SaveSyncPasswordHash(ASCIIToUTF16("sync_password")); 211 reuse_detector.SaveSyncPasswordHash(ASCIIToUTF16("sync_password"));
211 212
212 EXPECT_CALL(mockConsumer, OnReuseFound(ASCIIToUTF16("sync_password"), 213 EXPECT_CALL(
213 "accounts.google.com", 1, 0)); 214 mockConsumer,
215 OnReuseFound(ASCIIToUTF16("sync_password"),
216 std::string(safe_browsing::kSyncPasswordDomain), 1, 0));
214 reuse_detector.CheckReuse(ASCIIToUTF16("sync_password"), "https://evil.com", 217 reuse_detector.CheckReuse(ASCIIToUTF16("sync_password"), "https://evil.com",
215 &mockConsumer); 218 &mockConsumer);
216 } 219 }
217 220
218 TEST(PasswordReuseDetectorTest, SavedPasswordsReuseSyncPasswordAvailable) { 221 TEST(PasswordReuseDetectorTest, SavedPasswordsReuseSyncPasswordAvailable) {
219 // Check that reuse of saved passwords is detected also if the sync password 222 // Check that reuse of saved passwords is detected also if the sync password
220 // hash is saved. 223 // hash is saved.
221 PasswordReuseDetector reuse_detector(nullptr); 224 PasswordReuseDetector reuse_detector(nullptr);
222 reuse_detector.OnGetPasswordStoreResults(GetForms(GetTestDomainsPasswords())); 225 reuse_detector.OnGetPasswordStoreResults(GetForms(GetTestDomainsPasswords()));
223 MockPasswordReuseDetectorConsumer mockConsumer; 226 MockPasswordReuseDetectorConsumer mockConsumer;
(...skipping 12 matching lines...) Expand all
236 PrefRegistry::NO_REGISTRATION_FLAGS); 239 PrefRegistry::NO_REGISTRATION_FLAGS);
237 ASSERT_FALSE(prefs.HasPrefPath(prefs::kSyncPasswordHash)); 240 ASSERT_FALSE(prefs.HasPrefPath(prefs::kSyncPasswordHash));
238 PasswordReuseDetector reuse_detector(&prefs); 241 PasswordReuseDetector reuse_detector(&prefs);
239 reuse_detector.SaveSyncPasswordHash(ASCIIToUTF16("sync_password")); 242 reuse_detector.SaveSyncPasswordHash(ASCIIToUTF16("sync_password"));
240 EXPECT_TRUE(prefs.HasPrefPath(prefs::kSyncPasswordHash)); 243 EXPECT_TRUE(prefs.HasPrefPath(prefs::kSyncPasswordHash));
241 } 244 }
242 245
243 } // namespace 246 } // namespace
244 247
245 } // namespace password_manager 248 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698