| 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); |
| 143 OwnerSettingsServiceChromeOSFactory::GetInstance() | 147 OwnerSettingsServiceChromeOSFactory::GetInstance() |
| 144 ->SetOwnerKeyUtilForTesting(owner_key_util_); | 148 ->SetOwnerKeyUtilForTesting(owner_key_util_); |
| 145 user_context_.SetKey(Key("fakepass")); | 149 user_context_.SetKey(Key("fakepass")); |
| 146 user_context_.SetUserIDHash("me_nowhere_com_hash"); | 150 user_context_.SetUserIDHash("me_nowhere_com_hash"); |
| 147 const user_manager::User* user = | 151 const user_manager::User* user = |
| 148 user_manager_->AddUser(user_context_.GetAccountId()); | 152 user_manager_->AddUser(user_context_.GetAccountId()); |
| 149 profile_.set_profile_name(user_context_.GetAccountId().GetUserEmail()); | 153 profile_->set_profile_name(user_context_.GetAccountId().GetUserEmail()); |
| 150 | 154 |
| 151 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, &profile_); | 155 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, |
| 156 profile_.get()); |
| 152 | 157 |
| 153 CreateTransformedKey(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, | 158 CreateTransformedKey(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, |
| 154 SystemSaltGetter::ConvertRawSaltToHexString( | 159 SystemSaltGetter::ConvertRawSaltToHexString( |
| 155 FakeCryptohomeClient::GetStubSystemSalt())); | 160 FakeCryptohomeClient::GetStubSystemSalt())); |
| 156 } | 161 } |
| 157 | 162 |
| 158 ~CryptohomeAuthenticatorTest() override {} | 163 ~CryptohomeAuthenticatorTest() override {} |
| 159 | 164 |
| 160 void SetUp() override { | 165 void SetUp() override { |
| 161 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 166 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 323 |
| 319 UserContext user_context_; | 324 UserContext user_context_; |
| 320 UserContext user_context_with_transformed_key_; | 325 UserContext user_context_with_transformed_key_; |
| 321 Key transformed_key_; | 326 Key transformed_key_; |
| 322 | 327 |
| 323 std::vector<cryptohome::KeyDefinition> key_definitions_; | 328 std::vector<cryptohome::KeyDefinition> key_definitions_; |
| 324 | 329 |
| 325 ScopedDeviceSettingsTestHelper device_settings_test_helper_; | 330 ScopedDeviceSettingsTestHelper device_settings_test_helper_; |
| 326 ScopedTestCrosSettings test_cros_settings_; | 331 ScopedTestCrosSettings test_cros_settings_; |
| 327 | 332 |
| 328 TestingProfile profile_; | 333 chromeos::FakeChromeUserManager* user_manager_; |
| 334 std::unique_ptr<TestingProfile> profile_; |
| 329 std::unique_ptr<TestingProfileManager> profile_manager_; | 335 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 330 chromeos::FakeChromeUserManager* user_manager_; | |
| 331 ScopedUserManagerEnabler user_manager_enabler_; | 336 ScopedUserManagerEnabler user_manager_enabler_; |
| 332 | 337 |
| 333 cryptohome::MockAsyncMethodCaller* mock_caller_; | 338 cryptohome::MockAsyncMethodCaller* mock_caller_; |
| 334 cryptohome::MockHomedirMethods* mock_homedir_methods_; | 339 cryptohome::MockHomedirMethods* mock_homedir_methods_; |
| 335 | 340 |
| 336 MockAuthStatusConsumer consumer_; | 341 MockAuthStatusConsumer consumer_; |
| 337 | 342 |
| 338 scoped_refptr<CryptohomeAuthenticator> auth_; | 343 scoped_refptr<CryptohomeAuthenticator> auth_; |
| 339 std::unique_ptr<TestAttemptState> state_; | 344 std::unique_ptr<TestAttemptState> state_; |
| 340 FakeCryptohomeClient* fake_cryptohome_client_; | 345 FakeCryptohomeClient* fake_cryptohome_client_; |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 // pre-hashed key was used to create the cryptohome but without the required | 787 // pre-hashed key was used to create the cryptohome but without the required |
| 783 // salt. | 788 // salt. |
| 784 ExpectGetKeyDataExCall(base::MakeUnique<int64_t>(Key::KEY_TYPE_SALTED_SHA256), | 789 ExpectGetKeyDataExCall(base::MakeUnique<int64_t>(Key::KEY_TYPE_SALTED_SHA256), |
| 785 std::unique_ptr<std::string>()); | 790 std::unique_ptr<std::string>()); |
| 786 | 791 |
| 787 auth_->AuthenticateToLogin(NULL, user_context_); | 792 auth_->AuthenticateToLogin(NULL, user_context_); |
| 788 base::RunLoop().Run(); | 793 base::RunLoop().Run(); |
| 789 } | 794 } |
| 790 | 795 |
| 791 } // namespace chromeos | 796 } // namespace chromeos |
| OLD | NEW |