OLD | NEW |
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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 using ::testing::ReturnNull; | 64 using ::testing::ReturnNull; |
65 using ::testing::WithArg; | 65 using ::testing::WithArg; |
66 using ::testing::_; | 66 using ::testing::_; |
67 | 67 |
68 namespace em = enterprise_management; | 68 namespace em = enterprise_management; |
69 | 69 |
70 namespace chromeos { | 70 namespace chromeos { |
71 | 71 |
72 namespace { | 72 namespace { |
73 | 73 |
| 74 const char kGaiaID[] = "12345"; |
74 const char kUsername[] = "test_user@gmail.com"; | 75 const char kUsername[] = "test_user@gmail.com"; |
75 const char kSupervisedUserID[] = "supervised_user@locally-managed.localhost"; | 76 const char kSupervisedUserID[] = "supervised_user@locally-managed.localhost"; |
76 const char kPassword[] = "test_password"; | 77 const char kPassword[] = "test_password"; |
77 | 78 |
78 const char kPublicSessionAccountId[] = "public_session_user@localhost"; | 79 const char kPublicSessionAccountId[] = "public_session_user@localhost"; |
79 const int kAutoLoginNoDelay = 0; | 80 const int kAutoLoginNoDelay = 0; |
80 const int kAutoLoginShortDelay = 1; | 81 const int kAutoLoginShortDelay = 1; |
81 const int kAutoLoginLongDelay = 10000; | 82 const int kAutoLoginLongDelay = 10000; |
82 | 83 |
83 // Wait for cros settings to become permanently untrusted and run |callback|. | 84 // Wait for cros settings to become permanently untrusted and run |callback|. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 }; | 221 }; |
221 | 222 |
222 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, PRE_ExistingUserLogin) { | 223 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, PRE_ExistingUserLogin) { |
223 RegisterUser(kUsername); | 224 RegisterUser(kUsername); |
224 } | 225 } |
225 | 226 |
226 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { | 227 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { |
227 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 228 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
228 .Times(2); | 229 .Times(2); |
229 UserContext user_context(kUsername); | 230 UserContext user_context(kUsername); |
| 231 user_context.SetGaiaID(kGaiaID); |
230 user_context.SetKey(Key(kPassword)); | 232 user_context.SetKey(Key(kPassword)); |
231 user_context.SetUserIDHash(kUsername); | 233 user_context.SetUserIDHash(kUsername); |
232 test::UserSessionManagerTestApi session_manager_test_api( | 234 test::UserSessionManagerTestApi session_manager_test_api( |
233 UserSessionManager::GetInstance()); | 235 UserSessionManager::GetInstance()); |
234 session_manager_test_api.InjectStubUserContext(user_context); | 236 session_manager_test_api.InjectStubUserContext(user_context); |
235 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 237 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
236 .Times(1); | 238 .Times(1); |
237 EXPECT_CALL(*mock_login_display_host_, | 239 EXPECT_CALL(*mock_login_display_host_, |
238 StartWizard(WizardController::kTermsOfServiceScreenName)) | 240 StartWizard(WizardController::kTermsOfServiceScreenName)) |
239 .Times(0); | 241 .Times(0); |
(...skipping 30 matching lines...) Expand all Loading... |
270 ExpectLoginFailure(); | 272 ExpectLoginFailure(); |
271 } | 273 } |
272 | 274 |
273 void ExistingUserControllerUntrustedTest::SetUpSessionManager() { | 275 void ExistingUserControllerUntrustedTest::SetUpSessionManager() { |
274 InstallOwnerKey(); | 276 InstallOwnerKey(); |
275 } | 277 } |
276 | 278 |
277 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 279 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
278 ExistingUserLoginForbidden) { | 280 ExistingUserLoginForbidden) { |
279 UserContext user_context(kUsername); | 281 UserContext user_context(kUsername); |
| 282 user_context.SetGaiaID(kGaiaID); |
280 user_context.SetKey(Key(kPassword)); | 283 user_context.SetKey(Key(kPassword)); |
281 user_context.SetUserIDHash(kUsername); | 284 user_context.SetUserIDHash(kUsername); |
282 existing_user_controller()->Login(user_context, SigninSpecifics()); | 285 existing_user_controller()->Login(user_context, SigninSpecifics()); |
283 } | 286 } |
284 | 287 |
285 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 288 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
286 NewUserLoginForbidden) { | 289 NewUserLoginForbidden) { |
287 UserContext user_context(kUsername); | 290 UserContext user_context(kUsername); |
| 291 user_context.SetGaiaID(kGaiaID); |
288 user_context.SetKey(Key(kPassword)); | 292 user_context.SetKey(Key(kPassword)); |
289 user_context.SetUserIDHash(kUsername); | 293 user_context.SetUserIDHash(kUsername); |
290 existing_user_controller()->CompleteLogin(user_context); | 294 existing_user_controller()->CompleteLogin(user_context); |
291 } | 295 } |
292 | 296 |
293 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 297 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
294 CreateAccountForbidden) { | 298 CreateAccountForbidden) { |
295 existing_user_controller()->CreateAccount(); | 299 existing_user_controller()->CreateAccount(); |
296 } | 300 } |
297 | 301 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 profile_prepared_observer.Wait(); | 566 profile_prepared_observer.Wait(); |
563 | 567 |
564 // Wait for login tasks to complete. | 568 // Wait for login tasks to complete. |
565 content::RunAllPendingInMessageLoop(); | 569 content::RunAllPendingInMessageLoop(); |
566 } | 570 } |
567 | 571 |
568 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 572 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
569 LoginStopsAutoLogin) { | 573 LoginStopsAutoLogin) { |
570 // Set up mocks to check login success. | 574 // Set up mocks to check login success. |
571 UserContext user_context(kUsername); | 575 UserContext user_context(kUsername); |
| 576 user_context.SetGaiaID(kGaiaID); |
572 user_context.SetKey(Key(kPassword)); | 577 user_context.SetKey(Key(kPassword)); |
573 user_context.SetUserIDHash(user_context.GetUserID()); | 578 user_context.SetUserIDHash(user_context.GetUserID()); |
574 ExpectSuccessfulLogin(user_context); | 579 ExpectSuccessfulLogin(user_context); |
575 | 580 |
576 existing_user_controller()->OnSigninScreenReady(); | 581 existing_user_controller()->OnSigninScreenReady(); |
577 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 582 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
578 EXPECT_TRUE(auto_login_timer()); | 583 EXPECT_TRUE(auto_login_timer()); |
579 | 584 |
580 content::WindowedNotificationObserver profile_prepared_observer( | 585 content::WindowedNotificationObserver profile_prepared_observer( |
581 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 586 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
(...skipping 13 matching lines...) Expand all Loading... |
595 // Timer should still be stopped after login completes. | 600 // Timer should still be stopped after login completes. |
596 ASSERT_TRUE(auto_login_timer()); | 601 ASSERT_TRUE(auto_login_timer()); |
597 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 602 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
598 } | 603 } |
599 | 604 |
600 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 605 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
601 GuestModeLoginStopsAutoLogin) { | 606 GuestModeLoginStopsAutoLogin) { |
602 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 607 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
603 .Times(2); | 608 .Times(2); |
604 UserContext user_context(kUsername); | 609 UserContext user_context(kUsername); |
| 610 user_context.SetGaiaID(kGaiaID); |
605 user_context.SetKey(Key(kPassword)); | 611 user_context.SetKey(Key(kPassword)); |
606 test::UserSessionManagerTestApi session_manager_test_api( | 612 test::UserSessionManagerTestApi session_manager_test_api( |
607 UserSessionManager::GetInstance()); | 613 UserSessionManager::GetInstance()); |
608 session_manager_test_api.InjectStubUserContext(user_context); | 614 session_manager_test_api.InjectStubUserContext(user_context); |
609 | 615 |
610 existing_user_controller()->OnSigninScreenReady(); | 616 existing_user_controller()->OnSigninScreenReady(); |
611 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 617 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
612 EXPECT_TRUE(auto_login_timer()); | 618 EXPECT_TRUE(auto_login_timer()); |
613 | 619 |
614 // Login and check that it stopped the timer. | 620 // Login and check that it stopped the timer. |
615 existing_user_controller()->Login(UserContext(user_manager::USER_TYPE_GUEST, | 621 existing_user_controller()->Login(UserContext(user_manager::USER_TYPE_GUEST, |
616 std::string()), | 622 std::string()), |
617 SigninSpecifics()); | 623 SigninSpecifics()); |
618 EXPECT_TRUE(is_login_in_progress()); | 624 EXPECT_TRUE(is_login_in_progress()); |
619 ASSERT_TRUE(auto_login_timer()); | 625 ASSERT_TRUE(auto_login_timer()); |
620 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 626 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
621 | 627 |
622 // Wait for login tasks to complete. | 628 // Wait for login tasks to complete. |
623 content::RunAllPendingInMessageLoop(); | 629 content::RunAllPendingInMessageLoop(); |
624 | 630 |
625 // Timer should still be stopped after login completes. | 631 // Timer should still be stopped after login completes. |
626 ASSERT_TRUE(auto_login_timer()); | 632 ASSERT_TRUE(auto_login_timer()); |
627 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 633 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
628 } | 634 } |
629 | 635 |
630 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 636 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
631 CompleteLoginStopsAutoLogin) { | 637 CompleteLoginStopsAutoLogin) { |
632 // Set up mocks to check login success. | 638 // Set up mocks to check login success. |
633 UserContext user_context(kUsername); | 639 UserContext user_context(kUsername); |
| 640 user_context.SetGaiaID(kGaiaID); |
634 user_context.SetKey(Key(kPassword)); | 641 user_context.SetKey(Key(kPassword)); |
635 user_context.SetUserIDHash(user_context.GetUserID()); | 642 user_context.SetUserIDHash(user_context.GetUserID()); |
636 ExpectSuccessfulLogin(user_context); | 643 ExpectSuccessfulLogin(user_context); |
637 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) | 644 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) |
638 .Times(1); | 645 .Times(1); |
639 | 646 |
640 existing_user_controller()->OnSigninScreenReady(); | 647 existing_user_controller()->OnSigninScreenReady(); |
641 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 648 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
642 EXPECT_TRUE(auto_login_timer()); | 649 EXPECT_TRUE(auto_login_timer()); |
643 | 650 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 } | 703 } |
697 | 704 |
698 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 705 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
699 LoginForbiddenWhenUntrusted) { | 706 LoginForbiddenWhenUntrusted) { |
700 // Make cros settings untrusted. | 707 // Make cros settings untrusted. |
701 MakeCrosSettingsPermanentlyUntrusted(); | 708 MakeCrosSettingsPermanentlyUntrusted(); |
702 | 709 |
703 // Check that the attempt to start a public session fails with an error. | 710 // Check that the attempt to start a public session fails with an error. |
704 ExpectLoginFailure(); | 711 ExpectLoginFailure(); |
705 UserContext user_context(kUsername); | 712 UserContext user_context(kUsername); |
| 713 user_context.SetGaiaID(kGaiaID); |
706 user_context.SetKey(Key(kPassword)); | 714 user_context.SetKey(Key(kPassword)); |
707 user_context.SetUserIDHash(user_context.GetUserID()); | 715 user_context.SetUserIDHash(user_context.GetUserID()); |
708 existing_user_controller()->Login(user_context, SigninSpecifics()); | 716 existing_user_controller()->Login(user_context, SigninSpecifics()); |
709 } | 717 } |
710 | 718 |
711 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 719 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
712 NoAutoLoginWhenUntrusted) { | 720 NoAutoLoginWhenUntrusted) { |
713 // Start the public session timer. | 721 // Start the public session timer. |
714 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 722 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
715 existing_user_controller()->OnSigninScreenReady(); | 723 existing_user_controller()->OnSigninScreenReady(); |
(...skipping 12 matching lines...) Expand all Loading... |
728 // First run propagates public accounts and stores them in Local State. | 736 // First run propagates public accounts and stores them in Local State. |
729 } | 737 } |
730 | 738 |
731 // See http://crbug.com/393704; flaky. | 739 // See http://crbug.com/393704; flaky. |
732 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 740 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
733 DISABLED_TestLoadingPublicUsersFromLocalState) { | 741 DISABLED_TestLoadingPublicUsersFromLocalState) { |
734 // Second run loads list of public accounts from Local State. | 742 // Second run loads list of public accounts from Local State. |
735 } | 743 } |
736 | 744 |
737 } // namespace chromeos | 745 } // namespace chromeos |
OLD | NEW |