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 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | |
20 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 19 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
21 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" | 20 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
22 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" | 21 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" |
23 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 22 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
24 #include "chrome/browser/chromeos/settings/cros_settings.h" | 23 #include "chrome/browser/chromeos/settings/cros_settings.h" |
25 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 24 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
26 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 25 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
27 #include "chrome/test/base/testing_browser_process.h" | 26 #include "chrome/test/base/testing_browser_process.h" |
28 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
29 #include "chrome/test/base/testing_profile_manager.h" | 28 #include "chrome/test/base/testing_profile_manager.h" |
30 #include "chromeos/chromeos_switches.h" | 29 #include "chromeos/chromeos_switches.h" |
31 #include "chromeos/cryptohome/cryptohome_parameters.h" | 30 #include "chromeos/cryptohome/cryptohome_parameters.h" |
32 #include "chromeos/cryptohome/homedir_methods.h" | 31 #include "chromeos/cryptohome/homedir_methods.h" |
33 #include "chromeos/cryptohome/mock_async_method_caller.h" | 32 #include "chromeos/cryptohome/mock_async_method_caller.h" |
34 #include "chromeos/cryptohome/mock_homedir_methods.h" | 33 #include "chromeos/cryptohome/mock_homedir_methods.h" |
35 #include "chromeos/cryptohome/system_salt_getter.h" | 34 #include "chromeos/cryptohome/system_salt_getter.h" |
36 #include "chromeos/dbus/cros_disks_client.h" | 35 #include "chromeos/dbus/cros_disks_client.h" |
37 #include "chromeos/dbus/cryptohome/rpc.pb.h" | 36 #include "chromeos/dbus/cryptohome/rpc.pb.h" |
38 #include "chromeos/dbus/dbus_thread_manager.h" | 37 #include "chromeos/dbus/dbus_thread_manager.h" |
39 #include "chromeos/dbus/fake_cryptohome_client.h" | 38 #include "chromeos/dbus/fake_cryptohome_client.h" |
40 #include "chromeos/login/auth/key.h" | 39 #include "chromeos/login/auth/key.h" |
41 #include "chromeos/login/auth/mock_auth_status_consumer.h" | 40 #include "chromeos/login/auth/mock_auth_status_consumer.h" |
42 #include "chromeos/login/auth/mock_url_fetchers.h" | 41 #include "chromeos/login/auth/mock_url_fetchers.h" |
43 #include "chromeos/login/auth/test_attempt_state.h" | 42 #include "chromeos/login/auth/test_attempt_state.h" |
44 #include "chromeos/login/auth/user_context.h" | 43 #include "chromeos/login/auth/user_context.h" |
45 #include "chromeos/login/login_state.h" | 44 #include "chromeos/login/login_state.h" |
46 #include "components/ownership/mock_owner_key_util.h" | 45 #include "components/ownership/mock_owner_key_util.h" |
| 46 #include "components/user_manager/fake_user_manager.h" |
47 #include "content/public/test/test_browser_thread_bundle.h" | 47 #include "content/public/test/test_browser_thread_bundle.h" |
48 #include "crypto/nss_util_internal.h" | 48 #include "crypto/nss_util_internal.h" |
49 #include "crypto/scoped_test_nss_chromeos_user.h" | 49 #include "crypto/scoped_test_nss_chromeos_user.h" |
50 #include "google_apis/gaia/mock_url_fetcher_factory.h" | 50 #include "google_apis/gaia/mock_url_fetcher_factory.h" |
51 #include "net/base/net_errors.h" | 51 #include "net/base/net_errors.h" |
52 #include "net/url_request/url_request_status.h" | 52 #include "net/url_request/url_request_status.h" |
53 #include "testing/gmock/include/gmock/gmock.h" | 53 #include "testing/gmock/include/gmock/gmock.h" |
54 #include "testing/gtest/include/gtest/gtest.h" | 54 #include "testing/gtest/include/gtest/gtest.h" |
55 #include "third_party/cros_system_api/dbus/service_constants.h" | 55 #include "third_party/cros_system_api/dbus/service_constants.h" |
56 #include "url/gurl.h" | 56 #include "url/gurl.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 return make_scoped_ptr( | 124 return make_scoped_ptr( |
125 crypto::RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo(slot, key)); | 125 crypto::RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo(slot, key)); |
126 } | 126 } |
127 | 127 |
128 } // namespace | 128 } // namespace |
129 | 129 |
130 class CryptohomeAuthenticatorTest : public testing::Test { | 130 class CryptohomeAuthenticatorTest : public testing::Test { |
131 public: | 131 public: |
132 CryptohomeAuthenticatorTest() | 132 CryptohomeAuthenticatorTest() |
133 : user_context_("me@nowhere.org"), | 133 : user_context_("me@nowhere.org"), |
134 user_manager_(new FakeUserManager()), | 134 user_manager_(new user_manager::FakeUserManager()), |
135 user_manager_enabler_(user_manager_), | 135 user_manager_enabler_(user_manager_), |
136 mock_caller_(NULL), | 136 mock_caller_(NULL), |
137 mock_homedir_methods_(NULL), | 137 mock_homedir_methods_(NULL), |
138 owner_key_util_(new ownership::MockOwnerKeyUtil()) { | 138 owner_key_util_(new ownership::MockOwnerKeyUtil()) { |
139 OwnerSettingsServiceChromeOSFactory::GetInstance() | 139 OwnerSettingsServiceChromeOSFactory::GetInstance() |
140 ->SetOwnerKeyUtilForTesting(owner_key_util_); | 140 ->SetOwnerKeyUtilForTesting(owner_key_util_); |
141 user_context_.SetKey(Key("fakepass")); | 141 user_context_.SetKey(Key("fakepass")); |
142 user_context_.SetUserIDHash("me_nowhere_com_hash"); | 142 user_context_.SetUserIDHash("me_nowhere_com_hash"); |
143 const user_manager::User* user = | 143 const user_manager::User* user = |
144 user_manager_->AddUser(user_context_.GetUserID()); | 144 user_manager_->AddUser(user_context_.GetUserID()); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 UserContext user_context_with_transformed_key_; | 318 UserContext user_context_with_transformed_key_; |
319 Key transformed_key_; | 319 Key transformed_key_; |
320 | 320 |
321 std::vector<cryptohome::KeyDefinition> key_definitions_; | 321 std::vector<cryptohome::KeyDefinition> key_definitions_; |
322 | 322 |
323 ScopedDeviceSettingsTestHelper device_settings_test_helper_; | 323 ScopedDeviceSettingsTestHelper device_settings_test_helper_; |
324 ScopedTestCrosSettings test_cros_settings_; | 324 ScopedTestCrosSettings test_cros_settings_; |
325 | 325 |
326 TestingProfile profile_; | 326 TestingProfile profile_; |
327 scoped_ptr<TestingProfileManager> profile_manager_; | 327 scoped_ptr<TestingProfileManager> profile_manager_; |
328 FakeUserManager* user_manager_; | 328 user_manager::FakeUserManager* user_manager_; |
329 ScopedUserManagerEnabler user_manager_enabler_; | 329 ScopedUserManagerEnabler user_manager_enabler_; |
330 | 330 |
331 cryptohome::MockAsyncMethodCaller* mock_caller_; | 331 cryptohome::MockAsyncMethodCaller* mock_caller_; |
332 cryptohome::MockHomedirMethods* mock_homedir_methods_; | 332 cryptohome::MockHomedirMethods* mock_homedir_methods_; |
333 | 333 |
334 MockAuthStatusConsumer consumer_; | 334 MockAuthStatusConsumer consumer_; |
335 | 335 |
336 scoped_refptr<CryptohomeAuthenticator> auth_; | 336 scoped_refptr<CryptohomeAuthenticator> auth_; |
337 scoped_ptr<TestAttemptState> state_; | 337 scoped_ptr<TestAttemptState> state_; |
338 FakeCryptohomeClient* fake_cryptohome_client_; | 338 FakeCryptohomeClient* fake_cryptohome_client_; |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 // salt. | 790 // salt. |
791 ExpectGetKeyDataExCall( | 791 ExpectGetKeyDataExCall( |
792 make_scoped_ptr(new int64(Key::KEY_TYPE_SALTED_SHA256)), | 792 make_scoped_ptr(new int64(Key::KEY_TYPE_SALTED_SHA256)), |
793 scoped_ptr<std::string>()); | 793 scoped_ptr<std::string>()); |
794 | 794 |
795 auth_->AuthenticateToLogin(NULL, user_context_); | 795 auth_->AuthenticateToLogin(NULL, user_context_); |
796 base::RunLoop().Run(); | 796 base::RunLoop().Run(); |
797 } | 797 } |
798 | 798 |
799 } // namespace chromeos | 799 } // namespace chromeos |
OLD | NEW |