| 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 #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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "chrome/browser/chromeos/cros/cros_library.h" | 15 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 16 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" | 16 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" |
| 17 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" | 17 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" |
| 18 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 18 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
| 19 #include "chrome/browser/chromeos/login/test_attempt_state.h" | 19 #include "chrome/browser/chromeos/login/test_attempt_state.h" |
| 20 #include "chrome/browser/chromeos/login/user.h" | 20 #include "chrome/browser/chromeos/login/user.h" |
| 21 #include "chrome/browser/chromeos/login/user_manager.h" | 21 #include "chrome/browser/chromeos/login/user_manager.h" |
| 22 #include "chrome/browser/chromeos/settings/cros_settings.h" | 22 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 23 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 23 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
| 24 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 24 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
| 25 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
| 26 #include "chromeos/cryptohome/mock_async_method_caller.h" | 26 #include "chromeos/cryptohome/mock_async_method_caller.h" |
| 27 #include "chromeos/cryptohome/mock_cryptohome_library.h" | 27 #include "chromeos/cryptohome/mock_cryptohome_library.h" |
| 28 #include "chromeos/dbus/fake_cryptohome_client.h" | 28 #include "chromeos/dbus/fake_cryptohome_client.h" |
| 29 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" | 29 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" |
| 30 #include "content/public/test/test_browser_thread.h" | 30 #include "content/public/test/test_browser_thread_bundle.h" |
| 31 #include "google_apis/gaia/mock_url_fetcher_factory.h" | 31 #include "google_apis/gaia/mock_url_fetcher_factory.h" |
| 32 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
| 33 #include "net/url_request/url_request_status.h" | 33 #include "net/url_request/url_request_status.h" |
| 34 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
| 35 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 36 #include "third_party/cros_system_api/dbus/service_constants.h" | 36 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 37 #include "url/gurl.h" | 37 #include "url/gurl.h" |
| 38 | 38 |
| 39 using ::testing::AnyNumber; | |
| 40 using ::testing::DoAll; | |
| 41 using ::testing::Invoke; | 39 using ::testing::Invoke; |
| 42 using ::testing::Return; | 40 using ::testing::Return; |
| 43 using ::testing::SetArgPointee; | |
| 44 using ::testing::_; | 41 using ::testing::_; |
| 45 using content::BrowserThread; | |
| 46 | 42 |
| 47 namespace chromeos { | 43 namespace chromeos { |
| 48 | 44 |
| 49 class TestOnlineAttempt : public OnlineAttempt { | 45 class TestOnlineAttempt : public OnlineAttempt { |
| 50 public: | 46 public: |
| 51 TestOnlineAttempt(AuthAttemptState* state, | 47 TestOnlineAttempt(AuthAttemptState* state, |
| 52 AuthAttemptStateResolver* resolver) | 48 AuthAttemptStateResolver* resolver) |
| 53 : OnlineAttempt(state, resolver) { | 49 : OnlineAttempt(state, resolver) { |
| 54 } | 50 } |
| 55 }; | 51 }; |
| 56 | 52 |
| 57 class ParallelAuthenticatorTest : public testing::Test { | 53 class ParallelAuthenticatorTest : public testing::Test { |
| 58 public: | 54 public: |
| 59 ParallelAuthenticatorTest() | 55 ParallelAuthenticatorTest() |
| 60 : message_loop_(base::MessageLoop::TYPE_UI), | 56 : username_("me@nowhere.org"), |
| 61 ui_thread_(BrowserThread::UI, &message_loop_), | |
| 62 file_thread_(BrowserThread::FILE, &message_loop_), | |
| 63 io_thread_(BrowserThread::IO), | |
| 64 username_("me@nowhere.org"), | |
| 65 password_("fakepass"), | 57 password_("fakepass"), |
| 58 hash_ascii_("0a010000000000a0" + std::string(16, '0')), |
| 66 user_manager_enabler_(new MockUserManager) { | 59 user_manager_enabler_(new MockUserManager) { |
| 67 hash_ascii_.assign("0a010000000000a0"); | |
| 68 hash_ascii_.append(std::string(16, '0')); | |
| 69 } | 60 } |
| 70 | 61 |
| 71 virtual ~ParallelAuthenticatorTest() { | 62 virtual ~ParallelAuthenticatorTest() { |
| 72 DCHECK(!mock_caller_); | 63 DCHECK(!mock_caller_); |
| 73 } | 64 } |
| 74 | 65 |
| 75 virtual void SetUp() { | 66 virtual void SetUp() { |
| 76 mock_caller_ = new cryptohome::MockAsyncMethodCaller; | 67 mock_caller_ = new cryptohome::MockAsyncMethodCaller; |
| 77 cryptohome::AsyncMethodCaller::InitializeForTesting(mock_caller_); | 68 cryptohome::AsyncMethodCaller::InitializeForTesting(mock_caller_); |
| 78 | 69 |
| 79 mock_cryptohome_library_ .reset(new MockCryptohomeLibrary()); | 70 mock_cryptohome_library_ .reset(new MockCryptohomeLibrary()); |
| 80 CryptohomeLibrary::SetForTest(mock_cryptohome_library_.get()); | 71 CryptohomeLibrary::SetForTest(mock_cryptohome_library_.get()); |
| 81 | 72 |
| 82 io_thread_.Start(); | |
| 83 | |
| 84 auth_ = new ParallelAuthenticator(&consumer_); | 73 auth_ = new ParallelAuthenticator(&consumer_); |
| 85 auth_->set_using_oauth(false); | 74 auth_->set_using_oauth(false); |
| 86 state_.reset(new TestAttemptState(UserContext(username_, | 75 state_.reset(new TestAttemptState(UserContext(username_, |
| 87 password_, | 76 password_, |
| 88 std::string()), | 77 std::string()), |
| 89 hash_ascii_, | 78 hash_ascii_, |
| 90 "", | 79 "", |
| 91 "", | 80 "", |
| 92 User::USER_TYPE_REGULAR, | 81 User::USER_TYPE_REGULAR, |
| 93 false)); | 82 false)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } | 160 } |
| 172 | 161 |
| 173 void ExpectPasswordChange() { | 162 void ExpectPasswordChange() { |
| 174 EXPECT_CALL(consumer_, OnPasswordChangeDetected()) | 163 EXPECT_CALL(consumer_, OnPasswordChangeDetected()) |
| 175 .WillOnce(Invoke(MockConsumer::OnMigrateQuit)) | 164 .WillOnce(Invoke(MockConsumer::OnMigrateQuit)) |
| 176 .RetiresOnSaturation(); | 165 .RetiresOnSaturation(); |
| 177 } | 166 } |
| 178 | 167 |
| 179 void RunResolve(ParallelAuthenticator* auth) { | 168 void RunResolve(ParallelAuthenticator* auth) { |
| 180 auth->Resolve(); | 169 auth->Resolve(); |
| 181 message_loop_.RunUntilIdle(); | 170 base::MessageLoop::current()->RunUntilIdle(); |
| 182 } | 171 } |
| 183 | 172 |
| 184 void SetAttemptState(ParallelAuthenticator* auth, TestAttemptState* state) { | 173 void SetAttemptState(ParallelAuthenticator* auth, TestAttemptState* state) { |
| 185 auth->set_attempt_state(state); | 174 auth->set_attempt_state(state); |
| 186 } | 175 } |
| 187 | 176 |
| 188 ParallelAuthenticator::AuthState SetAndResolveState( | 177 ParallelAuthenticator::AuthState SetAndResolveState( |
| 189 ParallelAuthenticator* auth, TestAttemptState* state) { | 178 ParallelAuthenticator* auth, TestAttemptState* state) { |
| 190 auth->set_attempt_state(state); | 179 auth->set_attempt_state(state); |
| 191 return auth->ResolveState(); | 180 return auth->ResolveState(); |
| 192 } | 181 } |
| 193 | 182 |
| 194 void SetOwnerState(bool owner_check_finished, bool check_result) { | 183 void SetOwnerState(bool owner_check_finished, bool check_result) { |
| 195 auth_->SetOwnerState(owner_check_finished, check_result); | 184 auth_->SetOwnerState(owner_check_finished, check_result); |
| 196 } | 185 } |
| 197 | 186 |
| 198 void FakeOnlineAttempt() { | 187 void FakeOnlineAttempt() { |
| 199 auth_->set_online_attempt(new TestOnlineAttempt(state_.get(), auth_.get())); | 188 auth_->set_online_attempt(new TestOnlineAttempt(state_.get(), auth_.get())); |
| 200 } | 189 } |
| 201 | 190 |
| 202 base::MessageLoop message_loop_; | 191 content::TestBrowserThreadBundle thread_bundle_; |
| 203 content::TestBrowserThread ui_thread_; | |
| 204 content::TestBrowserThread file_thread_; | |
| 205 content::TestBrowserThread io_thread_; | |
| 206 | 192 |
| 207 std::string username_; | 193 std::string username_; |
| 208 std::string password_; | 194 std::string password_; |
| 209 std::string username_hash_; | 195 std::string username_hash_; |
| 210 std::string hash_ascii_; | 196 std::string hash_ascii_; |
| 211 | 197 |
| 212 ScopedStubCrosEnabler stub_cros_enabler_; | 198 ScopedStubCrosEnabler stub_cros_enabler_; |
| 213 ScopedDeviceSettingsTestHelper device_settings_test_helper_; | 199 ScopedDeviceSettingsTestHelper device_settings_test_helper_; |
| 214 ScopedTestCrosSettings test_cros_settings_; | 200 ScopedTestCrosSettings test_cros_settings_; |
| 215 | 201 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 FailOnLoginFailure(); | 371 FailOnLoginFailure(); |
| 386 | 372 |
| 387 // Set up mock cryptohome library to respond as though a tmpfs mount | 373 // Set up mock cryptohome library to respond as though a tmpfs mount |
| 388 // attempt has occurred and succeeded. | 374 // attempt has occurred and succeeded. |
| 389 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); | 375 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
| 390 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)) | 376 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)) |
| 391 .Times(1) | 377 .Times(1) |
| 392 .RetiresOnSaturation(); | 378 .RetiresOnSaturation(); |
| 393 | 379 |
| 394 auth_->LoginOffTheRecord(); | 380 auth_->LoginOffTheRecord(); |
| 395 message_loop_.Run(); | 381 base::MessageLoop::current()->Run(); |
| 396 } | 382 } |
| 397 | 383 |
| 398 TEST_F(ParallelAuthenticatorTest, DriveGuestLoginButFail) { | 384 TEST_F(ParallelAuthenticatorTest, DriveGuestLoginButFail) { |
| 399 FailOnGuestLoginSuccess(); | 385 FailOnGuestLoginSuccess(); |
| 400 ExpectLoginFailure(LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); | 386 ExpectLoginFailure(LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); |
| 401 | 387 |
| 402 // Set up mock cryptohome library to respond as though a tmpfs mount | 388 // Set up mock cryptohome library to respond as though a tmpfs mount |
| 403 // attempt has occurred and failed. | 389 // attempt has occurred and failed. |
| 404 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_NONE); | 390 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_NONE); |
| 405 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)) | 391 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)) |
| 406 .Times(1) | 392 .Times(1) |
| 407 .RetiresOnSaturation(); | 393 .RetiresOnSaturation(); |
| 408 | 394 |
| 409 auth_->LoginOffTheRecord(); | 395 auth_->LoginOffTheRecord(); |
| 410 message_loop_.Run(); | 396 base::MessageLoop::current()->Run(); |
| 411 } | 397 } |
| 412 | 398 |
| 413 TEST_F(ParallelAuthenticatorTest, DriveRetailModeUserLogin) { | 399 TEST_F(ParallelAuthenticatorTest, DriveRetailModeUserLogin) { |
| 414 ExpectRetailModeLoginSuccess(); | 400 ExpectRetailModeLoginSuccess(); |
| 415 FailOnLoginFailure(); | 401 FailOnLoginFailure(); |
| 416 | 402 |
| 417 // Set up mock cryptohome library to respond as though a tmpfs mount | 403 // Set up mock cryptohome library to respond as though a tmpfs mount |
| 418 // attempt has occurred and succeeded. | 404 // attempt has occurred and succeeded. |
| 419 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); | 405 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
| 420 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)) | 406 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)) |
| 421 .Times(1) | 407 .Times(1) |
| 422 .RetiresOnSaturation(); | 408 .RetiresOnSaturation(); |
| 423 | 409 |
| 424 auth_->LoginRetailMode(); | 410 auth_->LoginRetailMode(); |
| 425 message_loop_.Run(); | 411 base::MessageLoop::current()->Run(); |
| 426 } | 412 } |
| 427 | 413 |
| 428 TEST_F(ParallelAuthenticatorTest, DriveRetailModeLoginButFail) { | 414 TEST_F(ParallelAuthenticatorTest, DriveRetailModeLoginButFail) { |
| 429 FailOnRetailModeLoginSuccess(); | 415 FailOnRetailModeLoginSuccess(); |
| 430 ExpectLoginFailure(LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); | 416 ExpectLoginFailure(LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); |
| 431 | 417 |
| 432 // Set up mock cryptohome library to respond as though a tmpfs mount | 418 // Set up mock cryptohome library to respond as though a tmpfs mount |
| 433 // attempt has occurred and failed. | 419 // attempt has occurred and failed. |
| 434 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_NONE); | 420 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_NONE); |
| 435 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)) | 421 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)) |
| 436 .Times(1) | 422 .Times(1) |
| 437 .RetiresOnSaturation(); | 423 .RetiresOnSaturation(); |
| 438 | 424 |
| 439 auth_->LoginRetailMode(); | 425 auth_->LoginRetailMode(); |
| 440 message_loop_.Run(); | 426 base::MessageLoop::current()->Run(); |
| 441 } | 427 } |
| 442 | 428 |
| 443 TEST_F(ParallelAuthenticatorTest, DriveDataResync) { | 429 TEST_F(ParallelAuthenticatorTest, DriveDataResync) { |
| 444 ExpectLoginSuccess(username_, | 430 ExpectLoginSuccess(username_, |
| 445 password_, | 431 password_, |
| 446 cryptohome::MockAsyncMethodCaller::kFakeSanitizedUsername, | 432 cryptohome::MockAsyncMethodCaller::kFakeSanitizedUsername, |
| 447 false); | 433 false); |
| 448 FailOnLoginFailure(); | 434 FailOnLoginFailure(); |
| 449 | 435 |
| 450 // Set up mock cryptohome library to respond successfully to a cryptohome | 436 // Set up mock cryptohome library to respond successfully to a cryptohome |
| 451 // remove attempt and a cryptohome create attempt (indicated by the | 437 // remove attempt and a cryptohome create attempt (indicated by the |
| 452 // |CREATE_IF_MISSING| flag to AsyncMount). | 438 // |CREATE_IF_MISSING| flag to AsyncMount). |
| 453 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); | 439 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
| 454 EXPECT_CALL(*mock_caller_, AsyncRemove(username_, _)) | 440 EXPECT_CALL(*mock_caller_, AsyncRemove(username_, _)) |
| 455 .Times(1) | 441 .Times(1) |
| 456 .RetiresOnSaturation(); | 442 .RetiresOnSaturation(); |
| 457 EXPECT_CALL(*mock_caller_, AsyncMount(username_, hash_ascii_, | 443 EXPECT_CALL(*mock_caller_, AsyncMount(username_, hash_ascii_, |
| 458 cryptohome::CREATE_IF_MISSING, _)) | 444 cryptohome::CREATE_IF_MISSING, _)) |
| 459 .Times(1) | 445 .Times(1) |
| 460 .RetiresOnSaturation(); | 446 .RetiresOnSaturation(); |
| 461 EXPECT_CALL(*mock_caller_, AsyncGetSanitizedUsername(username_, _)) | 447 EXPECT_CALL(*mock_caller_, AsyncGetSanitizedUsername(username_, _)) |
| 462 .Times(1) | 448 .Times(1) |
| 463 .RetiresOnSaturation(); | 449 .RetiresOnSaturation(); |
| 464 | 450 |
| 465 state_->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone()); | 451 state_->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone()); |
| 466 SetAttemptState(auth_.get(), state_.release()); | 452 SetAttemptState(auth_.get(), state_.release()); |
| 467 | 453 |
| 468 auth_->ResyncEncryptedData(); | 454 auth_->ResyncEncryptedData(); |
| 469 message_loop_.Run(); | 455 base::MessageLoop::current()->Run(); |
| 470 } | 456 } |
| 471 | 457 |
| 472 TEST_F(ParallelAuthenticatorTest, DriveResyncFail) { | 458 TEST_F(ParallelAuthenticatorTest, DriveResyncFail) { |
| 473 FailOnLoginSuccess(); | 459 FailOnLoginSuccess(); |
| 474 ExpectLoginFailure(LoginFailure(LoginFailure::DATA_REMOVAL_FAILED)); | 460 ExpectLoginFailure(LoginFailure(LoginFailure::DATA_REMOVAL_FAILED)); |
| 475 | 461 |
| 476 // Set up mock cryptohome library to fail a cryptohome remove attempt. | 462 // Set up mock cryptohome library to fail a cryptohome remove attempt. |
| 477 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_NONE); | 463 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_NONE); |
| 478 EXPECT_CALL(*mock_caller_, AsyncRemove(username_, _)) | 464 EXPECT_CALL(*mock_caller_, AsyncRemove(username_, _)) |
| 479 .Times(1) | 465 .Times(1) |
| 480 .RetiresOnSaturation(); | 466 .RetiresOnSaturation(); |
| 481 | 467 |
| 482 SetAttemptState(auth_.get(), state_.release()); | 468 SetAttemptState(auth_.get(), state_.release()); |
| 483 | 469 |
| 484 auth_->ResyncEncryptedData(); | 470 auth_->ResyncEncryptedData(); |
| 485 message_loop_.Run(); | 471 base::MessageLoop::current()->Run(); |
| 486 } | 472 } |
| 487 | 473 |
| 488 TEST_F(ParallelAuthenticatorTest, DriveRequestOldPassword) { | 474 TEST_F(ParallelAuthenticatorTest, DriveRequestOldPassword) { |
| 489 FailOnLoginSuccess(); | 475 FailOnLoginSuccess(); |
| 490 ExpectPasswordChange(); | 476 ExpectPasswordChange(); |
| 491 | 477 |
| 492 state_->PresetCryptohomeStatus(false, cryptohome::MOUNT_ERROR_KEY_FAILURE); | 478 state_->PresetCryptohomeStatus(false, cryptohome::MOUNT_ERROR_KEY_FAILURE); |
| 493 state_->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone()); | 479 state_->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone()); |
| 494 SetAttemptState(auth_.get(), state_.release()); | 480 SetAttemptState(auth_.get(), state_.release()); |
| 495 | 481 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 516 .Times(1) | 502 .Times(1) |
| 517 .RetiresOnSaturation(); | 503 .RetiresOnSaturation(); |
| 518 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) | 504 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) |
| 519 .WillOnce(Return(std::string())) | 505 .WillOnce(Return(std::string())) |
| 520 .RetiresOnSaturation(); | 506 .RetiresOnSaturation(); |
| 521 | 507 |
| 522 state_->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone()); | 508 state_->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone()); |
| 523 SetAttemptState(auth_.get(), state_.release()); | 509 SetAttemptState(auth_.get(), state_.release()); |
| 524 | 510 |
| 525 auth_->RecoverEncryptedData(std::string()); | 511 auth_->RecoverEncryptedData(std::string()); |
| 526 message_loop_.Run(); | 512 base::MessageLoop::current()->Run(); |
| 527 } | 513 } |
| 528 | 514 |
| 529 TEST_F(ParallelAuthenticatorTest, DriveDataRecoverButFail) { | 515 TEST_F(ParallelAuthenticatorTest, DriveDataRecoverButFail) { |
| 530 FailOnLoginSuccess(); | 516 FailOnLoginSuccess(); |
| 531 ExpectPasswordChange(); | 517 ExpectPasswordChange(); |
| 532 | 518 |
| 533 // Set up mock cryptohome library to fail a key migration attempt, | 519 // Set up mock cryptohome library to fail a key migration attempt, |
| 534 // asserting that the wrong password was used. | 520 // asserting that the wrong password was used. |
| 535 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_KEY_FAILURE); | 521 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_KEY_FAILURE); |
| 536 EXPECT_CALL(*mock_caller_, AsyncMigrateKey(username_, _, hash_ascii_, _)) | 522 EXPECT_CALL(*mock_caller_, AsyncMigrateKey(username_, _, hash_ascii_, _)) |
| 537 .Times(1) | 523 .Times(1) |
| 538 .RetiresOnSaturation(); | 524 .RetiresOnSaturation(); |
| 539 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) | 525 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) |
| 540 .WillOnce(Return(std::string())) | 526 .WillOnce(Return(std::string())) |
| 541 .RetiresOnSaturation(); | 527 .RetiresOnSaturation(); |
| 542 | 528 |
| 543 SetAttemptState(auth_.get(), state_.release()); | 529 SetAttemptState(auth_.get(), state_.release()); |
| 544 | 530 |
| 545 auth_->RecoverEncryptedData(std::string()); | 531 auth_->RecoverEncryptedData(std::string()); |
| 546 message_loop_.Run(); | 532 base::MessageLoop::current()->Run(); |
| 547 } | 533 } |
| 548 | 534 |
| 549 TEST_F(ParallelAuthenticatorTest, ResolveNoMount) { | 535 TEST_F(ParallelAuthenticatorTest, ResolveNoMount) { |
| 550 // Set a fake online attempt so that we return intermediate cryptohome state. | 536 // Set a fake online attempt so that we return intermediate cryptohome state. |
| 551 FakeOnlineAttempt(); | 537 FakeOnlineAttempt(); |
| 552 | 538 |
| 553 // Set up state as though a cryptohome mount attempt has occurred | 539 // Set up state as though a cryptohome mount attempt has occurred |
| 554 // and been rejected because the user doesn't exist. | 540 // and been rejected because the user doesn't exist. |
| 555 state_->PresetCryptohomeStatus(false, | 541 state_->PresetCryptohomeStatus(false, |
| 556 cryptohome::MOUNT_ERROR_USER_DOES_NOT_EXIST); | 542 cryptohome::MOUNT_ERROR_USER_DOES_NOT_EXIST); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 | 671 |
| 686 MockURLFetcherFactory<SuccessFetcher> factory; | 672 MockURLFetcherFactory<SuccessFetcher> factory; |
| 687 TestingProfile profile; | 673 TestingProfile profile; |
| 688 | 674 |
| 689 auth_->RetryAuth(&profile, | 675 auth_->RetryAuth(&profile, |
| 690 UserContext(username_, | 676 UserContext(username_, |
| 691 std::string(), | 677 std::string(), |
| 692 std::string()), | 678 std::string()), |
| 693 std::string(), | 679 std::string(), |
| 694 std::string()); | 680 std::string()); |
| 695 message_loop_.Run(); | 681 base::MessageLoop::current()->Run(); |
| 696 message_loop_.RunUntilIdle(); | 682 base::MessageLoop::current()->RunUntilIdle(); |
| 697 } | 683 } |
| 698 | 684 |
| 699 TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginGetCaptchad) { | 685 TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginGetCaptchad) { |
| 700 ExpectLoginSuccess(username_, password_, username_hash_, true); | 686 ExpectLoginSuccess(username_, password_, username_hash_, true); |
| 701 FailOnLoginFailure(); | 687 FailOnLoginFailure(); |
| 702 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) | 688 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) |
| 703 .WillOnce(Return(std::string())) | 689 .WillOnce(Return(std::string())) |
| 704 .RetiresOnSaturation(); | 690 .RetiresOnSaturation(); |
| 705 | 691 |
| 706 // Set up state as though a cryptohome mount attempt has occurred and | 692 // Set up state as though a cryptohome mount attempt has occurred and |
| (...skipping 22 matching lines...) Expand all Loading... |
| 729 | 715 |
| 730 MockURLFetcherFactory<CaptchaFetcher> factory; | 716 MockURLFetcherFactory<CaptchaFetcher> factory; |
| 731 TestingProfile profile; | 717 TestingProfile profile; |
| 732 | 718 |
| 733 auth_->RetryAuth(&profile, | 719 auth_->RetryAuth(&profile, |
| 734 UserContext(username_, | 720 UserContext(username_, |
| 735 std::string(), | 721 std::string(), |
| 736 std::string()), | 722 std::string()), |
| 737 std::string(), | 723 std::string(), |
| 738 std::string()); | 724 std::string()); |
| 739 message_loop_.Run(); | 725 base::MessageLoop::current()->Run(); |
| 740 message_loop_.RunUntilIdle(); | 726 base::MessageLoop::current()->RunUntilIdle(); |
| 741 } | 727 } |
| 742 | 728 |
| 743 TEST_F(ParallelAuthenticatorTest, DriveOnlineLogin) { | 729 TEST_F(ParallelAuthenticatorTest, DriveOnlineLogin) { |
| 744 ExpectLoginSuccess(username_, password_, username_hash_, false); | 730 ExpectLoginSuccess(username_, password_, username_hash_, false); |
| 745 FailOnLoginFailure(); | 731 FailOnLoginFailure(); |
| 746 | 732 |
| 747 // Set up state as though a cryptohome mount attempt has occurred and | 733 // Set up state as though a cryptohome mount attempt has occurred and |
| 748 // succeeded. | 734 // succeeded. |
| 749 state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE); | 735 state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE); |
| 750 state_->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone()); | 736 state_->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 EXPECT_CALL(*mock_caller_, AsyncCheckKey(username_, _, _)) | 768 EXPECT_CALL(*mock_caller_, AsyncCheckKey(username_, _, _)) |
| 783 .Times(1) | 769 .Times(1) |
| 784 .RetiresOnSaturation(); | 770 .RetiresOnSaturation(); |
| 785 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) | 771 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) |
| 786 .WillOnce(Return(std::string())) | 772 .WillOnce(Return(std::string())) |
| 787 .RetiresOnSaturation(); | 773 .RetiresOnSaturation(); |
| 788 | 774 |
| 789 auth_->AuthenticateToUnlock(UserContext(username_, | 775 auth_->AuthenticateToUnlock(UserContext(username_, |
| 790 std::string(), | 776 std::string(), |
| 791 std::string())); | 777 std::string())); |
| 792 message_loop_.Run(); | 778 base::MessageLoop::current()->Run(); |
| 793 } | 779 } |
| 794 | 780 |
| 795 } // namespace chromeos | 781 } // namespace chromeos |
| OLD | NEW |