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

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

Issue 2835473002: Chromad: Allow offline login. (Closed)
Patch Set: Add TryAuthenticateUser call Created 3 years, 8 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
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 <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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 789
790 protected: 790 protected:
791 void ExpectLoginFailure() { 791 void ExpectLoginFailure() {
792 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)).Times(2); 792 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)).Times(2);
793 EXPECT_CALL(*mock_login_display_, 793 EXPECT_CALL(*mock_login_display_,
794 ShowError(IDS_LOGIN_ERROR_GOOGLE_ACCOUNT_NOT_ALLOWED, 1, 794 ShowError(IDS_LOGIN_ERROR_GOOGLE_ACCOUNT_NOT_ALLOWED, 1,
795 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT)) 795 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT))
796 .Times(1); 796 .Times(1);
797 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)).Times(1); 797 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)).Times(1);
798 } 798 }
799
799 void ExpectLoginSuccess() { 800 void ExpectLoginSuccess() {
800 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)).Times(2); 801 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)).Times(2);
801 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)).Times(1); 802 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)).Times(1);
802 } 803 }
803 }; 804 };
804 805
805 // Tests that Active Directory online login succeeds on the Active Directory 806 // Tests that Active Directory online login succeeds on the Active Directory
806 // managed device. 807 // managed device.
807 IN_PROC_BROWSER_TEST_F(ExistingUserControllerActiveDirectoryTest, 808 IN_PROC_BROWSER_TEST_F(ExistingUserControllerActiveDirectoryTest,
808 ActiveDirectoryOnlineLogin_Success) { 809 ActiveDirectoryOnlineLogin_Success) {
809 ExpectLoginSuccess(); 810 ExpectLoginSuccess();
810 UserContext user_context(ad_account_id_); 811 UserContext user_context(ad_account_id_);
811 user_context.SetKey(Key(kPassword)); 812 user_context.SetKey(Key(kPassword));
812 user_context.SetUserIDHash(ad_account_id_.GetUserEmail()); 813 user_context.SetUserIDHash(ad_account_id_.GetUserEmail());
813 user_context.SetAuthFlow(UserContext::AUTH_FLOW_ACTIVE_DIRECTORY); 814 user_context.SetAuthFlow(UserContext::AUTH_FLOW_ACTIVE_DIRECTORY);
814 user_context.SetUserType(user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY); 815 user_context.SetUserType(user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY);
815 content::WindowedNotificationObserver profile_prepared_observer( 816 content::WindowedNotificationObserver profile_prepared_observer(
816 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 817 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
817 content::NotificationService::AllSources()); 818 content::NotificationService::AllSources());
818 existing_user_controller()->CompleteLogin(user_context); 819 existing_user_controller()->CompleteLogin(user_context);
819 820
820 profile_prepared_observer.Wait(); 821 profile_prepared_observer.Wait();
821 base::ThreadTaskRunnerHandle::Get()->PostTask( 822 base::ThreadTaskRunnerHandle::Get()->PostTask(
822 FROM_HERE, base::Bind(&ClearNotifications)); 823 FROM_HERE, base::Bind(&ClearNotifications));
823 content::RunAllPendingInMessageLoop(); 824 content::RunAllPendingInMessageLoop();
824 } 825 }
825 826
826 // Tests that Active Directory offline login fails on the Active Directory 827 // Tests that Active Directory offline login succeeds on the Active Directory
827 // managed device. 828 // managed device.
828 IN_PROC_BROWSER_TEST_F(ExistingUserControllerActiveDirectoryTest, 829 IN_PROC_BROWSER_TEST_F(ExistingUserControllerActiveDirectoryTest,
829 ActiveDirectoryOfflineLogin_Failure) { 830 ActiveDirectoryOfflineLogin_Success) {
830 ExpectLoginFailure(); 831 ExpectLoginSuccess();
831 UserContext user_context(ad_account_id_); 832 UserContext user_context(ad_account_id_);
832 user_context.SetKey(Key(kPassword)); 833 user_context.SetKey(Key(kPassword));
833 user_context.SetUserIDHash(ad_account_id_.GetUserEmail()); 834 user_context.SetUserIDHash(ad_account_id_.GetUserEmail());
834 user_context.SetUserType(user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY); 835 user_context.SetUserType(user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY);
836 content::WindowedNotificationObserver profile_prepared_observer(
837 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
838 content::NotificationService::AllSources());
835 existing_user_controller()->Login(user_context, SigninSpecifics()); 839 existing_user_controller()->Login(user_context, SigninSpecifics());
840
841 profile_prepared_observer.Wait();
842 base::ThreadTaskRunnerHandle::Get()->PostTask(
843 FROM_HERE, base::Bind(&ClearNotifications));
844 content::RunAllPendingInMessageLoop();
836 } 845 }
837 846
838 // Tests that Gaia login fails on the Active Directory managed device. 847 // Tests that Gaia login fails on the Active Directory managed device.
839 IN_PROC_BROWSER_TEST_F(ExistingUserControllerActiveDirectoryTest, 848 IN_PROC_BROWSER_TEST_F(ExistingUserControllerActiveDirectoryTest,
840 GAIAAccountLogin_Failure) { 849 GAIAAccountLogin_Failure) {
841 ExpectLoginFailure(); 850 ExpectLoginFailure();
842 UserContext user_context(gaia_account_id_); 851 UserContext user_context(gaia_account_id_);
843 user_context.SetKey(Key(kPassword)); 852 user_context.SetKey(Key(kPassword));
844 user_context.SetUserIDHash(gaia_account_id_.GetUserEmail()); 853 user_context.SetUserIDHash(gaia_account_id_.GetUserEmail());
845 existing_user_controller()->CompleteLogin(user_context); 854 existing_user_controller()->CompleteLogin(user_context);
846 } 855 }
847 856
848 } // namespace chromeos 857 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698