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

Side by Side Diff: chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc

Issue 608283003: Remove retail mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/auth/chrome_cryptohome_authenticator.h" 5 #include "chrome/browser/chromeos/login/auth/chrome_cryptohome_authenticator.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return out; 198 return out;
199 } 199 }
200 200
201 // Allow test to fail and exit gracefully, even if OnAuthFailure() 201 // Allow test to fail and exit gracefully, even if OnAuthFailure()
202 // wasn't supposed to happen. 202 // wasn't supposed to happen.
203 void FailOnLoginFailure() { 203 void FailOnLoginFailure() {
204 ON_CALL(consumer_, OnAuthFailure(_)) 204 ON_CALL(consumer_, OnAuthFailure(_))
205 .WillByDefault(Invoke(MockAuthStatusConsumer::OnFailQuitAndFail)); 205 .WillByDefault(Invoke(MockAuthStatusConsumer::OnFailQuitAndFail));
206 } 206 }
207 207
208 // Allow test to fail and exit gracefully, even if
209 // OnRetailModeAuthSuccess() wasn't supposed to happen.
210 void FailOnRetailModeLoginSuccess() {
211 ON_CALL(consumer_, OnRetailModeAuthSuccess(_)).WillByDefault(
212 Invoke(MockAuthStatusConsumer::OnRetailModeSuccessQuitAndFail));
213 }
214
215 // Allow test to fail and exit gracefully, even if OnAuthSuccess() 208 // Allow test to fail and exit gracefully, even if OnAuthSuccess()
216 // wasn't supposed to happen. 209 // wasn't supposed to happen.
217 void FailOnLoginSuccess() { 210 void FailOnLoginSuccess() {
218 ON_CALL(consumer_, OnAuthSuccess(_)) 211 ON_CALL(consumer_, OnAuthSuccess(_))
219 .WillByDefault(Invoke(MockAuthStatusConsumer::OnSuccessQuitAndFail)); 212 .WillByDefault(Invoke(MockAuthStatusConsumer::OnSuccessQuitAndFail));
220 } 213 }
221 214
222 // Allow test to fail and exit gracefully, even if 215 // Allow test to fail and exit gracefully, even if
223 // OnOffTheRecordAuthSuccess() wasn't supposed to happen. 216 // OnOffTheRecordAuthSuccess() wasn't supposed to happen.
224 void FailOnGuestLoginSuccess() { 217 void FailOnGuestLoginSuccess() {
225 ON_CALL(consumer_, OnOffTheRecordAuthSuccess()).WillByDefault( 218 ON_CALL(consumer_, OnOffTheRecordAuthSuccess()).WillByDefault(
226 Invoke(MockAuthStatusConsumer::OnGuestSuccessQuitAndFail)); 219 Invoke(MockAuthStatusConsumer::OnGuestSuccessQuitAndFail));
227 } 220 }
228 221
229 void ExpectLoginFailure(const AuthFailure& failure) { 222 void ExpectLoginFailure(const AuthFailure& failure) {
230 EXPECT_CALL(consumer_, OnAuthFailure(failure)) 223 EXPECT_CALL(consumer_, OnAuthFailure(failure))
231 .WillOnce(Invoke(MockAuthStatusConsumer::OnFailQuit)) 224 .WillOnce(Invoke(MockAuthStatusConsumer::OnFailQuit))
232 .RetiresOnSaturation(); 225 .RetiresOnSaturation();
233 } 226 }
234 227
235 void ExpectRetailModeLoginSuccess() {
236 EXPECT_CALL(consumer_, OnRetailModeAuthSuccess(_))
237 .WillOnce(Invoke(MockAuthStatusConsumer::OnRetailModeSuccessQuit))
238 .RetiresOnSaturation();
239 }
240
241 void ExpectLoginSuccess(const UserContext& user_context) { 228 void ExpectLoginSuccess(const UserContext& user_context) {
242 EXPECT_CALL(consumer_, OnAuthSuccess(user_context)) 229 EXPECT_CALL(consumer_, OnAuthSuccess(user_context))
243 .WillOnce(Invoke(MockAuthStatusConsumer::OnSuccessQuit)) 230 .WillOnce(Invoke(MockAuthStatusConsumer::OnSuccessQuit))
244 .RetiresOnSaturation(); 231 .RetiresOnSaturation();
245 } 232 }
246 233
247 void ExpectGuestLoginSuccess() { 234 void ExpectGuestLoginSuccess() {
248 EXPECT_CALL(consumer_, OnOffTheRecordAuthSuccess()) 235 EXPECT_CALL(consumer_, OnOffTheRecordAuthSuccess())
249 .WillOnce(Invoke(MockAuthStatusConsumer::OnGuestSuccessQuit)) 236 .WillOnce(Invoke(MockAuthStatusConsumer::OnGuestSuccessQuit))
250 .RetiresOnSaturation(); 237 .RetiresOnSaturation();
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 561
575 // Set up mock async method caller to respond as though a tmpfs mount 562 // Set up mock async method caller to respond as though a tmpfs mount
576 // attempt has occurred and failed. 563 // attempt has occurred and failed.
577 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_NONE); 564 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_NONE);
578 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)).Times(1).RetiresOnSaturation(); 565 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)).Times(1).RetiresOnSaturation();
579 566
580 auth_->LoginOffTheRecord(); 567 auth_->LoginOffTheRecord();
581 base::MessageLoop::current()->Run(); 568 base::MessageLoop::current()->Run();
582 } 569 }
583 570
584 TEST_F(CryptohomeAuthenticatorTest, DriveRetailModeUserLogin) {
585 ExpectRetailModeLoginSuccess();
586 FailOnLoginFailure();
587
588 // Set up mock async method caller to respond as though a tmpfs mount
589 // attempt has occurred and succeeded.
590 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE);
591 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)).Times(1).RetiresOnSaturation();
592
593 auth_->LoginRetailMode();
594 base::MessageLoop::current()->Run();
595 }
596
597 TEST_F(CryptohomeAuthenticatorTest, DriveRetailModeLoginButFail) {
598 FailOnRetailModeLoginSuccess();
599 ExpectLoginFailure(AuthFailure(AuthFailure::COULD_NOT_MOUNT_TMPFS));
600
601 // Set up mock async method caller to respond as though a tmpfs mount
602 // attempt has occurred and failed.
603 mock_caller_->SetUp(false, cryptohome::MOUNT_ERROR_NONE);
604 EXPECT_CALL(*mock_caller_, AsyncMountGuest(_)).Times(1).RetiresOnSaturation();
605
606 auth_->LoginRetailMode();
607 base::MessageLoop::current()->Run();
608 }
609
610 TEST_F(CryptohomeAuthenticatorTest, DriveDataResync) { 571 TEST_F(CryptohomeAuthenticatorTest, DriveDataResync) {
611 UserContext expected_user_context(user_context_with_transformed_key_); 572 UserContext expected_user_context(user_context_with_transformed_key_);
612 expected_user_context.SetUserIDHash( 573 expected_user_context.SetUserIDHash(
613 cryptohome::MockAsyncMethodCaller::kFakeSanitizedUsername); 574 cryptohome::MockAsyncMethodCaller::kFakeSanitizedUsername);
614 ExpectLoginSuccess(expected_user_context); 575 ExpectLoginSuccess(expected_user_context);
615 FailOnLoginFailure(); 576 FailOnLoginFailure();
616 577
617 // Set up mock async method caller to respond successfully to a cryptohome 578 // Set up mock async method caller to respond successfully to a cryptohome
618 // remove attempt. 579 // remove attempt.
619 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); 580 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 // salt. 789 // salt.
829 ExpectGetKeyDataExCall( 790 ExpectGetKeyDataExCall(
830 make_scoped_ptr(new int64(Key::KEY_TYPE_SALTED_SHA256)), 791 make_scoped_ptr(new int64(Key::KEY_TYPE_SALTED_SHA256)),
831 scoped_ptr<std::string>()); 792 scoped_ptr<std::string>());
832 793
833 auth_->AuthenticateToLogin(NULL, user_context_); 794 auth_->AuthenticateToLogin(NULL, user_context_);
834 base::RunLoop().Run(); 795 base::RunLoop().Run();
835 } 796 }
836 797
837 } // namespace chromeos 798 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698