OLD | NEW |
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 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } // namespace | 116 } // namespace |
117 | 117 |
118 class CryptohomeAuthenticatorTest : public testing::Test { | 118 class CryptohomeAuthenticatorTest : public testing::Test { |
119 public: | 119 public: |
120 CryptohomeAuthenticatorTest() | 120 CryptohomeAuthenticatorTest() |
121 : user_context_("me@nowhere.org"), | 121 : user_context_("me@nowhere.org"), |
122 user_manager_(new FakeUserManager()), | 122 user_manager_(new FakeUserManager()), |
123 user_manager_enabler_(user_manager_), | 123 user_manager_enabler_(user_manager_), |
124 mock_caller_(NULL), | 124 mock_caller_(NULL), |
125 mock_homedir_methods_(NULL), | 125 mock_homedir_methods_(NULL), |
126 owner_key_util_(new ownership::MockOwnerKeyUtil) { | 126 owner_key_util_(new ownership::MockOwnerKeyUtil()) { |
| 127 OwnerSettingsServiceFactory::GetInstance()->set_owner_key_util_for_testing( |
| 128 owner_key_util_); |
127 user_context_.SetKey(Key("fakepass")); | 129 user_context_.SetKey(Key("fakepass")); |
128 user_context_.SetUserIDHash("me_nowhere_com_hash"); | 130 user_context_.SetUserIDHash("me_nowhere_com_hash"); |
129 const user_manager::User* user = | 131 const user_manager::User* user = |
130 user_manager_->AddUser(user_context_.GetUserID()); | 132 user_manager_->AddUser(user_context_.GetUserID()); |
131 profile_.set_profile_name(user_context_.GetUserID()); | 133 profile_.set_profile_name(user_context_.GetUserID()); |
132 | 134 |
133 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, &profile_); | 135 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, &profile_); |
134 | 136 |
135 transformed_key_ = *user_context_.GetKey(); | 137 transformed_key_ = *user_context_.GetKey(); |
136 transformed_key_.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, | 138 transformed_key_.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, |
(...skipping 11 matching lines...) Expand all Loading... |
148 mock_homedir_methods_ = new cryptohome::MockHomedirMethods; | 150 mock_homedir_methods_ = new cryptohome::MockHomedirMethods; |
149 mock_homedir_methods_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); | 151 mock_homedir_methods_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
150 cryptohome::HomedirMethods::InitializeForTesting(mock_homedir_methods_); | 152 cryptohome::HomedirMethods::InitializeForTesting(mock_homedir_methods_); |
151 | 153 |
152 fake_cryptohome_client_ = new FakeCryptohomeClient; | 154 fake_cryptohome_client_ = new FakeCryptohomeClient; |
153 chromeos::DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( | 155 chromeos::DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( |
154 scoped_ptr<CryptohomeClient>(fake_cryptohome_client_)); | 156 scoped_ptr<CryptohomeClient>(fake_cryptohome_client_)); |
155 | 157 |
156 SystemSaltGetter::Initialize(); | 158 SystemSaltGetter::Initialize(); |
157 | 159 |
158 OwnerSettingsService::SetOwnerKeyUtilForTesting(owner_key_util_); | |
159 | |
160 auth_ = new ChromeCryptohomeAuthenticator(&consumer_); | 160 auth_ = new ChromeCryptohomeAuthenticator(&consumer_); |
161 state_.reset(new TestAttemptState(user_context_, false)); | 161 state_.reset(new TestAttemptState(user_context_, false)); |
162 } | 162 } |
163 | 163 |
164 // Tears down the test fixture. | 164 // Tears down the test fixture. |
165 virtual void TearDown() { | 165 virtual void TearDown() { |
166 OwnerSettingsService::SetOwnerKeyUtilForTesting(NULL); | |
167 SystemSaltGetter::Shutdown(); | 166 SystemSaltGetter::Shutdown(); |
168 DBusThreadManager::Shutdown(); | 167 DBusThreadManager::Shutdown(); |
169 | 168 |
170 cryptohome::AsyncMethodCaller::Shutdown(); | 169 cryptohome::AsyncMethodCaller::Shutdown(); |
171 mock_caller_ = NULL; | 170 mock_caller_ = NULL; |
172 cryptohome::HomedirMethods::Shutdown(); | 171 cryptohome::HomedirMethods::Shutdown(); |
173 mock_homedir_methods_ = NULL; | 172 mock_homedir_methods_ = NULL; |
174 } | 173 } |
175 | 174 |
176 base::FilePath PopulateTempFile(const char* data, int data_len) { | 175 base::FilePath PopulateTempFile(const char* data, int data_len) { |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); | 742 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
744 EXPECT_CALL(*mock_caller_, AsyncCheckKey(user_context_.GetUserID(), _, _)) | 743 EXPECT_CALL(*mock_caller_, AsyncCheckKey(user_context_.GetUserID(), _, _)) |
745 .Times(1) | 744 .Times(1) |
746 .RetiresOnSaturation(); | 745 .RetiresOnSaturation(); |
747 | 746 |
748 auth_->AuthenticateToUnlock(user_context_); | 747 auth_->AuthenticateToUnlock(user_context_); |
749 base::MessageLoop::current()->Run(); | 748 base::MessageLoop::current()->Run(); |
750 } | 749 } |
751 | 750 |
752 } // namespace chromeos | 751 } // namespace chromeos |
OLD | NEW |