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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/login/parallel_authenticator.h"
9 #include "base/command_line.h"
10 #include "base/file_util.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h"
14 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h"
16 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h"
17 #include "chrome/browser/chromeos/login/mock_url_fetchers.h"
18 #include "chrome/browser/chromeos/login/mock_user_manager.h"
19 #include "chrome/browser/chromeos/login/test_attempt_state.h"
20 #include "chrome/browser/chromeos/login/user.h"
21 #include "chrome/browser/chromeos/login/user_manager.h"
22 #include "chrome/browser/chromeos/settings/cros_settings.h"
23 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
24 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
25 #include "chrome/test/base/testing_profile.h"
26 #include "chromeos/chromeos_switches.h"
27 #include "chromeos/cryptohome/mock_async_method_caller.h"
28 #include "chromeos/cryptohome/system_salt_getter.h"
29 #include "chromeos/dbus/fake_cryptohome_client.h"
30 #include "chromeos/dbus/fake_dbus_thread_manager.h"
31 #include "content/public/test/test_browser_thread_bundle.h"
32 #include "google_apis/gaia/mock_url_fetcher_factory.h"
33 #include "net/base/net_errors.h"
34 #include "net/url_request/url_request_status.h"
35 #include "testing/gmock/include/gmock/gmock.h"
36 #include "testing/gtest/include/gtest/gtest.h"
37 #include "third_party/cros_system_api/dbus/service_constants.h"
40 using ::testing::Invoke
;
41 using ::testing::Return
;
46 class ParallelAuthenticatorTest
: public testing::Test
{
48 ParallelAuthenticatorTest()
49 : username_("me@nowhere.org"),
50 password_("fakepass"),
51 hash_ascii_(ParallelAuthenticator::HashPassword(
53 SystemSaltGetter::ConvertRawSaltToHexString(
54 FakeCryptohomeClient::GetStubSystemSalt()))),
55 user_manager_enabler_(new MockUserManager
),
59 virtual ~ParallelAuthenticatorTest() {
60 DCHECK(!mock_caller_
);
63 virtual void SetUp() {
64 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kLoginManager
);
66 mock_caller_
= new cryptohome::MockAsyncMethodCaller
;
67 cryptohome::AsyncMethodCaller::InitializeForTesting(mock_caller_
);
69 FakeDBusThreadManager
* fake_dbus_thread_manager
= new FakeDBusThreadManager
;
70 fake_cryptohome_client_
= new FakeCryptohomeClient
;
71 fake_dbus_thread_manager
->SetCryptohomeClient(
72 scoped_ptr
<CryptohomeClient
>(fake_cryptohome_client_
));
73 DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager
);
75 SystemSaltGetter::Initialize();
77 auth_
= new ParallelAuthenticator(&consumer_
);
78 state_
.reset(new TestAttemptState(UserContext(username_
,
83 User::USER_TYPE_REGULAR
,
87 // Tears down the test fixture.
88 virtual void TearDown() {
89 SystemSaltGetter::Shutdown();
90 DBusThreadManager::Shutdown();
92 cryptohome::AsyncMethodCaller::Shutdown();
96 base::FilePath
PopulateTempFile(const char* data
, int data_len
) {
98 FILE* tmp_file
= base::CreateAndOpenTemporaryFile(&out
);
99 EXPECT_NE(tmp_file
, static_cast<FILE*>(NULL
));
100 EXPECT_EQ(file_util::WriteFile(out
, data
, data_len
), data_len
);
101 EXPECT_TRUE(base::CloseFile(tmp_file
));
105 // Allow test to fail and exit gracefully, even if OnLoginFailure()
106 // wasn't supposed to happen.
107 void FailOnLoginFailure() {
108 ON_CALL(consumer_
, OnLoginFailure(_
))
109 .WillByDefault(Invoke(MockConsumer::OnFailQuitAndFail
));
112 // Allow test to fail and exit gracefully, even if
113 // OnRetailModeLoginSuccess() wasn't supposed to happen.
114 void FailOnRetailModeLoginSuccess() {
115 ON_CALL(consumer_
, OnRetailModeLoginSuccess(_
))
116 .WillByDefault(Invoke(MockConsumer::OnRetailModeSuccessQuitAndFail
));
119 // Allow test to fail and exit gracefully, even if OnLoginSuccess()
120 // wasn't supposed to happen.
121 void FailOnLoginSuccess() {
122 ON_CALL(consumer_
, OnLoginSuccess(_
))
123 .WillByDefault(Invoke(MockConsumer::OnSuccessQuitAndFail
));
126 // Allow test to fail and exit gracefully, even if
127 // OnOffTheRecordLoginSuccess() wasn't supposed to happen.
128 void FailOnGuestLoginSuccess() {
129 ON_CALL(consumer_
, OnOffTheRecordLoginSuccess())
130 .WillByDefault(Invoke(MockConsumer::OnGuestSuccessQuitAndFail
));
133 void ExpectLoginFailure(const LoginFailure
& failure
) {
134 EXPECT_CALL(consumer_
, OnLoginFailure(failure
))
135 .WillOnce(Invoke(MockConsumer::OnFailQuit
))
136 .RetiresOnSaturation();
139 void ExpectRetailModeLoginSuccess() {
140 EXPECT_CALL(consumer_
, OnRetailModeLoginSuccess(_
))
141 .WillOnce(Invoke(MockConsumer::OnRetailModeSuccessQuit
))
142 .RetiresOnSaturation();
145 void ExpectLoginSuccess(const std::string
& username
,
146 const std::string
& password
,
147 const std::string
& username_hash_
,
149 EXPECT_CALL(consumer_
, OnLoginSuccess(UserContext(username
,
153 true /* using_oauth */)))
154 .WillOnce(Invoke(MockConsumer::OnSuccessQuit
))
155 .RetiresOnSaturation();
158 void ExpectGuestLoginSuccess() {
159 EXPECT_CALL(consumer_
, OnOffTheRecordLoginSuccess())
160 .WillOnce(Invoke(MockConsumer::OnGuestSuccessQuit
))
161 .RetiresOnSaturation();
164 void ExpectPasswordChange() {
165 EXPECT_CALL(consumer_
, OnPasswordChangeDetected())
166 .WillOnce(Invoke(MockConsumer::OnMigrateQuit
))
167 .RetiresOnSaturation();
170 void RunResolve(ParallelAuthenticator
* auth
) {
172 base::MessageLoop::current()->RunUntilIdle();
175 void SetAttemptState(ParallelAuthenticator
* auth
, TestAttemptState
* state
) {
176 auth
->set_attempt_state(state
);
179 ParallelAuthenticator::AuthState
SetAndResolveState(
180 ParallelAuthenticator
* auth
, TestAttemptState
* state
) {
181 auth
->set_attempt_state(state
);
182 return auth
->ResolveState();
185 void SetOwnerState(bool owner_check_finished
, bool check_result
) {
186 auth_
->SetOwnerState(owner_check_finished
, check_result
);
189 content::TestBrowserThreadBundle thread_bundle_
;
191 std::string username_
;
192 std::string password_
;
193 std::string username_hash_
;
194 std::string hash_ascii_
;
196 ScopedDeviceSettingsTestHelper device_settings_test_helper_
;
197 ScopedTestCrosSettings test_cros_settings_
;
199 ScopedUserManagerEnabler user_manager_enabler_
;
201 cryptohome::MockAsyncMethodCaller
* mock_caller_
;
203 MockConsumer consumer_
;
204 scoped_refptr
<ParallelAuthenticator
> auth_
;
205 scoped_ptr
<TestAttemptState
> state_
;
206 FakeCryptohomeClient
* fake_cryptohome_client_
;
209 TEST_F(ParallelAuthenticatorTest
, OnLoginSuccess
) {
210 EXPECT_CALL(consumer_
, OnLoginSuccess(UserContext(username_
,
214 true /* using oauth */)))
216 .RetiresOnSaturation();
218 SetAttemptState(auth_
.get(), state_
.release());
219 auth_
->OnLoginSuccess();
222 TEST_F(ParallelAuthenticatorTest
, OnPasswordChangeDetected
) {
223 EXPECT_CALL(consumer_
, OnPasswordChangeDetected())
225 .RetiresOnSaturation();
226 SetAttemptState(auth_
.get(), state_
.release());
227 auth_
->OnPasswordChangeDetected();
230 TEST_F(ParallelAuthenticatorTest
, ResolveNothingDone
) {
231 EXPECT_EQ(ParallelAuthenticator::CONTINUE
,
232 SetAndResolveState(auth_
.get(), state_
.release()));
236 TEST_F(ParallelAuthenticatorTest
, ResolvePossiblePwChangeToFailedMount
) {
237 // Set up state as though a cryptohome mount attempt has occurred
238 // and been rejected.
239 state_
->PresetCryptohomeStatus(false, cryptohome::MOUNT_ERROR_KEY_FAILURE
);
241 // When there is no online attempt and online results, POSSIBLE_PW_CHANGE
242 EXPECT_EQ(ParallelAuthenticator::FAILED_MOUNT
,
243 SetAndResolveState(auth_
.get(), state_
.release()));
246 TEST_F(ParallelAuthenticatorTest
, ResolveNeedOldPw
) {
247 // Set up state as though a cryptohome mount attempt has occurred
248 // and been rejected because of unmatched key; additionally,
249 // an online auth attempt has completed successfully.
250 state_
->PresetCryptohomeStatus(false, cryptohome::MOUNT_ERROR_KEY_FAILURE
);
251 state_
->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone());
253 EXPECT_EQ(ParallelAuthenticator::NEED_OLD_PW
,
254 SetAndResolveState(auth_
.get(), state_
.release()));
257 TEST_F(ParallelAuthenticatorTest
, ResolveOwnerNeededDirectFailedMount
) {
258 // Set up state as though a cryptohome mount attempt has occurred
259 // and succeeded but we are in safe mode and the current user is not owner.
260 // This is a high level test to verify the proper transitioning in this mode
261 // only. It is not testing that we properly verify that the user is an owner
262 // or that we really are in "safe-mode".
263 state_
->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE
);
264 SetOwnerState(true, false);
266 EXPECT_EQ(ParallelAuthenticator::OWNER_REQUIRED
,
267 SetAndResolveState(auth_
.get(), state_
.release()));
270 TEST_F(ParallelAuthenticatorTest
, ResolveOwnerNeededMount
) {
271 // Set up state as though a cryptohome mount attempt has occurred
272 // and succeeded but we are in safe mode and the current user is not owner.
273 // This test will check that the "safe-mode" policy is not set and will let
274 // the mount finish successfully.
275 state_
->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE
);
276 SetOwnerState(false, false);
277 // and test that the mount has succeeded.
278 state_
.reset(new TestAttemptState(UserContext(username_
,
283 User::USER_TYPE_REGULAR
,
285 state_
->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE
);
286 EXPECT_EQ(ParallelAuthenticator::OFFLINE_LOGIN
,
287 SetAndResolveState(auth_
.get(), state_
.release()));
290 TEST_F(ParallelAuthenticatorTest
, ResolveOwnerNeededFailedMount
) {
291 FailOnLoginSuccess(); // Set failing on success as the default...
292 LoginFailure failure
= LoginFailure(LoginFailure::OWNER_REQUIRED
);
293 ExpectLoginFailure(failure
);
295 fake_cryptohome_client_
->set_unmount_result(true);
297 CrosSettingsProvider
* device_settings_provider
;
298 StubCrosSettingsProvider stub_settings_provider
;
299 // Set up state as though a cryptohome mount attempt has occurred
300 // and succeeded but we are in safe mode and the current user is not owner.
301 state_
->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE
);
302 SetOwnerState(false, false);
303 // Remove the real DeviceSettingsProvider and replace it with a stub.
304 device_settings_provider
=
305 CrosSettings::Get()->GetProvider(chromeos::kReportDeviceVersionInfo
);
306 EXPECT_TRUE(device_settings_provider
!= NULL
);
308 CrosSettings::Get()->RemoveSettingsProvider(device_settings_provider
));
309 CrosSettings::Get()->AddSettingsProvider(&stub_settings_provider
);
310 CrosSettings::Get()->SetBoolean(kPolicyMissingMitigationMode
, true);
312 // Initialize login state for this test to verify the login state is changed
314 LoginState::Initialize();
316 EXPECT_EQ(ParallelAuthenticator::CONTINUE
,
317 SetAndResolveState(auth_
.get(), state_
.release()));
318 EXPECT_TRUE(LoginState::Get()->IsInSafeMode());
320 // Simulate certificates load event. The exact certificates loaded are not
321 // actually used by the DeviceSettingsService, so it is OK to pass an empty
323 DeviceSettingsService::Get()->OnCertificatesLoaded(net::CertificateList(),
325 // Flush all the pending operations. The operations should induce an owner
327 device_settings_test_helper_
.Flush();
328 // and test that the mount has succeeded.
329 state_
.reset(new TestAttemptState(UserContext(username_
,
334 User::USER_TYPE_REGULAR
,
336 state_
->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE
);
337 EXPECT_EQ(ParallelAuthenticator::OWNER_REQUIRED
,
338 SetAndResolveState(auth_
.get(), state_
.release()));
340 // Unset global objects used by this test.
341 LoginState::Shutdown();
343 CrosSettings::Get()->RemoveSettingsProvider(&stub_settings_provider
));
344 CrosSettings::Get()->AddSettingsProvider(device_settings_provider
);
347 TEST_F(ParallelAuthenticatorTest
, DriveFailedMount
) {
348 FailOnLoginSuccess();
349 ExpectLoginFailure(LoginFailure(LoginFailure::COULD_NOT_MOUNT_CRYPTOHOME
));
351 // Set up state as though a cryptohome mount attempt has occurred
353 state_
->PresetCryptohomeStatus(false, cryptohome::MOUNT_ERROR_NONE
);
354 SetAttemptState(auth_
.get(), state_
.release());
356 RunResolve(auth_
.get());
359 TEST_F(ParallelAuthenticatorTest
, DriveGuestLogin
) {
360 ExpectGuestLoginSuccess();
361 FailOnLoginFailure();
363 // Set up mock async method caller to respond as though a tmpfs mount
364 // attempt has occurred and succeeded.
365 mock_caller_
->SetUp(true, cryptohome::MOUNT_ERROR_NONE
);
366 EXPECT_CALL(*mock_caller_
, AsyncMountGuest(_
))
368 .RetiresOnSaturation();
370 auth_
->LoginOffTheRecord();
371 base::MessageLoop::current()->Run();
374 TEST_F(ParallelAuthenticatorTest
, DriveGuestLoginButFail
) {
375 FailOnGuestLoginSuccess();
376 ExpectLoginFailure(LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS
));
378 // Set up mock async method caller to respond as though a tmpfs mount
379 // attempt has occurred and failed.
380 mock_caller_
->SetUp(false, cryptohome::MOUNT_ERROR_NONE
);
381 EXPECT_CALL(*mock_caller_
, AsyncMountGuest(_
))
383 .RetiresOnSaturation();
385 auth_
->LoginOffTheRecord();
386 base::MessageLoop::current()->Run();
389 TEST_F(ParallelAuthenticatorTest
, DriveRetailModeUserLogin
) {
390 ExpectRetailModeLoginSuccess();
391 FailOnLoginFailure();
393 // Set up mock async method caller to respond as though a tmpfs mount
394 // attempt has occurred and succeeded.
395 mock_caller_
->SetUp(true, cryptohome::MOUNT_ERROR_NONE
);
396 EXPECT_CALL(*mock_caller_
, AsyncMountGuest(_
))
398 .RetiresOnSaturation();
400 auth_
->LoginRetailMode();
401 base::MessageLoop::current()->Run();
404 TEST_F(ParallelAuthenticatorTest
, DriveRetailModeLoginButFail
) {
405 FailOnRetailModeLoginSuccess();
406 ExpectLoginFailure(LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS
));
408 // Set up mock async method caller to respond as though a tmpfs mount
409 // attempt has occurred and failed.
410 mock_caller_
->SetUp(false, cryptohome::MOUNT_ERROR_NONE
);
411 EXPECT_CALL(*mock_caller_
, AsyncMountGuest(_
))
413 .RetiresOnSaturation();
415 auth_
->LoginRetailMode();
416 base::MessageLoop::current()->Run();
419 TEST_F(ParallelAuthenticatorTest
, DriveDataResync
) {
420 ExpectLoginSuccess(username_
,
422 cryptohome::MockAsyncMethodCaller::kFakeSanitizedUsername
,
424 FailOnLoginFailure();
426 // Set up mock async method caller to respond successfully to a cryptohome
427 // remove attempt and a cryptohome create attempt (indicated by the
428 // |CREATE_IF_MISSING| flag to AsyncMount).
429 mock_caller_
->SetUp(true, cryptohome::MOUNT_ERROR_NONE
);
430 EXPECT_CALL(*mock_caller_
, AsyncRemove(username_
, _
))
432 .RetiresOnSaturation();
433 EXPECT_CALL(*mock_caller_
, AsyncMount(username_
, hash_ascii_
,
434 cryptohome::CREATE_IF_MISSING
, _
))
436 .RetiresOnSaturation();
437 EXPECT_CALL(*mock_caller_
, AsyncGetSanitizedUsername(username_
, _
))
439 .RetiresOnSaturation();
441 state_
->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone());
442 SetAttemptState(auth_
.get(), state_
.release());
444 auth_
->ResyncEncryptedData();
445 base::MessageLoop::current()->Run();
448 TEST_F(ParallelAuthenticatorTest
, DriveResyncFail
) {
449 FailOnLoginSuccess();
450 ExpectLoginFailure(LoginFailure(LoginFailure::DATA_REMOVAL_FAILED
));
452 // Set up mock async method caller to fail a cryptohome remove attempt.
453 mock_caller_
->SetUp(false, cryptohome::MOUNT_ERROR_NONE
);
454 EXPECT_CALL(*mock_caller_
, AsyncRemove(username_
, _
))
456 .RetiresOnSaturation();
458 SetAttemptState(auth_
.get(), state_
.release());
460 auth_
->ResyncEncryptedData();
461 base::MessageLoop::current()->Run();
464 TEST_F(ParallelAuthenticatorTest
, DriveRequestOldPassword
) {
465 FailOnLoginSuccess();
466 ExpectPasswordChange();
468 state_
->PresetCryptohomeStatus(false, cryptohome::MOUNT_ERROR_KEY_FAILURE
);
469 state_
->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone());
470 SetAttemptState(auth_
.get(), state_
.release());
472 RunResolve(auth_
.get());
475 TEST_F(ParallelAuthenticatorTest
, DriveDataRecover
) {
476 ExpectLoginSuccess(username_
,
478 cryptohome::MockAsyncMethodCaller::kFakeSanitizedUsername
,
480 FailOnLoginFailure();
482 // Set up mock async method caller to respond successfully to a key migration.
483 mock_caller_
->SetUp(true, cryptohome::MOUNT_ERROR_NONE
);
484 EXPECT_CALL(*mock_caller_
, AsyncMigrateKey(username_
, _
, hash_ascii_
, _
))
486 .RetiresOnSaturation();
487 EXPECT_CALL(*mock_caller_
, AsyncMount(username_
, hash_ascii_
,
488 cryptohome::MOUNT_FLAGS_NONE
, _
))
490 .RetiresOnSaturation();
491 EXPECT_CALL(*mock_caller_
, AsyncGetSanitizedUsername(username_
, _
))
493 .RetiresOnSaturation();
495 state_
->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone());
496 SetAttemptState(auth_
.get(), state_
.release());
498 auth_
->RecoverEncryptedData(std::string());
499 base::MessageLoop::current()->Run();
502 TEST_F(ParallelAuthenticatorTest
, DriveDataRecoverButFail
) {
503 FailOnLoginSuccess();
504 ExpectPasswordChange();
506 // Set up mock async method caller to fail a key migration attempt,
507 // asserting that the wrong password was used.
508 mock_caller_
->SetUp(false, cryptohome::MOUNT_ERROR_KEY_FAILURE
);
509 EXPECT_CALL(*mock_caller_
, AsyncMigrateKey(username_
, _
, hash_ascii_
, _
))
511 .RetiresOnSaturation();
513 SetAttemptState(auth_
.get(), state_
.release());
515 auth_
->RecoverEncryptedData(std::string());
516 base::MessageLoop::current()->Run();
519 TEST_F(ParallelAuthenticatorTest
, ResolveNoMountToFailedMount
) {
520 // Set up state as though a cryptohome mount attempt has occurred
521 // and been rejected because the user doesn't exist.
522 state_
->PresetCryptohomeStatus(false,
523 cryptohome::MOUNT_ERROR_USER_DOES_NOT_EXIST
);
525 // When there is no online attempt and online results, NO_MOUNT will be
526 // resolved to FAILED_MOUNT.
527 EXPECT_EQ(ParallelAuthenticator::FAILED_MOUNT
,
528 SetAndResolveState(auth_
.get(), state_
.release()));
531 TEST_F(ParallelAuthenticatorTest
, ResolveCreateNew
) {
532 // Set up state as though a cryptohome mount attempt has occurred
533 // and been rejected because the user doesn't exist; additionally,
534 // an online auth attempt has completed successfully.
535 state_
->PresetCryptohomeStatus(false,
536 cryptohome::MOUNT_ERROR_USER_DOES_NOT_EXIST
);
537 state_
->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone());
539 EXPECT_EQ(ParallelAuthenticator::CREATE_NEW
,
540 SetAndResolveState(auth_
.get(), state_
.release()));
543 TEST_F(ParallelAuthenticatorTest
, DriveCreateForNewUser
) {
544 ExpectLoginSuccess(username_
,
546 cryptohome::MockAsyncMethodCaller::kFakeSanitizedUsername
,
548 FailOnLoginFailure();
550 // Set up mock async method caller to respond successfully to a cryptohome
551 // create attempt (indicated by the |CREATE_IF_MISSING| flag to AsyncMount).
552 mock_caller_
->SetUp(true, cryptohome::MOUNT_ERROR_NONE
);
553 EXPECT_CALL(*mock_caller_
, AsyncMount(username_
, hash_ascii_
,
554 cryptohome::CREATE_IF_MISSING
, _
))
556 .RetiresOnSaturation();
557 EXPECT_CALL(*mock_caller_
, AsyncGetSanitizedUsername(username_
, _
))
559 .RetiresOnSaturation();
561 // Set up state as though a cryptohome mount attempt has occurred
562 // and been rejected because the user doesn't exist; additionally,
563 // an online auth attempt has completed successfully.
564 state_
->PresetCryptohomeStatus(false,
565 cryptohome::MOUNT_ERROR_USER_DOES_NOT_EXIST
);
566 state_
->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone());
567 SetAttemptState(auth_
.get(), state_
.release());
569 RunResolve(auth_
.get());
572 TEST_F(ParallelAuthenticatorTest
, DriveOfflineLogin
) {
573 ExpectLoginSuccess(username_
, password_
, username_hash_
, false);
574 FailOnLoginFailure();
576 // Set up state as though a cryptohome mount attempt has occurred and
578 state_
->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE
);
579 SetAttemptState(auth_
.get(), state_
.release());
581 RunResolve(auth_
.get());
584 TEST_F(ParallelAuthenticatorTest
, DriveOnlineLogin
) {
585 ExpectLoginSuccess(username_
, password_
, username_hash_
, false);
586 FailOnLoginFailure();
588 // Set up state as though a cryptohome mount attempt has occurred and
590 state_
->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE
);
591 state_
->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone());
592 SetAttemptState(auth_
.get(), state_
.release());
594 RunResolve(auth_
.get());
597 TEST_F(ParallelAuthenticatorTest
, DriveUnlock
) {
598 ExpectLoginSuccess(username_
, std::string(), std::string(), false);
599 FailOnLoginFailure();
601 // Set up mock async method caller to respond successfully to a cryptohome
602 // key-check attempt.
603 mock_caller_
->SetUp(true, cryptohome::MOUNT_ERROR_NONE
);
604 EXPECT_CALL(*mock_caller_
, AsyncCheckKey(username_
, _
, _
))
606 .RetiresOnSaturation();
608 auth_
->AuthenticateToUnlock(UserContext(username_
,
611 base::MessageLoop::current()->Run();
614 } // namespace chromeos