| 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 // The passwords in the tests below are all empty because PasswordStoreDefault | 5 // The passwords in the tests below are all empty because PasswordStoreDefault |
| 6 // does not store the actual passwords on OS X (they are stored in the Keychain | 6 // does not store the actual passwords on OS X (they are stored in the Keychain |
| 7 // instead). We could special-case it, but it is easier to just have empty | 7 // instead). We could special-case it, but it is easier to just have empty |
| 8 // passwords. This will not be needed anymore if crbug.com/466638 is fixed. | 8 // passwords. This will not be needed anymore if crbug.com/466638 is fixed. |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/synchronization/waitable_event.h" | 22 #include "base/synchronization/waitable_event.h" |
| 23 #include "base/test/scoped_task_environment.h" | 23 #include "base/test/scoped_task_environment.h" |
| 24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
| 25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 27 #include "components/password_manager/core/browser/affiliated_match_helper.h" | 27 #include "components/password_manager/core/browser/affiliated_match_helper.h" |
| 28 #include "components/password_manager/core/browser/affiliation_service.h" | 28 #include "components/password_manager/core/browser/affiliation_service.h" |
| 29 #include "components/password_manager/core/browser/mock_affiliated_match_helper.
h" | 29 #include "components/password_manager/core/browser/mock_affiliated_match_helper.
h" |
| 30 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 30 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
| 31 #include "components/password_manager/core/browser/password_reuse_detector.h" |
| 31 #include "components/password_manager/core/browser/password_store_consumer.h" | 32 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 32 #include "components/password_manager/core/browser/password_store_default.h" | 33 #include "components/password_manager/core/browser/password_store_default.h" |
| 33 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 35 | 36 |
| 36 #if defined(OS_MACOSX) | 37 #if defined(OS_MACOSX) |
| 37 #include "components/os_crypt/os_crypt_mocker.h" | 38 #include "components/os_crypt/os_crypt_mocker.h" |
| 38 #endif | 39 #endif |
| 39 | 40 |
| 40 using autofill::PasswordForm; | 41 using autofill::PasswordForm; |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 base::MakeUnique<LoginDatabase>(test_login_db_file_path()))); | 983 base::MakeUnique<LoginDatabase>(test_login_db_file_path()))); |
| 983 store->Init(syncer::SyncableService::StartSyncFlare(), nullptr); | 984 store->Init(syncer::SyncableService::StartSyncFlare(), nullptr); |
| 984 | 985 |
| 985 const base::string16 sync_password = base::ASCIIToUTF16("password"); | 986 const base::string16 sync_password = base::ASCIIToUTF16("password"); |
| 986 const base::string16 input = base::ASCIIToUTF16("123password"); | 987 const base::string16 input = base::ASCIIToUTF16("123password"); |
| 987 store->SaveSyncPasswordHash(sync_password); | 988 store->SaveSyncPasswordHash(sync_password); |
| 988 base::RunLoop().RunUntilIdle(); | 989 base::RunLoop().RunUntilIdle(); |
| 989 | 990 |
| 990 // Check that sync password reuse is found. | 991 // Check that sync password reuse is found. |
| 991 MockPasswordReuseDetectorConsumer mock_consumer; | 992 MockPasswordReuseDetectorConsumer mock_consumer; |
| 992 EXPECT_CALL(mock_consumer, | 993 EXPECT_CALL( |
| 993 OnReuseFound(sync_password, "accounts.google.com", 1, 0)); | 994 mock_consumer, |
| 995 OnReuseFound(sync_password, std::string(kSyncPasswordDomain), 1, 0)); |
| 994 store->CheckReuse(input, "https://facebook.com", &mock_consumer); | 996 store->CheckReuse(input, "https://facebook.com", &mock_consumer); |
| 995 base::RunLoop().RunUntilIdle(); | 997 base::RunLoop().RunUntilIdle(); |
| 996 testing::Mock::VerifyAndClearExpectations(&mock_consumer); | 998 testing::Mock::VerifyAndClearExpectations(&mock_consumer); |
| 997 | 999 |
| 998 // Check that no sync password reuse is found after clearing the saved sync | 1000 // Check that no sync password reuse is found after clearing the saved sync |
| 999 // password hash. | 1001 // password hash. |
| 1000 store->ClearSyncPasswordHash(); | 1002 store->ClearSyncPasswordHash(); |
| 1001 EXPECT_CALL(mock_consumer, OnReuseFound(_, _, _, _)).Times(0); | 1003 EXPECT_CALL(mock_consumer, OnReuseFound(_, _, _, _)).Times(0); |
| 1002 store->CheckReuse(input, "https://facebook.com", &mock_consumer); | 1004 store->CheckReuse(input, "https://facebook.com", &mock_consumer); |
| 1003 base::RunLoop().RunUntilIdle(); | 1005 base::RunLoop().RunUntilIdle(); |
| 1004 | 1006 |
| 1005 store->ShutdownOnUIThread(); | 1007 store->ShutdownOnUIThread(); |
| 1006 base::RunLoop().RunUntilIdle(); | 1008 base::RunLoop().RunUntilIdle(); |
| 1007 } | 1009 } |
| 1008 #endif | 1010 #endif |
| 1009 | 1011 |
| 1010 } // namespace password_manager | 1012 } // namespace password_manager |
| OLD | NEW |