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/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } // namespace | 127 } // namespace |
128 | 128 |
129 class CryptohomeAuthenticatorTest : public testing::Test { | 129 class CryptohomeAuthenticatorTest : public testing::Test { |
130 public: | 130 public: |
131 CryptohomeAuthenticatorTest() | 131 CryptohomeAuthenticatorTest() |
132 : user_context_("me@nowhere.org"), | 132 : user_context_("me@nowhere.org"), |
133 user_manager_(new FakeUserManager()), | 133 user_manager_(new FakeUserManager()), |
134 user_manager_enabler_(user_manager_), | 134 user_manager_enabler_(user_manager_), |
135 mock_caller_(NULL), | 135 mock_caller_(NULL), |
136 mock_homedir_methods_(NULL), | 136 mock_homedir_methods_(NULL), |
137 owner_key_util_(new ownership::MockOwnerKeyUtil) { | 137 owner_key_util_(new ownership::MockOwnerKeyUtil()) { |
| 138 OwnerSettingsServiceFactory::GetInstance()->SetOwnerKeyUtilForTesting( |
| 139 owner_key_util_); |
138 user_context_.SetKey(Key("fakepass")); | 140 user_context_.SetKey(Key("fakepass")); |
139 user_context_.SetUserIDHash("me_nowhere_com_hash"); | 141 user_context_.SetUserIDHash("me_nowhere_com_hash"); |
140 const user_manager::User* user = | 142 const user_manager::User* user = |
141 user_manager_->AddUser(user_context_.GetUserID()); | 143 user_manager_->AddUser(user_context_.GetUserID()); |
142 profile_.set_profile_name(user_context_.GetUserID()); | 144 profile_.set_profile_name(user_context_.GetUserID()); |
143 | 145 |
144 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, &profile_); | 146 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, &profile_); |
145 | 147 |
146 CreateTransformedKey(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, | 148 CreateTransformedKey(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, |
147 SystemSaltGetter::ConvertRawSaltToHexString( | 149 SystemSaltGetter::ConvertRawSaltToHexString( |
(...skipping 10 matching lines...) Expand all Loading... |
158 mock_homedir_methods_ = new cryptohome::MockHomedirMethods; | 160 mock_homedir_methods_ = new cryptohome::MockHomedirMethods; |
159 mock_homedir_methods_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); | 161 mock_homedir_methods_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
160 cryptohome::HomedirMethods::InitializeForTesting(mock_homedir_methods_); | 162 cryptohome::HomedirMethods::InitializeForTesting(mock_homedir_methods_); |
161 | 163 |
162 fake_cryptohome_client_ = new FakeCryptohomeClient; | 164 fake_cryptohome_client_ = new FakeCryptohomeClient; |
163 chromeos::DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( | 165 chromeos::DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( |
164 scoped_ptr<CryptohomeClient>(fake_cryptohome_client_)); | 166 scoped_ptr<CryptohomeClient>(fake_cryptohome_client_)); |
165 | 167 |
166 SystemSaltGetter::Initialize(); | 168 SystemSaltGetter::Initialize(); |
167 | 169 |
168 OwnerSettingsService::SetOwnerKeyUtilForTesting(owner_key_util_); | |
169 | |
170 auth_ = new ChromeCryptohomeAuthenticator(&consumer_); | 170 auth_ = new ChromeCryptohomeAuthenticator(&consumer_); |
171 state_.reset(new TestAttemptState(user_context_, false)); | 171 state_.reset(new TestAttemptState(user_context_, false)); |
172 } | 172 } |
173 | 173 |
174 // Tears down the test fixture. | 174 // Tears down the test fixture. |
175 virtual void TearDown() { | 175 virtual void TearDown() { |
176 OwnerSettingsService::SetOwnerKeyUtilForTesting(NULL); | |
177 SystemSaltGetter::Shutdown(); | 176 SystemSaltGetter::Shutdown(); |
178 DBusThreadManager::Shutdown(); | 177 DBusThreadManager::Shutdown(); |
179 | 178 |
180 cryptohome::AsyncMethodCaller::Shutdown(); | 179 cryptohome::AsyncMethodCaller::Shutdown(); |
181 mock_caller_ = NULL; | 180 mock_caller_ = NULL; |
182 cryptohome::HomedirMethods::Shutdown(); | 181 cryptohome::HomedirMethods::Shutdown(); |
183 mock_homedir_methods_ = NULL; | 182 mock_homedir_methods_ = NULL; |
184 } | 183 } |
185 | 184 |
186 void CreateTransformedKey(Key::KeyType type, const std::string& salt) { | 185 void CreateTransformedKey(Key::KeyType type, const std::string& salt) { |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 // salt. | 830 // salt. |
832 ExpectGetKeyDataExCall( | 831 ExpectGetKeyDataExCall( |
833 make_scoped_ptr(new int64(Key::KEY_TYPE_SALTED_SHA256)), | 832 make_scoped_ptr(new int64(Key::KEY_TYPE_SALTED_SHA256)), |
834 scoped_ptr<std::string>()); | 833 scoped_ptr<std::string>()); |
835 | 834 |
836 auth_->AuthenticateToLogin(NULL, user_context_); | 835 auth_->AuthenticateToLogin(NULL, user_context_); |
837 base::RunLoop().Run(); | 836 base::RunLoop().Run(); |
838 } | 837 } |
839 | 838 |
840 } // namespace chromeos | 839 } // namespace chromeos |
OLD | NEW |