| 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/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/stringprintf.h" | 14 #include "base/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/cros/mock_cert_library.h" | |
| 17 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" | 16 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" |
| 18 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" | 17 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" |
| 19 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 18 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
| 20 #include "chrome/browser/chromeos/login/test_attempt_state.h" | 19 #include "chrome/browser/chromeos/login/test_attempt_state.h" |
| 21 #include "chrome/browser/chromeos/login/user.h" | 20 #include "chrome/browser/chromeos/login/user.h" |
| 22 #include "chrome/browser/chromeos/login/user_manager.h" | 21 #include "chrome/browser/chromeos/login/user_manager.h" |
| 23 #include "chrome/browser/chromeos/settings/cros_settings.h" | 22 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 24 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 23 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
| 25 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 24 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
| 26 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 69 } |
| 71 | 70 |
| 72 virtual ~ParallelAuthenticatorTest() { | 71 virtual ~ParallelAuthenticatorTest() { |
| 73 DCHECK(!mock_caller_); | 72 DCHECK(!mock_caller_); |
| 74 } | 73 } |
| 75 | 74 |
| 76 virtual void SetUp() { | 75 virtual void SetUp() { |
| 77 mock_caller_ = new cryptohome::MockAsyncMethodCaller; | 76 mock_caller_ = new cryptohome::MockAsyncMethodCaller; |
| 78 cryptohome::AsyncMethodCaller::InitializeForTesting(mock_caller_); | 77 cryptohome::AsyncMethodCaller::InitializeForTesting(mock_caller_); |
| 79 | 78 |
| 80 chromeos::CrosLibrary::TestApi* test_api = | |
| 81 chromeos::CrosLibrary::Get()->GetTestApi(); | |
| 82 | |
| 83 mock_cryptohome_library_ .reset(new MockCryptohomeLibrary()); | 79 mock_cryptohome_library_ .reset(new MockCryptohomeLibrary()); |
| 84 CryptohomeLibrary::SetForTest(mock_cryptohome_library_.get()); | 80 CryptohomeLibrary::SetForTest(mock_cryptohome_library_.get()); |
| 85 | 81 |
| 86 mock_cert_library_ = new MockCertLibrary(); | |
| 87 EXPECT_CALL(*mock_cert_library_, LoadKeyStore()).Times(AnyNumber()); | |
| 88 test_api->SetCertLibrary(mock_cert_library_, true); | |
| 89 | |
| 90 io_thread_.Start(); | 82 io_thread_.Start(); |
| 91 | 83 |
| 92 auth_ = new ParallelAuthenticator(&consumer_); | 84 auth_ = new ParallelAuthenticator(&consumer_); |
| 93 auth_->set_using_oauth(false); | 85 auth_->set_using_oauth(false); |
| 94 state_.reset(new TestAttemptState(UserContext(username_, | 86 state_.reset(new TestAttemptState(UserContext(username_, |
| 95 password_, | 87 password_, |
| 96 std::string()), | 88 std::string()), |
| 97 hash_ascii_, | 89 hash_ascii_, |
| 98 "", | 90 "", |
| 99 "", | 91 "", |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 std::string username_; | 207 std::string username_; |
| 216 std::string password_; | 208 std::string password_; |
| 217 std::string username_hash_; | 209 std::string username_hash_; |
| 218 std::string hash_ascii_; | 210 std::string hash_ascii_; |
| 219 | 211 |
| 220 ScopedStubCrosEnabler stub_cros_enabler_; | 212 ScopedStubCrosEnabler stub_cros_enabler_; |
| 221 ScopedDeviceSettingsTestHelper device_settings_test_helper_; | 213 ScopedDeviceSettingsTestHelper device_settings_test_helper_; |
| 222 ScopedTestCrosSettings test_cros_settings_; | 214 ScopedTestCrosSettings test_cros_settings_; |
| 223 | 215 |
| 224 // Mocks, destroyed by CrosLibrary class. | 216 // Mocks, destroyed by CrosLibrary class. |
| 225 MockCertLibrary* mock_cert_library_; | |
| 226 ScopedUserManagerEnabler user_manager_enabler_; | 217 ScopedUserManagerEnabler user_manager_enabler_; |
| 227 | 218 |
| 228 scoped_ptr<MockCryptohomeLibrary> mock_cryptohome_library_; | 219 scoped_ptr<MockCryptohomeLibrary> mock_cryptohome_library_; |
| 229 | 220 |
| 230 cryptohome::MockAsyncMethodCaller* mock_caller_; | 221 cryptohome::MockAsyncMethodCaller* mock_caller_; |
| 231 | 222 |
| 232 MockConsumer consumer_; | 223 MockConsumer consumer_; |
| 233 scoped_refptr<ParallelAuthenticator> auth_; | 224 scoped_refptr<ParallelAuthenticator> auth_; |
| 234 scoped_ptr<TestAttemptState> state_; | 225 scoped_ptr<TestAttemptState> state_; |
| 235 }; | 226 }; |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 .WillOnce(Return(std::string())) | 786 .WillOnce(Return(std::string())) |
| 796 .RetiresOnSaturation(); | 787 .RetiresOnSaturation(); |
| 797 | 788 |
| 798 auth_->AuthenticateToUnlock(UserContext(username_, | 789 auth_->AuthenticateToUnlock(UserContext(username_, |
| 799 std::string(), | 790 std::string(), |
| 800 std::string())); | 791 std::string())); |
| 801 message_loop_.Run(); | 792 message_loop_.Run(); |
| 802 } | 793 } |
| 803 | 794 |
| 804 } // namespace chromeos | 795 } // namespace chromeos |
| OLD | NEW |