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

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

Issue 2913323004: Implementation of sync password hash clearing. (Closed)
Patch Set: comments 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
« no previous file with comments | « components/password_manager/core/browser/password_store.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 &mock_consumer); 964 &mock_consumer);
965 base::RunLoop().RunUntilIdle(); 965 base::RunLoop().RunUntilIdle();
966 } 966 }
967 967
968 store->ShutdownOnUIThread(); 968 store->ShutdownOnUIThread();
969 base::RunLoop().RunUntilIdle(); 969 base::RunLoop().RunUntilIdle();
970 #if defined(OS_MACOSX) 970 #if defined(OS_MACOSX)
971 OSCryptMocker::TearDown(); 971 OSCryptMocker::TearDown();
972 #endif 972 #endif
973 } 973 }
974
975 TEST_F(PasswordStoreTest, SavingClearingSyncPassword) {
976 #if defined(OS_MACOSX)
977 // Mock Keychain. There is a call to Keychain on initializling
978 // PasswordReuseDetector, so it should be mocked.
979 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
980 #endif
981 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault(
982 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
983 base::MakeUnique<LoginDatabase>(test_login_db_file_path())));
984 store->Init(syncer::SyncableService::StartSyncFlare(), nullptr);
985
986 const base::string16 sync_password = base::ASCIIToUTF16("password");
987 const base::string16 input = base::ASCIIToUTF16("123password");
988 store->SaveSyncPasswordHash(sync_password);
989 base::RunLoop().RunUntilIdle();
990
991 // Check that sync password reuse is found.
992 MockPasswordReuseDetectorConsumer mock_consumer;
993 EXPECT_CALL(mock_consumer,
994 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
995 store->CheckReuse(input, "https://facebook.com", &mock_consumer);
996 base::RunLoop().RunUntilIdle();
997 testing::Mock::VerifyAndClearExpectations(&mock_consumer);
998
999 // Check that no sync password reuse is found after clearing the saved sync
1000 // password hash.
1001 store->ClearSyncPasswordHash();
1002 EXPECT_CALL(mock_consumer, OnReuseFound(_, _, _, _)).Times(0);
1003 store->CheckReuse(input, "https://facebook.com", &mock_consumer);
1004 base::RunLoop().RunUntilIdle();
1005
1006 store->ShutdownOnUIThread();
1007 base::RunLoop().RunUntilIdle();
1008 #if defined(OS_MACOSX)
1009 OSCryptMocker::TearDown();
1010 #endif
1011 }
974 #endif 1012 #endif
975 1013
976 } // namespace password_manager 1014 } // namespace password_manager
OLDNEW
« no previous file with comments | « components/password_manager/core/browser/password_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698