| OLD | NEW |
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 22 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 23 #include "chrome/browser/chromeos/login/test/https_forwarder.h" | 23 #include "chrome/browser/chromeos/login/test/https_forwarder.h" |
| 24 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" | 24 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
| 25 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 25 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 26 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 26 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 27 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
| 28 #include "chrome/browser/chromeos/login/wizard_controller.h" | 27 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 29 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 28 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
| 30 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 29 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 31 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 30 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 32 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 31 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 33 #include "chrome/browser/chromeos/settings/cros_settings.h" | 32 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 34 #include "chrome/browser/lifetime/application_lifetime.h" | 33 #include "chrome/browser/lifetime/application_lifetime.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" | 35 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" |
| 37 #include "chrome/common/chrome_paths.h" | 36 #include "chrome/common/chrome_paths.h" |
| 38 #include "chrome/common/chrome_switches.h" | 37 #include "chrome/common/chrome_switches.h" |
| 39 #include "chrome/grit/generated_resources.h" | 38 #include "chrome/grit/generated_resources.h" |
| 40 #include "chrome/test/base/in_process_browser_test.h" | 39 #include "chrome/test/base/in_process_browser_test.h" |
| 41 #include "chromeos/chromeos_switches.h" | 40 #include "chromeos/chromeos_switches.h" |
| 42 #include "chromeos/dbus/dbus_thread_manager.h" | 41 #include "chromeos/dbus/dbus_thread_manager.h" |
| 43 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 42 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
| 44 #include "chromeos/dbus/fake_session_manager_client.h" | 43 #include "chromeos/dbus/fake_session_manager_client.h" |
| 45 #include "chromeos/dbus/session_manager_client.h" | 44 #include "chromeos/dbus/session_manager_client.h" |
| 46 #include "chromeos/settings/cros_settings_names.h" | 45 #include "chromeos/settings/cros_settings_names.h" |
| 47 #include "components/policy/core/browser/browser_policy_connector.h" | 46 #include "components/policy/core/browser/browser_policy_connector.h" |
| 48 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 47 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
| 49 #include "components/policy/core/common/policy_map.h" | 48 #include "components/policy/core/common/policy_map.h" |
| 50 #include "components/policy/core/common/policy_types.h" | 49 #include "components/policy/core/common/policy_types.h" |
| 51 #include "components/user_manager/user.h" | 50 #include "components/user_manager/user.h" |
| 51 #include "components/user_manager/user_manager.h" |
| 52 #include "content/public/browser/browser_thread.h" | 52 #include "content/public/browser/browser_thread.h" |
| 53 #include "content/public/browser/web_contents.h" | 53 #include "content/public/browser/web_contents.h" |
| 54 #include "content/public/test/browser_test_utils.h" | 54 #include "content/public/test/browser_test_utils.h" |
| 55 #include "content/public/test/test_utils.h" | 55 #include "content/public/test/test_utils.h" |
| 56 #include "google_apis/gaia/fake_gaia.h" | 56 #include "google_apis/gaia/fake_gaia.h" |
| 57 #include "google_apis/gaia/gaia_switches.h" | 57 #include "google_apis/gaia/gaia_switches.h" |
| 58 #include "net/base/url_util.h" | 58 #include "net/base/url_util.h" |
| 59 #include "net/cookies/canonical_cookie.h" | 59 #include "net/cookies/canonical_cookie.h" |
| 60 #include "net/cookies/cookie_monster.h" | 60 #include "net/cookies/cookie_monster.h" |
| 61 #include "net/cookies/cookie_store.h" | 61 #include "net/cookies/cookie_store.h" |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 SetSignFormField("Email", "fake_user"); | 573 SetSignFormField("Email", "fake_user"); |
| 574 SetSignFormField("Password", "fake_password"); | 574 SetSignFormField("Password", "fake_password"); |
| 575 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); | 575 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); |
| 576 | 576 |
| 577 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); | 577 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); |
| 578 | 578 |
| 579 SendConfirmPassword("fake_password"); | 579 SendConfirmPassword("fake_password"); |
| 580 content::WindowedNotificationObserver( | 580 content::WindowedNotificationObserver( |
| 581 chrome::NOTIFICATION_SESSION_STARTED, | 581 chrome::NOTIFICATION_SESSION_STARTED, |
| 582 content::NotificationService::AllSources()).Wait(); | 582 content::NotificationService::AllSources()).Wait(); |
| 583 const user_manager::User* user = UserManager::Get()->GetActiveUser(); | 583 const user_manager::User* user = |
| 584 user_manager::UserManager::Get()->GetActiveUser(); |
| 584 ASSERT_TRUE(user); | 585 ASSERT_TRUE(user); |
| 585 EXPECT_EQ(kFirstSAMLUserEmail, user->email()); | 586 EXPECT_EQ(kFirstSAMLUserEmail, user->email()); |
| 586 } | 587 } |
| 587 | 588 |
| 588 // Verifies that if the authenticated user's e-mail address cannot be retrieved, | 589 // Verifies that if the authenticated user's e-mail address cannot be retrieved, |
| 589 // an error message is shown. | 590 // an error message is shown. |
| 590 IN_PROC_BROWSER_TEST_F(SamlTest, FailToRetrieveAutenticatedUserEmailAddress) { | 591 IN_PROC_BROWSER_TEST_F(SamlTest, FailToRetrieveAutenticatedUserEmailAddress) { |
| 591 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 592 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 592 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); | 593 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); |
| 593 | 594 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 // Initialize user policy. | 731 // Initialize user policy. |
| 731 EXPECT_CALL(provider_, IsInitializationComplete(_)) | 732 EXPECT_CALL(provider_, IsInitializationComplete(_)) |
| 732 .WillRepeatedly(Return(true)); | 733 .WillRepeatedly(Return(true)); |
| 733 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); | 734 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); |
| 734 } | 735 } |
| 735 | 736 |
| 736 void SAMLPolicyTest::SetUpOnMainThread() { | 737 void SAMLPolicyTest::SetUpOnMainThread() { |
| 737 SamlTest::SetUpOnMainThread(); | 738 SamlTest::SetUpOnMainThread(); |
| 738 | 739 |
| 739 // Pretend that the test users' OAuth tokens are valid. | 740 // Pretend that the test users' OAuth tokens are valid. |
| 740 UserManager::Get()->SaveUserOAuthStatus( | 741 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
| 741 kFirstSAMLUserEmail, user_manager::User::OAUTH2_TOKEN_STATUS_VALID); | 742 kFirstSAMLUserEmail, user_manager::User::OAUTH2_TOKEN_STATUS_VALID); |
| 742 UserManager::Get()->SaveUserOAuthStatus( | 743 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
| 743 kNonSAMLUserEmail, user_manager::User::OAUTH2_TOKEN_STATUS_VALID); | 744 kNonSAMLUserEmail, user_manager::User::OAUTH2_TOKEN_STATUS_VALID); |
| 744 UserManager::Get()->SaveUserOAuthStatus( | 745 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
| 745 kDifferentDomainSAMLUserEmail, | 746 kDifferentDomainSAMLUserEmail, |
| 746 user_manager::User::OAUTH2_TOKEN_STATUS_VALID); | 747 user_manager::User::OAUTH2_TOKEN_STATUS_VALID); |
| 747 } | 748 } |
| 748 | 749 |
| 749 void SAMLPolicyTest::SetSAMLOfflineSigninTimeLimitPolicy(int limit) { | 750 void SAMLPolicyTest::SetSAMLOfflineSigninTimeLimitPolicy(int limit) { |
| 750 policy::PolicyMap user_policy; | 751 policy::PolicyMap user_policy; |
| 751 user_policy.Set(policy::key::kSAMLOfflineSigninTimeLimit, | 752 user_policy.Set(policy::key::kSAMLOfflineSigninTimeLimit, |
| 752 policy::POLICY_LEVEL_MANDATORY, | 753 policy::POLICY_LEVEL_MANDATORY, |
| 753 policy::POLICY_SCOPE_USER, | 754 policy::POLICY_SCOPE_USER, |
| 754 new base::FundamentalValue(limit), | 755 new base::FundamentalValue(limit), |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 for (net::CookieList::const_iterator it = cookie_list_.begin(); | 812 for (net::CookieList::const_iterator it = cookie_list_.begin(); |
| 812 it != cookie_list_.end(); ++it) { | 813 it != cookie_list_.end(); ++it) { |
| 813 if (it->Name() == name) | 814 if (it->Name() == name) |
| 814 return it->Value(); | 815 return it->Value(); |
| 815 } | 816 } |
| 816 return std::string(); | 817 return std::string(); |
| 817 } | 818 } |
| 818 | 819 |
| 819 void SAMLPolicyTest::GetCookies() { | 820 void SAMLPolicyTest::GetCookies() { |
| 820 Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe( | 821 Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe( |
| 821 UserManager::Get()->GetActiveUser()); | 822 user_manager::UserManager::Get()->GetActiveUser()); |
| 822 ASSERT_TRUE(profile); | 823 ASSERT_TRUE(profile); |
| 823 base::RunLoop run_loop; | 824 base::RunLoop run_loop; |
| 824 content::BrowserThread::PostTask( | 825 content::BrowserThread::PostTask( |
| 825 content::BrowserThread::IO, | 826 content::BrowserThread::IO, |
| 826 FROM_HERE, | 827 FROM_HERE, |
| 827 base::Bind(&SAMLPolicyTest::GetCookiesOnIOThread, | 828 base::Bind(&SAMLPolicyTest::GetCookiesOnIOThread, |
| 828 base::Unretained(this), | 829 base::Unretained(this), |
| 829 scoped_refptr<net::URLRequestContextGetter>( | 830 scoped_refptr<net::URLRequestContextGetter>( |
| 830 profile->GetRequestContext()), | 831 profile->GetRequestContext()), |
| 831 run_loop.QuitClosure())); | 832 run_loop.QuitClosure())); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 kTestAuthSIDCookie1, | 977 kTestAuthSIDCookie1, |
| 977 kTestAuthLSIDCookie1); | 978 kTestAuthLSIDCookie1); |
| 978 | 979 |
| 979 GetCookies(); | 980 GetCookies(); |
| 980 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); | 981 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
| 981 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); | 982 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
| 982 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); | 983 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
| 983 } | 984 } |
| 984 | 985 |
| 985 } // namespace chromeos | 986 } // namespace chromeos |
| OLD | NEW |