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

Side by Side Diff: chrome/browser/chromeos/login/parallel_authenticator_unittest.cc

Issue 23903051: Eliminate CHECK from CryptohomeLibrary::LoadSystemSalt (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 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 | Annotate | Revision Log
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 #include "chrome/browser/chromeos/login/parallel_authenticator.h" 5 #include "chrome/browser/chromeos/login/parallel_authenticator.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 .Times(1) 510 .Times(1)
511 .RetiresOnSaturation(); 511 .RetiresOnSaturation();
512 EXPECT_CALL(*mock_caller_, AsyncMount(username_, hash_ascii_, 512 EXPECT_CALL(*mock_caller_, AsyncMount(username_, hash_ascii_,
513 cryptohome::MOUNT_FLAGS_NONE, _)) 513 cryptohome::MOUNT_FLAGS_NONE, _))
514 .Times(1) 514 .Times(1)
515 .RetiresOnSaturation(); 515 .RetiresOnSaturation();
516 EXPECT_CALL(*mock_caller_, AsyncGetSanitizedUsername(username_, _)) 516 EXPECT_CALL(*mock_caller_, AsyncGetSanitizedUsername(username_, _))
517 .Times(1) 517 .Times(1)
518 .RetiresOnSaturation(); 518 .RetiresOnSaturation();
519 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) 519 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt())
520 .WillOnce(Return(std::string())) 520 .WillOnce(Return(std::string("mock_system_salt")))
521 .RetiresOnSaturation(); 521 .RetiresOnSaturation();
522 522
523 state_->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone()); 523 state_->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone());
524 SetAttemptState(auth_.get(), state_.release()); 524 SetAttemptState(auth_.get(), state_.release());
525 525
526 auth_->RecoverEncryptedData(std::string()); 526 auth_->RecoverEncryptedData(std::string());
527 base::MessageLoop::current()->Run(); 527 base::MessageLoop::current()->Run();
528 } 528 }
529 529
530 TEST_F(ParallelAuthenticatorTest, DriveDataRecoverButFail) { 530 TEST_F(ParallelAuthenticatorTest, DriveDataRecoverButFail) {
531 FailOnLoginSuccess(); 531 FailOnLoginSuccess();
532 ExpectPasswordChange(); 532 ExpectPasswordChange();
533 533
534 // Set up mock cryptohome library to fail a key migration attempt, 534 // Set up mock cryptohome library to fail a key migration attempt,
535 // asserting that the wrong password was used. 535 // asserting that the wrong password was used.
536 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_KEY_FAILURE); 536 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_KEY_FAILURE);
537 EXPECT_CALL(*mock_caller_, AsyncMigrateKey(username_, _, hash_ascii_, _)) 537 EXPECT_CALL(*mock_caller_, AsyncMigrateKey(username_, _, hash_ascii_, _))
538 .Times(1) 538 .Times(1)
539 .RetiresOnSaturation(); 539 .RetiresOnSaturation();
540 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) 540 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt())
541 .WillOnce(Return(std::string())) 541 .WillOnce(Return(std::string("mock_system_salt")))
542 .RetiresOnSaturation(); 542 .RetiresOnSaturation();
543 543
544 SetAttemptState(auth_.get(), state_.release()); 544 SetAttemptState(auth_.get(), state_.release());
545 545
546 auth_->RecoverEncryptedData(std::string()); 546 auth_->RecoverEncryptedData(std::string());
547 base::MessageLoop::current()->Run(); 547 base::MessageLoop::current()->Run();
548 } 548 }
549 549
550 TEST_F(ParallelAuthenticatorTest, ResolveNoMount) { 550 TEST_F(ParallelAuthenticatorTest, ResolveNoMount) {
551 // Set a fake online attempt so that we return intermediate cryptohome state. 551 // Set a fake online attempt so that we return intermediate cryptohome state.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 ExpectLoginSuccess(username_, std::string(), std::string(), false); 642 ExpectLoginSuccess(username_, std::string(), std::string(), false);
643 FailOnLoginFailure(); 643 FailOnLoginFailure();
644 644
645 // Set up mock cryptohome library to respond successfully to a cryptohome 645 // Set up mock cryptohome library to respond successfully to a cryptohome
646 // key-check attempt. 646 // key-check attempt.
647 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); 647 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE);
648 EXPECT_CALL(*mock_caller_, AsyncCheckKey(username_, _, _)) 648 EXPECT_CALL(*mock_caller_, AsyncCheckKey(username_, _, _))
649 .Times(1) 649 .Times(1)
650 .RetiresOnSaturation(); 650 .RetiresOnSaturation();
651 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) 651 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt())
652 .WillOnce(Return(std::string())) 652 .WillOnce(Return(std::string("mock_system_salt")))
653 .RetiresOnSaturation(); 653 .RetiresOnSaturation();
654 654
655 auth_->AuthenticateToUnlock(UserContext(username_, 655 auth_->AuthenticateToUnlock(UserContext(username_,
656 std::string(), 656 std::string(),
657 std::string())); 657 std::string()));
658 base::MessageLoop::current()->Run(); 658 base::MessageLoop::current()->Run();
659 } 659 }
660 660
661 } // namespace chromeos 661 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698