Chromium Code Reviews| Index: components/password_manager/core/browser/password_store_unittest.cc |
| diff --git a/components/password_manager/core/browser/password_store_unittest.cc b/components/password_manager/core/browser/password_store_unittest.cc |
| index 53835261704c90b77ee545d875622a954127f13a..d93b0633809eaf650c7dacfa34147f4c0d06eeff 100644 |
| --- a/components/password_manager/core/browser/password_store_unittest.cc |
| +++ b/components/password_manager/core/browser/password_store_unittest.cc |
| @@ -971,6 +971,44 @@ TEST_F(PasswordStoreTest, CheckPasswordReuse) { |
| OSCryptMocker::TearDown(); |
| #endif |
| } |
| + |
| +TEST_F(PasswordStoreTest, SavingClearingSyncPassword) { |
| +#if defined(OS_MACOSX) |
| + // Mock Keychain. There is a call to Keychain on initializling |
| + // PasswordReuseDetector, so it should be mocked. |
| + OSCryptMocker::SetUpWithSingleton(); |
|
vasilii
2017/06/02 09:30:58
Why don't you put it into the test setup instead o
dvadym
2017/06/02 09:53:14
Thanks, it makes perfect sense. Done
|
| +#endif |
| + scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( |
| + base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), |
| + base::MakeUnique<LoginDatabase>(test_login_db_file_path()))); |
| + store->Init(syncer::SyncableService::StartSyncFlare(), nullptr); |
| + |
| + const base::string16 sync_password = base::ASCIIToUTF16("password"); |
| + const base::string16 input = base::ASCIIToUTF16("123password"); |
| + store->SaveSyncPasswordHash(sync_password); |
| + base::RunLoop().RunUntilIdle(); |
| + |
| + // Check that sync password reuse is found. |
| + MockPasswordReuseDetectorConsumer mock_consumer; |
| + EXPECT_CALL(mock_consumer, |
| + OnReuseFound(sync_password, "accounts.google.com", 1, 0)); |
|
vasilii
2017/06/02 09:30:58
How can the consumer get the plain-text sync passw
dvadym
2017/06/02 09:53:14
Yes, it's substring of input, which hash is equal
|
| + store->CheckReuse(input, "https://facebook.com", &mock_consumer); |
| + base::RunLoop().RunUntilIdle(); |
| + testing::Mock::VerifyAndClearExpectations(&mock_consumer); |
| + |
| + // Check that no sync password reuse is found after clearing the saved sync |
| + // password hash. |
| + store->ClearSyncPasswordHash(); |
| + EXPECT_CALL(mock_consumer, OnReuseFound(_, _, _, _)).Times(0); |
| + store->CheckReuse(input, "https://facebook.com", &mock_consumer); |
| + base::RunLoop().RunUntilIdle(); |
| + |
| + store->ShutdownOnUIThread(); |
| + base::RunLoop().RunUntilIdle(); |
| +#if defined(OS_MACOSX) |
| + OSCryptMocker::TearDown(); |
| +#endif |
| +} |
| #endif |
| } // namespace password_manager |