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

Side by Side Diff: chrome/browser/chromeos/login/parallel_authenticator_unittest.cc

Issue 10832035: Switch from SignedSettings to DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/parallel_authenticator.h" 5 #include "chrome/browser/chromeos/login/parallel_authenticator.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "chrome/browser/chromeos/cros/cros_library.h" 15 #include "chrome/browser/chromeos/cros/cros_library.h"
16 #include "chrome/browser/chromeos/cros/mock_cert_library.h" 16 #include "chrome/browser/chromeos/cros/mock_cert_library.h"
17 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" 17 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h"
18 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" 18 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h"
19 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" 19 #include "chrome/browser/chromeos/login/mock_url_fetchers.h"
20 #include "chrome/browser/chromeos/login/mock_user_manager.h" 20 #include "chrome/browser/chromeos/login/mock_user_manager.h"
21 #include "chrome/browser/chromeos/login/test_attempt_state.h" 21 #include "chrome/browser/chromeos/login/test_attempt_state.h"
22 #include "chrome/browser/chromeos/settings/cros_settings.h" 22 #include "chrome/browser/chromeos/settings/cros_settings.h"
23 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
23 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" 24 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
24 #include "chrome/common/net/gaia/mock_url_fetcher_factory.h" 25 #include "chrome/common/net/gaia/mock_url_fetcher_factory.h"
25 #include "chrome/test/base/testing_profile.h" 26 #include "chrome/test/base/testing_profile.h"
26 #include "chromeos/cryptohome/mock_async_method_caller.h" 27 #include "chromeos/cryptohome/mock_async_method_caller.h"
27 #include "chromeos/dbus/mock_cryptohome_client.h" 28 #include "chromeos/dbus/mock_cryptohome_client.h"
28 #include "chromeos/dbus/mock_dbus_thread_manager.h" 29 #include "chromeos/dbus/mock_dbus_thread_manager.h"
29 #include "content/public/test/test_browser_thread.h" 30 #include "content/public/test/test_browser_thread.h"
30 #include "googleurl/src/gurl.h" 31 #include "googleurl/src/gurl.h"
31 #include "net/base/net_errors.h" 32 #include "net/base/net_errors.h"
32 #include "net/url_request/url_request_status.h" 33 #include "net/url_request/url_request_status.h"
33 #include "testing/gmock/include/gmock/gmock.h" 34 #include "testing/gmock/include/gmock/gmock.h"
34 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
35 #include "third_party/cros_system_api/dbus/service_constants.h" 36 #include "third_party/cros_system_api/dbus/service_constants.h"
36 37
37 using content::BrowserThread;
38 using ::testing::AnyNumber; 38 using ::testing::AnyNumber;
39 using ::testing::DoAll; 39 using ::testing::DoAll;
40 using ::testing::Invoke; 40 using ::testing::Invoke;
41 using ::testing::Return; 41 using ::testing::Return;
42 using ::testing::SetArgPointee; 42 using ::testing::SetArgPointee;
43 using ::testing::_; 43 using ::testing::_;
44 using content::BrowserThread;
44 45
45 namespace chromeos { 46 namespace chromeos {
46 47
47 class TestOnlineAttempt : public OnlineAttempt { 48 class TestOnlineAttempt : public OnlineAttempt {
48 public: 49 public:
49 TestOnlineAttempt(AuthAttemptState* state, 50 TestOnlineAttempt(AuthAttemptState* state,
50 AuthAttemptStateResolver* resolver) 51 AuthAttemptStateResolver* resolver)
51 : OnlineAttempt(false, state, resolver) { 52 : OnlineAttempt(false, state, resolver) {
52 } 53 }
53 }; 54 };
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 202
202 MessageLoop message_loop_; 203 MessageLoop message_loop_;
203 content::TestBrowserThread ui_thread_; 204 content::TestBrowserThread ui_thread_;
204 content::TestBrowserThread file_thread_; 205 content::TestBrowserThread file_thread_;
205 content::TestBrowserThread io_thread_; 206 content::TestBrowserThread io_thread_;
206 207
207 std::string username_; 208 std::string username_;
208 std::string password_; 209 std::string password_;
209 std::string hash_ascii_; 210 std::string hash_ascii_;
210 211
212 ScopedDeviceSettingsTestHelper device_settings_test_helper_;
213
211 // Initializes / shuts down a stub CrosLibrary. 214 // Initializes / shuts down a stub CrosLibrary.
212 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; 215 ScopedStubCrosEnabler stub_cros_enabler_;
213 216
214 // Mocks, destroyed by CrosLibrary class. 217 // Mocks, destroyed by CrosLibrary class.
215 MockCertLibrary* mock_cert_library_; 218 MockCertLibrary* mock_cert_library_;
216 MockCryptohomeLibrary* mock_cryptohome_library_; 219 MockCryptohomeLibrary* mock_cryptohome_library_;
217 ScopedMockUserManagerEnabler mock_user_manager_; 220 ScopedMockUserManagerEnabler mock_user_manager_;
218 221
219 cryptohome::MockAsyncMethodCaller* mock_caller_; 222 cryptohome::MockAsyncMethodCaller* mock_caller_;
220 223
221 MockConsumer consumer_; 224 MockConsumer consumer_;
222 scoped_refptr<ParallelAuthenticator> auth_; 225 scoped_refptr<ParallelAuthenticator> auth_;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 device_settings_provider = 336 device_settings_provider =
334 CrosSettings::Get()->GetProvider(chromeos::kReportDeviceVersionInfo); 337 CrosSettings::Get()->GetProvider(chromeos::kReportDeviceVersionInfo);
335 EXPECT_TRUE(device_settings_provider != NULL); 338 EXPECT_TRUE(device_settings_provider != NULL);
336 EXPECT_TRUE( 339 EXPECT_TRUE(
337 CrosSettings::Get()->RemoveSettingsProvider(device_settings_provider)); 340 CrosSettings::Get()->RemoveSettingsProvider(device_settings_provider));
338 CrosSettings::Get()->AddSettingsProvider(&stub_settings_provider); 341 CrosSettings::Get()->AddSettingsProvider(&stub_settings_provider);
339 CrosSettings::Get()->SetBoolean(kPolicyMissingMitigationMode, true); 342 CrosSettings::Get()->SetBoolean(kPolicyMissingMitigationMode, true);
340 343
341 EXPECT_EQ(ParallelAuthenticator::CONTINUE, 344 EXPECT_EQ(ParallelAuthenticator::CONTINUE,
342 SetAndResolveState(auth_, state_.release())); 345 SetAndResolveState(auth_, state_.release()));
343 // Let the owner verification run on the FILE thread... 346 // Let the owner verification run.
344 message_loop_.RunAllPending(); 347 device_settings_test_helper_.Flush();
345 // and test that the mount has succeeded. 348 // and test that the mount has succeeded.
346 state_.reset(new TestAttemptState(username_, 349 state_.reset(new TestAttemptState(username_,
347 password_, 350 password_,
348 hash_ascii_, 351 hash_ascii_,
349 "", 352 "",
350 "", 353 "",
351 false)); 354 false));
352 state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE); 355 state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE);
353 EXPECT_EQ(ParallelAuthenticator::OWNER_REQUIRED, 356 EXPECT_EQ(ParallelAuthenticator::OWNER_REQUIRED,
354 SetAndResolveState(auth_, state_.release())); 357 SetAndResolveState(auth_, state_.release()));
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 .RetiresOnSaturation(); 755 .RetiresOnSaturation();
753 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) 756 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt())
754 .WillOnce(Return(std::string())) 757 .WillOnce(Return(std::string()))
755 .RetiresOnSaturation(); 758 .RetiresOnSaturation();
756 759
757 auth_->AuthenticateToUnlock(username_, ""); 760 auth_->AuthenticateToUnlock(username_, "");
758 message_loop_.Run(); 761 message_loop_.Run();
759 } 762 }
760 763
761 } // namespace chromeos 764 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698