Chromium Code Reviews| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 namespace em = enterprise_management; | 71 namespace em = enterprise_management; |
| 72 | 72 |
| 73 namespace chromeos { | 73 namespace chromeos { |
| 74 | 74 |
| 75 namespace { | 75 namespace { |
| 76 | 76 |
| 77 const char kGaiaID[] = "12345"; | 77 const char kGaiaID[] = "12345"; |
| 78 const char kUsername[] = "test_user@gmail.com"; | 78 const char kUsername[] = "test_user@gmail.com"; |
| 79 const char kSupervisedUserID[] = "supervised_user@locally-managed.localhost"; | 79 const char kSupervisedUserID[] = "supervised_user@locally-managed.localhost"; |
| 80 const char kPassword[] = "test_password"; | 80 const char kPassword[] = "test_password"; |
| 81 const char kActiveDirectoryRealm[] = "active.directory.realm"; | |
| 81 | 82 |
| 82 const char kPublicSessionUserEmail[] = "public_session_user@localhost"; | 83 const char kPublicSessionUserEmail[] = "public_session_user@localhost"; |
| 83 const int kAutoLoginNoDelay = 0; | 84 const int kAutoLoginNoDelay = 0; |
| 84 const int kAutoLoginShortDelay = 1; | 85 const int kAutoLoginShortDelay = 1; |
| 85 const int kAutoLoginLongDelay = 10000; | 86 const int kAutoLoginLongDelay = 10000; |
| 86 | 87 |
| 87 // Wait for cros settings to become permanently untrusted and run |callback|. | 88 // Wait for cros settings to become permanently untrusted and run |callback|. |
| 88 void WaitForPermanentlyUntrustedStatusAndRun(const base::Closure& callback) { | 89 void WaitForPermanentlyUntrustedStatusAndRun(const base::Closure& callback) { |
| 89 while (true) { | 90 while (true) { |
| 90 const CrosSettingsProvider::TrustedStatus status = | 91 const CrosSettingsProvider::TrustedStatus status = |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 std::unique_ptr<ExistingUserController> existing_user_controller_; | 224 std::unique_ptr<ExistingUserController> existing_user_controller_; |
| 224 | 225 |
| 225 // |mock_login_display_| is owned by the ExistingUserController, which calls | 226 // |mock_login_display_| is owned by the ExistingUserController, which calls |
| 226 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. | 227 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. |
| 227 MockLoginDisplay* mock_login_display_ = nullptr; | 228 MockLoginDisplay* mock_login_display_ = nullptr; |
| 228 std::unique_ptr<MockLoginDisplayHost> mock_login_display_host_; | 229 std::unique_ptr<MockLoginDisplayHost> mock_login_display_host_; |
| 229 | 230 |
| 230 // Mock URLFetcher. | 231 // Mock URLFetcher. |
| 231 MockURLFetcherFactory<SuccessFetcher> factory_; | 232 MockURLFetcherFactory<SuccessFetcher> factory_; |
| 232 | 233 |
| 233 const AccountId account_id_ = | 234 const AccountId google_account_id_ = |
|
achuithb
2017/02/17 13:03:49
I think gaia_account_id_ is a better name, and mor
Roman Sorokin (ftl)
2017/02/17 14:28:43
Done.
| |
| 234 AccountId::FromUserEmailGaiaId(kUsername, kGaiaID); | 235 AccountId::FromUserEmailGaiaId(kUsername, kGaiaID); |
| 236 const AccountId ad_account_id_ = | |
| 237 AccountId::AdFromUserEmailObjGuid(kUsername, kGaiaID); | |
| 235 | 238 |
| 236 private: | 239 private: |
| 237 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); | 240 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); |
| 238 }; | 241 }; |
| 239 | 242 |
| 240 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, PRE_ExistingUserLogin) { | 243 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, PRE_ExistingUserLogin) { |
| 241 RegisterUser(account_id_.GetUserEmail()); | 244 RegisterUser(google_account_id_.GetUserEmail()); |
| 242 } | 245 } |
| 243 | 246 |
| 244 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, DISABLED_ExistingUserLogin) { | 247 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, DISABLED_ExistingUserLogin) { |
| 245 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 248 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
| 246 .Times(2); | 249 .Times(2); |
| 247 UserContext user_context(account_id_); | 250 UserContext user_context(google_account_id_); |
| 248 user_context.SetKey(Key(kPassword)); | 251 user_context.SetKey(Key(kPassword)); |
| 249 user_context.SetUserIDHash(account_id_.GetUserEmail()); | 252 user_context.SetUserIDHash(google_account_id_.GetUserEmail()); |
| 250 test::UserSessionManagerTestApi session_manager_test_api( | 253 test::UserSessionManagerTestApi session_manager_test_api( |
| 251 UserSessionManager::GetInstance()); | 254 UserSessionManager::GetInstance()); |
| 252 session_manager_test_api.InjectStubUserContext(user_context); | 255 session_manager_test_api.InjectStubUserContext(user_context); |
| 253 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 256 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
| 254 .Times(1); | 257 .Times(1); |
| 255 EXPECT_CALL(*mock_login_display_host_, | 258 EXPECT_CALL(*mock_login_display_host_, |
| 256 StartWizard(OobeScreen::SCREEN_TERMS_OF_SERVICE)) | 259 StartWizard(OobeScreen::SCREEN_TERMS_OF_SERVICE)) |
| 257 .Times(0); | 260 .Times(0); |
| 258 | 261 |
| 259 content::WindowedNotificationObserver profile_prepared_observer( | 262 content::WindowedNotificationObserver profile_prepared_observer( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 290 | 293 |
| 291 ExpectLoginFailure(); | 294 ExpectLoginFailure(); |
| 292 } | 295 } |
| 293 | 296 |
| 294 void ExistingUserControllerUntrustedTest::SetUpSessionManager() { | 297 void ExistingUserControllerUntrustedTest::SetUpSessionManager() { |
| 295 InstallOwnerKey(); | 298 InstallOwnerKey(); |
| 296 } | 299 } |
| 297 | 300 |
| 298 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 301 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
| 299 ExistingUserLoginForbidden) { | 302 ExistingUserLoginForbidden) { |
| 300 UserContext user_context(account_id_); | 303 UserContext user_context(google_account_id_); |
| 301 user_context.SetKey(Key(kPassword)); | 304 user_context.SetKey(Key(kPassword)); |
| 302 user_context.SetUserIDHash(account_id_.GetUserEmail()); | 305 user_context.SetUserIDHash(google_account_id_.GetUserEmail()); |
| 303 existing_user_controller()->Login(user_context, SigninSpecifics()); | 306 existing_user_controller()->Login(user_context, SigninSpecifics()); |
| 304 } | 307 } |
| 305 | 308 |
| 306 // Per http://crbug.com/603735, NewUserLoginForbidden fails. | 309 // Per http://crbug.com/603735, NewUserLoginForbidden fails. |
| 307 #if defined(LINUX) | 310 #if defined(LINUX) |
| 308 #define MAYBE_NewUserLoginForbidden DISABLED_NewUserLoginForbidden | 311 #define MAYBE_NewUserLoginForbidden DISABLED_NewUserLoginForbidden |
| 309 #else | 312 #else |
| 310 #define MAYBE_NewUserLoginForbidden NewUserLoginForbidden | 313 #define MAYBE_NewUserLoginForbidden NewUserLoginForbidden |
| 311 #endif | 314 #endif |
| 312 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 315 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
| 313 MAYBE_NewUserLoginForbidden) { | 316 MAYBE_NewUserLoginForbidden) { |
| 314 UserContext user_context(account_id_); | 317 UserContext user_context(google_account_id_); |
| 315 user_context.SetKey(Key(kPassword)); | 318 user_context.SetKey(Key(kPassword)); |
| 316 user_context.SetUserIDHash(account_id_.GetUserEmail()); | 319 user_context.SetUserIDHash(google_account_id_.GetUserEmail()); |
| 317 existing_user_controller()->CompleteLogin(user_context); | 320 existing_user_controller()->CompleteLogin(user_context); |
| 318 } | 321 } |
| 319 | 322 |
| 320 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 323 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
| 321 GuestLoginForbidden) { | 324 GuestLoginForbidden) { |
| 322 existing_user_controller()->Login( | 325 existing_user_controller()->Login( |
| 323 UserContext(user_manager::USER_TYPE_GUEST, EmptyAccountId()), | 326 UserContext(user_manager::USER_TYPE_GUEST, EmptyAccountId()), |
| 324 SigninSpecifics()); | 327 SigninSpecifics()); |
| 325 } | 328 } |
| 326 | 329 |
| 327 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 330 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
| 328 SupervisedUserLoginForbidden) { | 331 SupervisedUserLoginForbidden) { |
| 329 UserContext user_context(AccountId::FromUserEmail(kSupervisedUserID)); | 332 UserContext user_context(AccountId::FromUserEmail(kSupervisedUserID)); |
| 330 user_context.SetKey(Key(kPassword)); | 333 user_context.SetKey(Key(kPassword)); |
| 331 user_context.SetUserIDHash(account_id_.GetUserEmail()); | 334 user_context.SetUserIDHash(google_account_id_.GetUserEmail()); |
| 332 existing_user_controller()->Login(user_context, SigninSpecifics()); | 335 existing_user_controller()->Login(user_context, SigninSpecifics()); |
| 333 } | 336 } |
| 334 | 337 |
| 335 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 338 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
| 336 SupervisedUserCreationForbidden) { | 339 SupervisedUserCreationForbidden) { |
| 337 MockBaseScreenDelegate mock_base_screen_delegate; | 340 MockBaseScreenDelegate mock_base_screen_delegate; |
| 338 SupervisedUserCreationScreenHandler supervised_user_creation_screen_handler; | 341 SupervisedUserCreationScreenHandler supervised_user_creation_screen_handler; |
| 339 SupervisedUserCreationScreen supervised_user_creation_screen( | 342 SupervisedUserCreationScreen supervised_user_creation_screen( |
| 340 &mock_base_screen_delegate, &supervised_user_creation_screen_handler); | 343 &mock_base_screen_delegate, &supervised_user_creation_screen_handler); |
| 341 | 344 |
| 342 supervised_user_creation_screen.AuthenticateManager(account_id_, kPassword); | 345 supervised_user_creation_screen.AuthenticateManager(google_account_id_, |
| 346 kPassword); | |
| 343 } | 347 } |
| 344 | 348 |
| 345 MATCHER_P(HasDetails, expected, "") { | 349 MATCHER_P(HasDetails, expected, "") { |
| 346 return expected == *content::Details<const std::string>(arg).ptr(); | 350 return expected == *content::Details<const std::string>(arg).ptr(); |
| 347 } | 351 } |
| 348 | 352 |
| 349 class ExistingUserControllerPublicSessionTest | 353 class ExistingUserControllerPublicSessionTest |
| 350 : public ExistingUserControllerTest { | 354 : public ExistingUserControllerTest { |
| 351 protected: | 355 protected: |
| 352 ExistingUserControllerPublicSessionTest() {} | 356 ExistingUserControllerPublicSessionTest() {} |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 profile_prepared_observer.Wait(); | 594 profile_prepared_observer.Wait(); |
| 591 | 595 |
| 592 // Wait for login tasks to complete. | 596 // Wait for login tasks to complete. |
| 593 content::RunAllPendingInMessageLoop(); | 597 content::RunAllPendingInMessageLoop(); |
| 594 } | 598 } |
| 595 | 599 |
| 596 // See http://crbug.com/654719 | 600 // See http://crbug.com/654719 |
| 597 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 601 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 598 DISABLED_LoginStopsAutoLogin) { | 602 DISABLED_LoginStopsAutoLogin) { |
| 599 // Set up mocks to check login success. | 603 // Set up mocks to check login success. |
| 600 UserContext user_context(account_id_); | 604 UserContext user_context(google_account_id_); |
| 601 user_context.SetKey(Key(kPassword)); | 605 user_context.SetKey(Key(kPassword)); |
| 602 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); | 606 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); |
| 603 ExpectSuccessfulLogin(user_context); | 607 ExpectSuccessfulLogin(user_context); |
| 604 | 608 |
| 605 existing_user_controller()->OnSigninScreenReady(); | 609 existing_user_controller()->OnSigninScreenReady(); |
| 606 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); | 610 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); |
| 607 EXPECT_TRUE(auto_login_timer()); | 611 EXPECT_TRUE(auto_login_timer()); |
| 608 | 612 |
| 609 content::WindowedNotificationObserver profile_prepared_observer( | 613 content::WindowedNotificationObserver profile_prepared_observer( |
| 610 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 614 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 625 ASSERT_TRUE(auto_login_timer()); | 629 ASSERT_TRUE(auto_login_timer()); |
| 626 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 630 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 627 | 631 |
| 628 ClearNotifications(); | 632 ClearNotifications(); |
| 629 } | 633 } |
| 630 | 634 |
| 631 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 635 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 632 GuestModeLoginStopsAutoLogin) { | 636 GuestModeLoginStopsAutoLogin) { |
| 633 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 637 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
| 634 .Times(2); | 638 .Times(2); |
| 635 UserContext user_context(account_id_); | 639 UserContext user_context(google_account_id_); |
| 636 user_context.SetKey(Key(kPassword)); | 640 user_context.SetKey(Key(kPassword)); |
| 637 test::UserSessionManagerTestApi session_manager_test_api( | 641 test::UserSessionManagerTestApi session_manager_test_api( |
| 638 UserSessionManager::GetInstance()); | 642 UserSessionManager::GetInstance()); |
| 639 session_manager_test_api.InjectStubUserContext(user_context); | 643 session_manager_test_api.InjectStubUserContext(user_context); |
| 640 | 644 |
| 641 existing_user_controller()->OnSigninScreenReady(); | 645 existing_user_controller()->OnSigninScreenReady(); |
| 642 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); | 646 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); |
| 643 EXPECT_TRUE(auto_login_timer()); | 647 EXPECT_TRUE(auto_login_timer()); |
| 644 | 648 |
| 645 // Login and check that it stopped the timer. | 649 // Login and check that it stopped the timer. |
| 646 existing_user_controller()->Login( | 650 existing_user_controller()->Login( |
| 647 UserContext(user_manager::USER_TYPE_GUEST, EmptyAccountId()), | 651 UserContext(user_manager::USER_TYPE_GUEST, EmptyAccountId()), |
| 648 SigninSpecifics()); | 652 SigninSpecifics()); |
| 649 EXPECT_TRUE(is_login_in_progress()); | 653 EXPECT_TRUE(is_login_in_progress()); |
| 650 ASSERT_TRUE(auto_login_timer()); | 654 ASSERT_TRUE(auto_login_timer()); |
| 651 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 655 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 652 | 656 |
| 653 // Wait for login tasks to complete. | 657 // Wait for login tasks to complete. |
| 654 content::RunAllPendingInMessageLoop(); | 658 content::RunAllPendingInMessageLoop(); |
| 655 | 659 |
| 656 // Timer should still be stopped after login completes. | 660 // Timer should still be stopped after login completes. |
| 657 ASSERT_TRUE(auto_login_timer()); | 661 ASSERT_TRUE(auto_login_timer()); |
| 658 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 662 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 659 } | 663 } |
| 660 | 664 |
| 661 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 665 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 662 CompleteLoginStopsAutoLogin) { | 666 CompleteLoginStopsAutoLogin) { |
| 663 // Set up mocks to check login success. | 667 // Set up mocks to check login success. |
| 664 UserContext user_context(account_id_); | 668 UserContext user_context(google_account_id_); |
| 665 user_context.SetKey(Key(kPassword)); | 669 user_context.SetKey(Key(kPassword)); |
| 666 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); | 670 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); |
| 667 ExpectSuccessfulLogin(user_context); | 671 ExpectSuccessfulLogin(user_context); |
| 668 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) | 672 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) |
| 669 .Times(1); | 673 .Times(1); |
| 670 | 674 |
| 671 existing_user_controller()->OnSigninScreenReady(); | 675 existing_user_controller()->OnSigninScreenReady(); |
| 672 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); | 676 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); |
| 673 EXPECT_TRUE(auto_login_timer()); | 677 EXPECT_TRUE(auto_login_timer()); |
| 674 | 678 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 726 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 730 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 727 } | 731 } |
| 728 | 732 |
| 729 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 733 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 730 LoginForbiddenWhenUntrusted) { | 734 LoginForbiddenWhenUntrusted) { |
| 731 // Make cros settings untrusted. | 735 // Make cros settings untrusted. |
| 732 MakeCrosSettingsPermanentlyUntrusted(); | 736 MakeCrosSettingsPermanentlyUntrusted(); |
| 733 | 737 |
| 734 // Check that the attempt to start a public session fails with an error. | 738 // Check that the attempt to start a public session fails with an error. |
| 735 ExpectLoginFailure(); | 739 ExpectLoginFailure(); |
| 736 UserContext user_context(account_id_); | 740 UserContext user_context(google_account_id_); |
| 737 user_context.SetKey(Key(kPassword)); | 741 user_context.SetKey(Key(kPassword)); |
| 738 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); | 742 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); |
| 739 existing_user_controller()->Login(user_context, SigninSpecifics()); | 743 existing_user_controller()->Login(user_context, SigninSpecifics()); |
| 740 } | 744 } |
| 741 | 745 |
| 742 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 746 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 743 NoAutoLoginWhenUntrusted) { | 747 NoAutoLoginWhenUntrusted) { |
| 744 // Start the public session timer. | 748 // Start the public session timer. |
| 745 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); | 749 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); |
| 746 existing_user_controller()->OnSigninScreenReady(); | 750 existing_user_controller()->OnSigninScreenReady(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 757 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 761 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 758 PRE_TestLoadingPublicUsersFromLocalState) { | 762 PRE_TestLoadingPublicUsersFromLocalState) { |
| 759 // First run propagates public accounts and stores them in Local State. | 763 // First run propagates public accounts and stores them in Local State. |
| 760 } | 764 } |
| 761 | 765 |
| 762 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 766 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
| 763 TestLoadingPublicUsersFromLocalState) { | 767 TestLoadingPublicUsersFromLocalState) { |
| 764 // Second run loads list of public accounts from Local State. | 768 // Second run loads list of public accounts from Local State. |
| 765 } | 769 } |
| 766 | 770 |
| 771 class ExistingUserControllerActiveDirectoryTest | |
| 772 : public ExistingUserControllerTest { | |
| 773 public: | |
| 774 ExistingUserControllerActiveDirectoryTest() = default; | |
| 775 | |
| 776 void MarkOwnership() override { | |
|
achuithb
2017/02/17 13:03:49
comment about class whose methods are being overri
Roman Sorokin (ftl)
2017/02/17 14:28:43
Done.
| |
| 777 policy::DevicePolicyCrosTestHelper::MarkAsActiveDirectoryEnterpriseOwned( | |
| 778 kActiveDirectoryRealm); | |
| 779 } | |
| 780 | |
| 781 void SetUpInProcessBrowserTestFixture() override { | |
| 782 RefreshDevicePolicy(); | |
| 783 ExistingUserControllerTest::SetUpInProcessBrowserTestFixture(); | |
| 784 } | |
| 785 | |
| 786 protected: | |
| 787 void ExpectLoginFailure() { | |
| 788 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)).Times(2); | |
| 789 EXPECT_CALL(*mock_login_display_, | |
| 790 ShowError(IDS_LOGIN_ERROR_ACTIVE_DIRECTORY_ONLY, 1, | |
| 791 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT)) | |
| 792 .Times(1); | |
| 793 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)).Times(1); | |
| 794 } | |
| 795 void ExpectLoginSuccess() { | |
| 796 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)).Times(2); | |
| 797 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)).Times(1); | |
| 798 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()).Times(1); | |
| 799 } | |
| 800 }; | |
| 801 | |
| 802 IN_PROC_BROWSER_TEST_F(ExistingUserControllerActiveDirectoryTest, | |
|
achuithb
2017/02/17 13:03:49
Comment about what's being tested by this.
Roman Sorokin (ftl)
2017/02/17 14:28:43
Done.
| |
| 803 ActiveDirectoryOnlineLogin_Success) { | |
| 804 ExpectLoginSuccess(); | |
| 805 UserContext user_context(ad_account_id_); | |
| 806 user_context.SetKey(Key(kPassword)); | |
| 807 user_context.SetUserIDHash(ad_account_id_.GetUserEmail()); | |
| 808 user_context.SetAuthFlow(UserContext::AUTH_FLOW_ACTIVE_DIRECTORY); | |
| 809 user_context.SetUserType(user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY); | |
| 810 content::WindowedNotificationObserver profile_prepared_observer( | |
| 811 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | |
| 812 content::NotificationService::AllSources()); | |
| 813 existing_user_controller()->CompleteLogin(user_context); | |
| 814 | |
| 815 profile_prepared_observer.Wait(); | |
| 816 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 817 FROM_HERE, base::Bind(&ClearNotifications)); | |
| 818 content::RunAllPendingInMessageLoop(); | |
| 819 } | |
| 820 | |
| 821 IN_PROC_BROWSER_TEST_F(ExistingUserControllerActiveDirectoryTest, | |
|
achuithb
2017/02/17 13:03:49
Function comment
Roman Sorokin (ftl)
2017/02/17 14:28:43
Done.
| |
| 822 ActiveDirectoryOfflineLogin_Failure) { | |
| 823 ExpectLoginFailure(); | |
| 824 UserContext user_context(ad_account_id_); | |
| 825 user_context.SetKey(Key(kPassword)); | |
| 826 user_context.SetUserIDHash(ad_account_id_.GetUserEmail()); | |
| 827 user_context.SetUserType(user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY); | |
| 828 existing_user_controller()->Login(user_context, SigninSpecifics()); | |
| 829 } | |
| 830 | |
| 831 IN_PROC_BROWSER_TEST_F(ExistingUserControllerActiveDirectoryTest, | |
|
achuithb
2017/02/17 13:03:49
Function comment
Roman Sorokin (ftl)
2017/02/17 14:28:43
Done.
| |
| 832 GoogleAccountLogin_Failure) { | |
| 833 ExpectLoginFailure(); | |
|
achuithb
2017/02/17 13:03:49
GAIAAccountLogin_Failure
Roman Sorokin (ftl)
2017/02/17 14:28:43
Done.
| |
| 834 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()).Times(1); | |
| 835 UserContext user_context(google_account_id_); | |
| 836 user_context.SetKey(Key(kPassword)); | |
| 837 user_context.SetUserIDHash(google_account_id_.GetUserEmail()); | |
| 838 existing_user_controller()->CompleteLogin(user_context); | |
| 839 } | |
| 840 | |
| 767 } // namespace chromeos | 841 } // namespace chromeos |
| OLD | NEW |