Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(724)

Side by Side Diff: chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc

Issue 2504513002: Make FakeChromeUserManager subclass of ChromeUserManager (Closed)
Patch Set: Addressed comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
22 #include "chrome/browser/chromeos/login/auth/chrome_cryptohome_authenticator.h" 22 #include "chrome/browser/chromeos/login/auth/chrome_cryptohome_authenticator.h"
23 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
23 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 24 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
24 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 25 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
25 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" 26 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h"
26 #include "chrome/browser/chromeos/profiles/profile_helper.h" 27 #include "chrome/browser/chromeos/profiles/profile_helper.h"
27 #include "chrome/browser/chromeos/settings/cros_settings.h" 28 #include "chrome/browser/chromeos/settings/cros_settings.h"
28 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" 29 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
29 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" 30 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
30 #include "chrome/test/base/testing_browser_process.h" 31 #include "chrome/test/base/testing_browser_process.h"
31 #include "chrome/test/base/testing_profile.h" 32 #include "chrome/test/base/testing_profile.h"
32 #include "chrome/test/base/testing_profile_manager.h" 33 #include "chrome/test/base/testing_profile_manager.h"
33 #include "chromeos/chromeos_switches.h" 34 #include "chromeos/chromeos_switches.h"
34 #include "chromeos/cryptohome/cryptohome_parameters.h" 35 #include "chromeos/cryptohome/cryptohome_parameters.h"
35 #include "chromeos/cryptohome/homedir_methods.h" 36 #include "chromeos/cryptohome/homedir_methods.h"
36 #include "chromeos/cryptohome/mock_async_method_caller.h" 37 #include "chromeos/cryptohome/mock_async_method_caller.h"
37 #include "chromeos/cryptohome/mock_homedir_methods.h" 38 #include "chromeos/cryptohome/mock_homedir_methods.h"
38 #include "chromeos/cryptohome/system_salt_getter.h" 39 #include "chromeos/cryptohome/system_salt_getter.h"
39 #include "chromeos/dbus/cros_disks_client.h" 40 #include "chromeos/dbus/cros_disks_client.h"
40 #include "chromeos/dbus/cryptohome/rpc.pb.h" 41 #include "chromeos/dbus/cryptohome/rpc.pb.h"
41 #include "chromeos/dbus/dbus_thread_manager.h" 42 #include "chromeos/dbus/dbus_thread_manager.h"
42 #include "chromeos/dbus/fake_cryptohome_client.h" 43 #include "chromeos/dbus/fake_cryptohome_client.h"
43 #include "chromeos/login/auth/key.h" 44 #include "chromeos/login/auth/key.h"
44 #include "chromeos/login/auth/mock_auth_status_consumer.h" 45 #include "chromeos/login/auth/mock_auth_status_consumer.h"
45 #include "chromeos/login/auth/mock_url_fetchers.h" 46 #include "chromeos/login/auth/mock_url_fetchers.h"
46 #include "chromeos/login/auth/test_attempt_state.h" 47 #include "chromeos/login/auth/test_attempt_state.h"
47 #include "chromeos/login/auth/user_context.h" 48 #include "chromeos/login/auth/user_context.h"
48 #include "chromeos/login/login_state.h" 49 #include "chromeos/login/login_state.h"
49 #include "components/ownership/mock_owner_key_util.h" 50 #include "components/ownership/mock_owner_key_util.h"
50 #include "components/user_manager/fake_user_manager.h"
51 #include "content/public/test/test_browser_thread_bundle.h" 51 #include "content/public/test/test_browser_thread_bundle.h"
52 #include "crypto/nss_key_util.h" 52 #include "crypto/nss_key_util.h"
53 #include "crypto/nss_util_internal.h" 53 #include "crypto/nss_util_internal.h"
54 #include "crypto/scoped_test_nss_chromeos_user.h" 54 #include "crypto/scoped_test_nss_chromeos_user.h"
55 #include "google_apis/gaia/mock_url_fetcher_factory.h" 55 #include "google_apis/gaia/mock_url_fetcher_factory.h"
56 #include "net/base/net_errors.h" 56 #include "net/base/net_errors.h"
57 #include "net/url_request/url_request_status.h" 57 #include "net/url_request/url_request_status.h"
58 #include "testing/gmock/include/gmock/gmock.h" 58 #include "testing/gmock/include/gmock/gmock.h"
59 #include "testing/gtest/include/gtest/gtest.h" 59 #include "testing/gtest/include/gtest/gtest.h"
60 #include "third_party/cros_system_api/dbus/service_constants.h" 60 #include "third_party/cros_system_api/dbus/service_constants.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return crypto::ImportNSSKeyFromPrivateKeyInfo( 129 return crypto::ImportNSSKeyFromPrivateKeyInfo(
130 slot, key, true /* permanent */) != nullptr; 130 slot, key, true /* permanent */) != nullptr;
131 } 131 }
132 132
133 } // namespace 133 } // namespace
134 134
135 class CryptohomeAuthenticatorTest : public testing::Test { 135 class CryptohomeAuthenticatorTest : public testing::Test {
136 public: 136 public:
137 CryptohomeAuthenticatorTest() 137 CryptohomeAuthenticatorTest()
138 : user_context_(AccountId::FromUserEmail("me@nowhere.org")), 138 : user_context_(AccountId::FromUserEmail("me@nowhere.org")),
139 user_manager_(new user_manager::FakeUserManager()), 139 user_manager_(new chromeos::FakeChromeUserManager()),
140 user_manager_enabler_(user_manager_), 140 user_manager_enabler_(user_manager_),
141 mock_caller_(NULL), 141 mock_caller_(NULL),
142 mock_homedir_methods_(NULL), 142 mock_homedir_methods_(NULL),
143 owner_key_util_(new ownership::MockOwnerKeyUtil()) { 143 owner_key_util_(new ownership::MockOwnerKeyUtil()) {
144 OwnerSettingsServiceChromeOSFactory::GetInstance() 144 OwnerSettingsServiceChromeOSFactory::GetInstance()
145 ->SetOwnerKeyUtilForTesting(owner_key_util_); 145 ->SetOwnerKeyUtilForTesting(owner_key_util_);
146 user_context_.SetKey(Key("fakepass")); 146 user_context_.SetKey(Key("fakepass"));
147 user_context_.SetUserIDHash("me_nowhere_com_hash"); 147 user_context_.SetUserIDHash("me_nowhere_com_hash");
148 const user_manager::User* user = 148 const user_manager::User* user =
149 user_manager_->AddUser(user_context_.GetAccountId()); 149 user_manager_->AddUser(user_context_.GetAccountId());
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 UserContext user_context_with_transformed_key_; 321 UserContext user_context_with_transformed_key_;
322 Key transformed_key_; 322 Key transformed_key_;
323 323
324 std::vector<cryptohome::KeyDefinition> key_definitions_; 324 std::vector<cryptohome::KeyDefinition> key_definitions_;
325 325
326 ScopedDeviceSettingsTestHelper device_settings_test_helper_; 326 ScopedDeviceSettingsTestHelper device_settings_test_helper_;
327 ScopedTestCrosSettings test_cros_settings_; 327 ScopedTestCrosSettings test_cros_settings_;
328 328
329 TestingProfile profile_; 329 TestingProfile profile_;
330 std::unique_ptr<TestingProfileManager> profile_manager_; 330 std::unique_ptr<TestingProfileManager> profile_manager_;
331 user_manager::FakeUserManager* user_manager_; 331 chromeos::FakeChromeUserManager* user_manager_;
332 ScopedUserManagerEnabler user_manager_enabler_; 332 ScopedUserManagerEnabler user_manager_enabler_;
333 333
334 cryptohome::MockAsyncMethodCaller* mock_caller_; 334 cryptohome::MockAsyncMethodCaller* mock_caller_;
335 cryptohome::MockHomedirMethods* mock_homedir_methods_; 335 cryptohome::MockHomedirMethods* mock_homedir_methods_;
336 336
337 MockAuthStatusConsumer consumer_; 337 MockAuthStatusConsumer consumer_;
338 338
339 scoped_refptr<CryptohomeAuthenticator> auth_; 339 scoped_refptr<CryptohomeAuthenticator> auth_;
340 std::unique_ptr<TestAttemptState> state_; 340 std::unique_ptr<TestAttemptState> state_;
341 FakeCryptohomeClient* fake_cryptohome_client_; 341 FakeCryptohomeClient* fake_cryptohome_client_;
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 // pre-hashed key was used to create the cryptohome but without the required 783 // pre-hashed key was used to create the cryptohome but without the required
784 // salt. 784 // salt.
785 ExpectGetKeyDataExCall(base::MakeUnique<int64_t>(Key::KEY_TYPE_SALTED_SHA256), 785 ExpectGetKeyDataExCall(base::MakeUnique<int64_t>(Key::KEY_TYPE_SALTED_SHA256),
786 std::unique_ptr<std::string>()); 786 std::unique_ptr<std::string>());
787 787
788 auth_->AuthenticateToLogin(NULL, user_context_); 788 auth_->AuthenticateToLogin(NULL, user_context_);
789 base::RunLoop().Run(); 789 base::RunLoop().Run();
790 } 790 }
791 791
792 } // namespace chromeos 792 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698