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

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

Issue 494093002: OwnerKeyUtil is moved to components/ownership. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed GYP file. Created 6 years, 3 months 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 | Annotate | Revision Log
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 #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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" 16 #include "chrome/browser/chromeos/login/users/fake_user_manager.h"
17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
18 #include "chrome/browser/chromeos/ownership/owner_settings_service.h" 18 #include "chrome/browser/chromeos/ownership/owner_settings_service.h"
19 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" 19 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h"
20 #include "chrome/browser/chromeos/profiles/profile_helper.h" 20 #include "chrome/browser/chromeos/profiles/profile_helper.h"
21 #include "chrome/browser/chromeos/settings/cros_settings.h" 21 #include "chrome/browser/chromeos/settings/cros_settings.h"
22 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" 22 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
23 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h"
24 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" 23 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
25 #include "chrome/test/base/testing_browser_process.h" 24 #include "chrome/test/base/testing_browser_process.h"
26 #include "chrome/test/base/testing_profile.h" 25 #include "chrome/test/base/testing_profile.h"
27 #include "chrome/test/base/testing_profile_manager.h" 26 #include "chrome/test/base/testing_profile_manager.h"
28 #include "chromeos/chromeos_switches.h" 27 #include "chromeos/chromeos_switches.h"
29 #include "chromeos/cryptohome/cryptohome_parameters.h" 28 #include "chromeos/cryptohome/cryptohome_parameters.h"
30 #include "chromeos/cryptohome/homedir_methods.h" 29 #include "chromeos/cryptohome/homedir_methods.h"
31 #include "chromeos/cryptohome/mock_async_method_caller.h" 30 #include "chromeos/cryptohome/mock_async_method_caller.h"
32 #include "chromeos/cryptohome/mock_homedir_methods.h" 31 #include "chromeos/cryptohome/mock_homedir_methods.h"
33 #include "chromeos/cryptohome/system_salt_getter.h" 32 #include "chromeos/cryptohome/system_salt_getter.h"
34 #include "chromeos/dbus/cros_disks_client.h" 33 #include "chromeos/dbus/cros_disks_client.h"
35 #include "chromeos/dbus/dbus_thread_manager.h" 34 #include "chromeos/dbus/dbus_thread_manager.h"
36 #include "chromeos/dbus/fake_cryptohome_client.h" 35 #include "chromeos/dbus/fake_cryptohome_client.h"
37 #include "chromeos/login/auth/key.h" 36 #include "chromeos/login/auth/key.h"
38 #include "chromeos/login/auth/mock_auth_status_consumer.h" 37 #include "chromeos/login/auth/mock_auth_status_consumer.h"
39 #include "chromeos/login/auth/mock_url_fetchers.h" 38 #include "chromeos/login/auth/mock_url_fetchers.h"
40 #include "chromeos/login/auth/test_attempt_state.h" 39 #include "chromeos/login/auth/test_attempt_state.h"
41 #include "chromeos/login/auth/user_context.h" 40 #include "chromeos/login/auth/user_context.h"
41 #include "components/ownership/mock_owner_key_util.h"
42 #include "content/public/test/test_browser_thread_bundle.h" 42 #include "content/public/test/test_browser_thread_bundle.h"
43 #include "crypto/nss_util_internal.h" 43 #include "crypto/nss_util_internal.h"
44 #include "crypto/scoped_test_nss_chromeos_user.h" 44 #include "crypto/scoped_test_nss_chromeos_user.h"
45 #include "google_apis/gaia/mock_url_fetcher_factory.h" 45 #include "google_apis/gaia/mock_url_fetcher_factory.h"
46 #include "net/base/net_errors.h" 46 #include "net/base/net_errors.h"
47 #include "net/url_request/url_request_status.h" 47 #include "net/url_request/url_request_status.h"
48 #include "testing/gmock/include/gmock/gmock.h" 48 #include "testing/gmock/include/gmock/gmock.h"
49 #include "testing/gtest/include/gtest/gtest.h" 49 #include "testing/gtest/include/gtest/gtest.h"
50 #include "third_party/cros_system_api/dbus/service_constants.h" 50 #include "third_party/cros_system_api/dbus/service_constants.h"
51 #include "url/gurl.h" 51 #include "url/gurl.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } // namespace 116 } // namespace
117 117
118 class CryptohomeAuthenticatorTest : public testing::Test { 118 class CryptohomeAuthenticatorTest : public testing::Test {
119 public: 119 public:
120 CryptohomeAuthenticatorTest() 120 CryptohomeAuthenticatorTest()
121 : user_context_("me@nowhere.org"), 121 : user_context_("me@nowhere.org"),
122 user_manager_(new FakeUserManager()), 122 user_manager_(new FakeUserManager()),
123 user_manager_enabler_(user_manager_), 123 user_manager_enabler_(user_manager_),
124 mock_caller_(NULL), 124 mock_caller_(NULL),
125 mock_homedir_methods_(NULL), 125 mock_homedir_methods_(NULL),
126 owner_key_util_(new MockOwnerKeyUtil) { 126 owner_key_util_(new ownership::MockOwnerKeyUtil) {
127 user_context_.SetKey(Key("fakepass")); 127 user_context_.SetKey(Key("fakepass"));
128 user_context_.SetUserIDHash("me_nowhere_com_hash"); 128 user_context_.SetUserIDHash("me_nowhere_com_hash");
129 const user_manager::User* user = 129 const user_manager::User* user =
130 user_manager_->AddUser(user_context_.GetUserID()); 130 user_manager_->AddUser(user_context_.GetUserID());
131 profile_.set_profile_name(user_context_.GetUserID()); 131 profile_.set_profile_name(user_context_.GetUserID());
132 132
133 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, &profile_); 133 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, &profile_);
134 134
135 transformed_key_ = *user_context_.GetKey(); 135 transformed_key_ = *user_context_.GetKey();
136 transformed_key_.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, 136 transformed_key_.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF,
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 cryptohome::MockAsyncMethodCaller* mock_caller_; 276 cryptohome::MockAsyncMethodCaller* mock_caller_;
277 cryptohome::MockHomedirMethods* mock_homedir_methods_; 277 cryptohome::MockHomedirMethods* mock_homedir_methods_;
278 278
279 MockAuthStatusConsumer consumer_; 279 MockAuthStatusConsumer consumer_;
280 280
281 scoped_refptr<CryptohomeAuthenticator> auth_; 281 scoped_refptr<CryptohomeAuthenticator> auth_;
282 scoped_ptr<TestAttemptState> state_; 282 scoped_ptr<TestAttemptState> state_;
283 FakeCryptohomeClient* fake_cryptohome_client_; 283 FakeCryptohomeClient* fake_cryptohome_client_;
284 284
285 scoped_refptr<MockOwnerKeyUtil> owner_key_util_; 285 scoped_refptr<ownership::MockOwnerKeyUtil> owner_key_util_;
286 }; 286 };
287 287
288 TEST_F(CryptohomeAuthenticatorTest, OnAuthSuccess) { 288 TEST_F(CryptohomeAuthenticatorTest, OnAuthSuccess) {
289 EXPECT_CALL(consumer_, OnAuthSuccess(user_context_)) 289 EXPECT_CALL(consumer_, OnAuthSuccess(user_context_))
290 .Times(1) 290 .Times(1)
291 .RetiresOnSaturation(); 291 .RetiresOnSaturation();
292 292
293 SetAttemptState(auth_.get(), state_.release()); 293 SetAttemptState(auth_.get(), state_.release());
294 auth_->OnAuthSuccess(); 294 auth_->OnAuthSuccess();
295 } 295 }
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); 743 mock_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE);
744 EXPECT_CALL(*mock_caller_, AsyncCheckKey(user_context_.GetUserID(), _, _)) 744 EXPECT_CALL(*mock_caller_, AsyncCheckKey(user_context_.GetUserID(), _, _))
745 .Times(1) 745 .Times(1)
746 .RetiresOnSaturation(); 746 .RetiresOnSaturation();
747 747
748 auth_->AuthenticateToUnlock(user_context_); 748 auth_->AuthenticateToUnlock(user_context_);
749 base::MessageLoop::current()->Run(); 749 base::MessageLoop::current()->Run();
750 } 750 }
751 751
752 } // namespace chromeos 752 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/chrome_browser_main_chromeos.cc ('k') | chrome/browser/chromeos/ownership/owner_settings_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698