| 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 | 5 |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 class CryptohomeAuthenticatorTest : public testing::Test { | 134 class CryptohomeAuthenticatorTest : public testing::Test { |
| 135 public: | 135 public: |
| 136 CryptohomeAuthenticatorTest() | 136 CryptohomeAuthenticatorTest() |
| 137 : user_context_(AccountId::FromUserEmail("me@nowhere.org")), | 137 : user_context_(AccountId::FromUserEmail("me@nowhere.org")), |
| 138 user_manager_(new chromeos::FakeChromeUserManager()), | 138 user_manager_(new chromeos::FakeChromeUserManager()), |
| 139 user_manager_enabler_(user_manager_), | 139 user_manager_enabler_(user_manager_), |
| 140 mock_caller_(NULL), | 140 mock_caller_(NULL), |
| 141 mock_homedir_methods_(NULL), | 141 mock_homedir_methods_(NULL), |
| 142 owner_key_util_(new ownership::MockOwnerKeyUtil()) { | 142 owner_key_util_(new ownership::MockOwnerKeyUtil()) { |
| 143 // Testing profile must be initialized after user_manager_ + | |
| 144 // user_manager_enabler_, because it will create another UserManager | |
| 145 // instance if UserManager instance has not been registed before. | |
| 146 profile_.reset(new TestingProfile); | |
| 147 OwnerSettingsServiceChromeOSFactory::GetInstance() | 143 OwnerSettingsServiceChromeOSFactory::GetInstance() |
| 148 ->SetOwnerKeyUtilForTesting(owner_key_util_); | 144 ->SetOwnerKeyUtilForTesting(owner_key_util_); |
| 149 user_context_.SetKey(Key("fakepass")); | 145 user_context_.SetKey(Key("fakepass")); |
| 150 user_context_.SetUserIDHash("me_nowhere_com_hash"); | 146 user_context_.SetUserIDHash("me_nowhere_com_hash"); |
| 151 const user_manager::User* user = | 147 const user_manager::User* user = |
| 152 user_manager_->AddUser(user_context_.GetAccountId()); | 148 user_manager_->AddUser(user_context_.GetAccountId()); |
| 153 profile_->set_profile_name(user_context_.GetAccountId().GetUserEmail()); | 149 profile_.set_profile_name(user_context_.GetAccountId().GetUserEmail()); |
| 154 | 150 |
| 155 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, | 151 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, &profile_); |
| 156 profile_.get()); | |
| 157 | 152 |
| 158 CreateTransformedKey(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, | 153 CreateTransformedKey(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, |
| 159 SystemSaltGetter::ConvertRawSaltToHexString( | 154 SystemSaltGetter::ConvertRawSaltToHexString( |
| 160 FakeCryptohomeClient::GetStubSystemSalt())); | 155 FakeCryptohomeClient::GetStubSystemSalt())); |
| 161 } | 156 } |
| 162 | 157 |
| 163 ~CryptohomeAuthenticatorTest() override {} | 158 ~CryptohomeAuthenticatorTest() override {} |
| 164 | 159 |
| 165 void SetUp() override { | 160 void SetUp() override { |
| 166 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 161 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 318 |
| 324 UserContext user_context_; | 319 UserContext user_context_; |
| 325 UserContext user_context_with_transformed_key_; | 320 UserContext user_context_with_transformed_key_; |
| 326 Key transformed_key_; | 321 Key transformed_key_; |
| 327 | 322 |
| 328 std::vector<cryptohome::KeyDefinition> key_definitions_; | 323 std::vector<cryptohome::KeyDefinition> key_definitions_; |
| 329 | 324 |
| 330 ScopedDeviceSettingsTestHelper device_settings_test_helper_; | 325 ScopedDeviceSettingsTestHelper device_settings_test_helper_; |
| 331 ScopedTestCrosSettings test_cros_settings_; | 326 ScopedTestCrosSettings test_cros_settings_; |
| 332 | 327 |
| 328 TestingProfile profile_; |
| 329 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 333 chromeos::FakeChromeUserManager* user_manager_; | 330 chromeos::FakeChromeUserManager* user_manager_; |
| 334 std::unique_ptr<TestingProfile> profile_; | |
| 335 std::unique_ptr<TestingProfileManager> profile_manager_; | |
| 336 ScopedUserManagerEnabler user_manager_enabler_; | 331 ScopedUserManagerEnabler user_manager_enabler_; |
| 337 | 332 |
| 338 cryptohome::MockAsyncMethodCaller* mock_caller_; | 333 cryptohome::MockAsyncMethodCaller* mock_caller_; |
| 339 cryptohome::MockHomedirMethods* mock_homedir_methods_; | 334 cryptohome::MockHomedirMethods* mock_homedir_methods_; |
| 340 | 335 |
| 341 MockAuthStatusConsumer consumer_; | 336 MockAuthStatusConsumer consumer_; |
| 342 | 337 |
| 343 scoped_refptr<CryptohomeAuthenticator> auth_; | 338 scoped_refptr<CryptohomeAuthenticator> auth_; |
| 344 std::unique_ptr<TestAttemptState> state_; | 339 std::unique_ptr<TestAttemptState> state_; |
| 345 FakeCryptohomeClient* fake_cryptohome_client_; | 340 FakeCryptohomeClient* fake_cryptohome_client_; |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 // pre-hashed key was used to create the cryptohome but without the required | 782 // pre-hashed key was used to create the cryptohome but without the required |
| 788 // salt. | 783 // salt. |
| 789 ExpectGetKeyDataExCall(base::MakeUnique<int64_t>(Key::KEY_TYPE_SALTED_SHA256), | 784 ExpectGetKeyDataExCall(base::MakeUnique<int64_t>(Key::KEY_TYPE_SALTED_SHA256), |
| 790 std::unique_ptr<std::string>()); | 785 std::unique_ptr<std::string>()); |
| 791 | 786 |
| 792 auth_->AuthenticateToLogin(NULL, user_context_); | 787 auth_->AuthenticateToLogin(NULL, user_context_); |
| 793 base::RunLoop().Run(); | 788 base::RunLoop().Run(); |
| 794 } | 789 } |
| 795 | 790 |
| 796 } // namespace chromeos | 791 } // namespace chromeos |
| OLD | NEW |