| 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" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 using net::test_server::BasicHttpResponse; | 76 using net::test_server::BasicHttpResponse; |
| 77 using net::test_server::HttpRequest; | 77 using net::test_server::HttpRequest; |
| 78 using net::test_server::HttpResponse; | 78 using net::test_server::HttpResponse; |
| 79 using testing::_; | 79 using testing::_; |
| 80 using testing::Return; | 80 using testing::Return; |
| 81 | 81 |
| 82 namespace chromeos { | 82 namespace chromeos { |
| 83 | 83 |
| 84 namespace { | 84 namespace { |
| 85 | 85 |
| 86 const char kTestAuthSIDCookie[] = "fake-auth-SID-cookie"; | 86 const char kGAIASIDCookieName[] = "SID"; |
| 87 const char kTestAuthLSIDCookie[] = "fake-auth-LSID-cookie"; | 87 const char kGAIALSIDCookieName[] = "LSID"; |
| 88 |
| 89 const char kTestAuthSIDCookie1[] = "fake-auth-SID-cookie-1"; |
| 90 const char kTestAuthSIDCookie2[] = "fake-auth-SID-cookie-2"; |
| 91 const char kTestAuthLSIDCookie1[] = "fake-auth-LSID-cookie-1"; |
| 92 const char kTestAuthLSIDCookie2[] = "fake-auth-LSID-cookie-2"; |
| 88 const char kTestAuthCode[] = "fake-auth-code"; | 93 const char kTestAuthCode[] = "fake-auth-code"; |
| 89 const char kTestGaiaUberToken[] = "fake-uber-token"; | 94 const char kTestGaiaUberToken[] = "fake-uber-token"; |
| 90 const char kTestAuthLoginAccessToken[] = "fake-access-token"; | 95 const char kTestAuthLoginAccessToken[] = "fake-access-token"; |
| 91 const char kTestRefreshToken[] = "fake-refresh-token"; | 96 const char kTestRefreshToken[] = "fake-refresh-token"; |
| 92 const char kTestSessionSIDCookie[] = "fake-session-SID-cookie"; | 97 const char kTestSessionSIDCookie[] = "fake-session-SID-cookie"; |
| 93 const char kTestSessionLSIDCookie[] = "fake-session-LSID-cookie"; | 98 const char kTestSessionLSIDCookie[] = "fake-session-LSID-cookie"; |
| 94 | 99 |
| 95 const char kFirstSAMLUserEmail[] = "bob@example.com"; | 100 const char kFirstSAMLUserEmail[] = "bob@example.com"; |
| 96 const char kSecondSAMLUserEmail[] = "alice@example.com"; | 101 const char kSecondSAMLUserEmail[] = "alice@example.com"; |
| 97 const char kHTTPSAMLUserEmail[] = "carol@example.com"; | 102 const char kHTTPSAMLUserEmail[] = "carol@example.com"; |
| 98 const char kNonSAMLUserEmail[] = "dan@example.com"; | 103 const char kNonSAMLUserEmail[] = "dan@example.com"; |
| 99 const char kDifferentDomainSAMLUserEmail[] = "eve@example.test"; | 104 const char kDifferentDomainSAMLUserEmail[] = "eve@example.test"; |
| 100 | 105 |
| 106 const char kSAMLIdPCookieName[] = "saml"; |
| 101 const char kSAMLIdPCookieValue1[] = "value-1"; | 107 const char kSAMLIdPCookieValue1[] = "value-1"; |
| 102 const char kSAMLIdPCookieValue2[] = "value-2"; | 108 const char kSAMLIdPCookieValue2[] = "value-2"; |
| 103 | 109 |
| 104 const char kRelayState[] = "RelayState"; | 110 const char kRelayState[] = "RelayState"; |
| 105 | 111 |
| 106 // FakeSamlIdp serves IdP auth form and the form submission. The form is | 112 // FakeSamlIdp serves IdP auth form and the form submission. The form is |
| 107 // served with the template's RelayState placeholder expanded to the real | 113 // served with the template's RelayState placeholder expanded to the real |
| 108 // RelayState parameter from request. The form submission redirects back to | 114 // RelayState parameter from request. The form submission redirects back to |
| 109 // FakeGaia with the same RelayState. | 115 // FakeGaia with the same RelayState. |
| 110 class FakeSamlIdp { | 116 class FakeSamlIdp { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 fake_gaia_.RegisterSamlUser(kSecondSAMLUserEmail, saml_idp_url); | 295 fake_gaia_.RegisterSamlUser(kSecondSAMLUserEmail, saml_idp_url); |
| 290 fake_gaia_.RegisterSamlUser( | 296 fake_gaia_.RegisterSamlUser( |
| 291 kHTTPSAMLUserEmail, | 297 kHTTPSAMLUserEmail, |
| 292 embedded_test_server()->base_url().Resolve("/SAML")); | 298 embedded_test_server()->base_url().Resolve("/SAML")); |
| 293 fake_gaia_.RegisterSamlUser(kDifferentDomainSAMLUserEmail, saml_idp_url); | 299 fake_gaia_.RegisterSamlUser(kDifferentDomainSAMLUserEmail, saml_idp_url); |
| 294 | 300 |
| 295 fake_gaia_.Initialize(); | 301 fake_gaia_.Initialize(); |
| 296 } | 302 } |
| 297 | 303 |
| 298 virtual void SetUpOnMainThread() OVERRIDE { | 304 virtual void SetUpOnMainThread() OVERRIDE { |
| 299 SetMergeSessionParams(kFirstSAMLUserEmail); | 305 SetMergeSessionParams(kFirstSAMLUserEmail, |
| 306 kTestAuthSIDCookie1, |
| 307 kTestAuthLSIDCookie1); |
| 300 | 308 |
| 301 embedded_test_server()->RegisterRequestHandler( | 309 embedded_test_server()->RegisterRequestHandler( |
| 302 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_))); | 310 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_))); |
| 303 embedded_test_server()->RegisterRequestHandler(base::Bind( | 311 embedded_test_server()->RegisterRequestHandler(base::Bind( |
| 304 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_))); | 312 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_))); |
| 305 | 313 |
| 306 // Restart the thread as the sandbox host process has already been spawned. | 314 // Restart the thread as the sandbox host process has already been spawned. |
| 307 embedded_test_server()->RestartThreadAndListen(); | 315 embedded_test_server()->RestartThreadAndListen(); |
| 308 | 316 |
| 309 login_screen_load_observer_.reset(new content::WindowedNotificationObserver( | 317 login_screen_load_observer_.reset(new content::WindowedNotificationObserver( |
| 310 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 318 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 311 content::NotificationService::AllSources())); | 319 content::NotificationService::AllSources())); |
| 312 } | 320 } |
| 313 | 321 |
| 314 virtual void TearDownOnMainThread() OVERRIDE { | 322 virtual void TearDownOnMainThread() OVERRIDE { |
| 315 // If the login display is still showing, exit gracefully. | 323 // If the login display is still showing, exit gracefully. |
| 316 if (LoginDisplayHostImpl::default_host()) { | 324 if (LoginDisplayHostImpl::default_host()) { |
| 317 base::MessageLoop::current()->PostTask(FROM_HERE, | 325 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 318 base::Bind(&chrome::AttemptExit)); | 326 base::Bind(&chrome::AttemptExit)); |
| 319 content::RunMessageLoop(); | 327 content::RunMessageLoop(); |
| 320 } | 328 } |
| 321 } | 329 } |
| 322 | 330 |
| 323 void SetMergeSessionParams(const std::string& email) { | 331 void SetMergeSessionParams(const std::string& email, |
| 332 const std::string& auth_sid_cookie, |
| 333 const std::string& auth_lsid_cookie) { |
| 324 FakeGaia::MergeSessionParams params; | 334 FakeGaia::MergeSessionParams params; |
| 325 params.auth_sid_cookie = kTestAuthSIDCookie; | 335 params.auth_sid_cookie = auth_sid_cookie; |
| 326 params.auth_lsid_cookie = kTestAuthLSIDCookie; | 336 params.auth_lsid_cookie = auth_lsid_cookie; |
| 327 params.auth_code = kTestAuthCode; | 337 params.auth_code = kTestAuthCode; |
| 328 params.refresh_token = kTestRefreshToken; | 338 params.refresh_token = kTestRefreshToken; |
| 329 params.access_token = kTestAuthLoginAccessToken; | 339 params.access_token = kTestAuthLoginAccessToken; |
| 330 params.gaia_uber_token = kTestGaiaUberToken; | 340 params.gaia_uber_token = kTestGaiaUberToken; |
| 331 params.session_sid_cookie = kTestSessionSIDCookie; | 341 params.session_sid_cookie = kTestSessionSIDCookie; |
| 332 params.session_lsid_cookie = kTestSessionLSIDCookie; | 342 params.session_lsid_cookie = kTestSessionLSIDCookie; |
| 333 params.email = email; | 343 params.email = email; |
| 334 fake_gaia_.SetMergeSessionParams(params); | 344 fake_gaia_.SetMergeSessionParams(params); |
| 335 } | 345 } |
| 336 | 346 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 ASSERT_TRUE(user); | 583 ASSERT_TRUE(user); |
| 574 EXPECT_EQ(kFirstSAMLUserEmail, user->email()); | 584 EXPECT_EQ(kFirstSAMLUserEmail, user->email()); |
| 575 } | 585 } |
| 576 | 586 |
| 577 // Verifies that if the authenticated user's e-mail address cannot be retrieved, | 587 // Verifies that if the authenticated user's e-mail address cannot be retrieved, |
| 578 // an error message is shown. | 588 // an error message is shown. |
| 579 IN_PROC_BROWSER_TEST_F(SamlTest, FailToRetrieveAutenticatedUserEmailAddress) { | 589 IN_PROC_BROWSER_TEST_F(SamlTest, FailToRetrieveAutenticatedUserEmailAddress) { |
| 580 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 590 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 581 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); | 591 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); |
| 582 | 592 |
| 583 SetMergeSessionParams(""); | 593 SetMergeSessionParams("", kTestAuthSIDCookie1, kTestAuthLSIDCookie1); |
| 584 SetSignFormField("Email", "fake_user"); | 594 SetSignFormField("Email", "fake_user"); |
| 585 SetSignFormField("Password", "fake_password"); | 595 SetSignFormField("Password", "fake_password"); |
| 586 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); | 596 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); |
| 587 | 597 |
| 588 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_LOGIN_FATAL_ERROR_NO_EMAIL), | 598 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_LOGIN_FATAL_ERROR_NO_EMAIL), |
| 589 WaitForAndGetFatalErrorMessage()); | 599 WaitForAndGetFatalErrorMessage()); |
| 590 } | 600 } |
| 591 | 601 |
| 592 // Tests the password confirm flow: show error on the first failure and | 602 // Tests the password confirm flow: show error on the first failure and |
| 593 // fatal error on the second failure. | 603 // fatal error on the second failure. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 virtual ~SAMLPolicyTest(); | 665 virtual ~SAMLPolicyTest(); |
| 656 | 666 |
| 657 // SamlTest: | 667 // SamlTest: |
| 658 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | 668 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
| 659 virtual void SetUpOnMainThread() OVERRIDE; | 669 virtual void SetUpOnMainThread() OVERRIDE; |
| 660 | 670 |
| 661 void SetSAMLOfflineSigninTimeLimitPolicy(int limit); | 671 void SetSAMLOfflineSigninTimeLimitPolicy(int limit); |
| 662 void EnableTransferSAMLCookiesPolicy(); | 672 void EnableTransferSAMLCookiesPolicy(); |
| 663 | 673 |
| 664 void ShowGAIALoginForm(); | 674 void ShowGAIALoginForm(); |
| 665 void LogInWithSAML(const std::string& user_id); | 675 void LogInWithSAML(const std::string& user_id, |
| 666 void VerifySAMLIdPCookieValue(const std::string& expected_cookie_value); | 676 const std::string& auth_sid_cookie, |
| 677 const std::string& auth_lsid_cookie); |
| 667 | 678 |
| 679 std::string GetCookieValue(const std::string& name); |
| 680 |
| 681 void GetCookies(); |
| 682 |
| 683 protected: |
| 668 void GetCookiesOnIOThread( | 684 void GetCookiesOnIOThread( |
| 669 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 685 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| 670 const base::Closure& callback); | 686 const base::Closure& callback); |
| 671 void StoreCookieList(const base::Closure& callback, | 687 void StoreCookieList(const base::Closure& callback, |
| 672 const net::CookieList& cookie_list); | 688 const net::CookieList& cookie_list); |
| 673 | 689 |
| 674 protected: | |
| 675 policy::DevicePolicyCrosTestHelper test_helper_; | 690 policy::DevicePolicyCrosTestHelper test_helper_; |
| 676 | 691 |
| 677 // FakeDBusThreadManager uses FakeSessionManagerClient. | 692 // FakeDBusThreadManager uses FakeSessionManagerClient. |
| 678 FakeDBusThreadManager* fake_dbus_thread_manager_; | 693 FakeDBusThreadManager* fake_dbus_thread_manager_; |
| 679 FakeSessionManagerClient* fake_session_manager_client_; | 694 FakeSessionManagerClient* fake_session_manager_client_; |
| 680 policy::DevicePolicyBuilder* device_policy_; | 695 policy::DevicePolicyBuilder* device_policy_; |
| 681 | 696 |
| 682 policy::MockConfigurationPolicyProvider provider_; | 697 policy::MockConfigurationPolicyProvider provider_; |
| 683 | 698 |
| 684 net::CookieList cookie_list_; | 699 net::CookieList cookie_list_; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 " window.domAutomationController.setAutomationId(0);" | 780 " window.domAutomationController.setAutomationId(0);" |
| 766 " window.domAutomationController.send('ready');" | 781 " window.domAutomationController.send('ready');" |
| 767 "});" | 782 "});" |
| 768 "$('add-user-button').click();")); | 783 "$('add-user-button').click();")); |
| 769 content::DOMMessageQueue message_queue; | 784 content::DOMMessageQueue message_queue; |
| 770 std::string message; | 785 std::string message; |
| 771 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 786 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 772 EXPECT_EQ("\"ready\"", message); | 787 EXPECT_EQ("\"ready\"", message); |
| 773 } | 788 } |
| 774 | 789 |
| 775 void SAMLPolicyTest::LogInWithSAML(const std::string& user_id) { | 790 void SAMLPolicyTest::LogInWithSAML(const std::string& user_id, |
| 791 const std::string& auth_sid_cookie, |
| 792 const std::string& auth_lsid_cookie) { |
| 776 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 793 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 777 StartSamlAndWaitForIdpPageLoad(user_id); | 794 StartSamlAndWaitForIdpPageLoad(user_id); |
| 778 | 795 |
| 779 SetMergeSessionParams(user_id); | 796 SetMergeSessionParams(user_id, auth_sid_cookie, auth_lsid_cookie); |
| 780 SetSignFormField("Email", "fake_user"); | 797 SetSignFormField("Email", "fake_user"); |
| 781 SetSignFormField("Password", "fake_password"); | 798 SetSignFormField("Password", "fake_password"); |
| 782 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); | 799 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); |
| 783 | 800 |
| 784 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); | 801 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); |
| 785 | 802 |
| 786 SendConfirmPassword("fake_password"); | 803 SendConfirmPassword("fake_password"); |
| 787 content::WindowedNotificationObserver( | 804 content::WindowedNotificationObserver( |
| 788 chrome::NOTIFICATION_SESSION_STARTED, | 805 chrome::NOTIFICATION_SESSION_STARTED, |
| 789 content::NotificationService::AllSources()).Wait(); | 806 content::NotificationService::AllSources()).Wait(); |
| 790 } | 807 } |
| 791 | 808 |
| 792 void SAMLPolicyTest::VerifySAMLIdPCookieValue( | 809 std::string SAMLPolicyTest::GetCookieValue(const std::string& name) { |
| 793 const std::string& expected_cookie_value) { | 810 for (net::CookieList::const_iterator it = cookie_list_.begin(); |
| 811 it != cookie_list_.end(); ++it) { |
| 812 if (it->Name() == name) |
| 813 return it->Value(); |
| 814 } |
| 815 return std::string(); |
| 816 } |
| 817 |
| 818 void SAMLPolicyTest::GetCookies() { |
| 794 Profile* profile =chromeos::ProfileHelper::Get()->GetProfileByUser( | 819 Profile* profile =chromeos::ProfileHelper::Get()->GetProfileByUser( |
| 795 UserManager::Get()->GetActiveUser()); | 820 UserManager::Get()->GetActiveUser()); |
| 796 ASSERT_TRUE(profile); | 821 ASSERT_TRUE(profile); |
| 797 base::RunLoop run_loop; | 822 base::RunLoop run_loop; |
| 798 content::BrowserThread::PostTask( | 823 content::BrowserThread::PostTask( |
| 799 content::BrowserThread::IO, | 824 content::BrowserThread::IO, |
| 800 FROM_HERE, | 825 FROM_HERE, |
| 801 base::Bind(&SAMLPolicyTest::GetCookiesOnIOThread, | 826 base::Bind(&SAMLPolicyTest::GetCookiesOnIOThread, |
| 802 base::Unretained(this), | 827 base::Unretained(this), |
| 803 scoped_refptr<net::URLRequestContextGetter>( | 828 scoped_refptr<net::URLRequestContextGetter>( |
| 804 profile->GetRequestContext()), | 829 profile->GetRequestContext()), |
| 805 run_loop.QuitClosure())); | 830 run_loop.QuitClosure())); |
| 806 run_loop.Run(); | 831 run_loop.Run(); |
| 807 | |
| 808 net::CanonicalCookie const* saml_cookie = NULL; | |
| 809 for (net::CookieList::const_iterator it = cookie_list_.begin(); | |
| 810 it != cookie_list_.end(); ++it) { | |
| 811 if (it->Name() == "saml") { | |
| 812 saml_cookie = &*it; | |
| 813 break; | |
| 814 } | |
| 815 } | |
| 816 ASSERT_TRUE(saml_cookie); | |
| 817 EXPECT_EQ(expected_cookie_value, saml_cookie->Value()); | |
| 818 } | 832 } |
| 819 | 833 |
| 820 void SAMLPolicyTest::GetCookiesOnIOThread( | 834 void SAMLPolicyTest::GetCookiesOnIOThread( |
| 821 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 835 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| 822 const base::Closure& callback) { | 836 const base::Closure& callback) { |
| 823 request_context->GetURLRequestContext()->cookie_store()-> | 837 request_context->GetURLRequestContext()->cookie_store()-> |
| 824 GetCookieMonster()->GetAllCookiesAsync(base::Bind( | 838 GetCookieMonster()->GetAllCookiesAsync(base::Bind( |
| 825 &SAMLPolicyTest::StoreCookieList, | 839 &SAMLPolicyTest::StoreCookieList, |
| 826 base::Unretained(this), | 840 base::Unretained(this), |
| 827 callback)); | 841 callback)); |
| 828 } | 842 } |
| 829 | 843 |
| 830 void SAMLPolicyTest::StoreCookieList( | 844 void SAMLPolicyTest::StoreCookieList( |
| 831 const base::Closure& callback, | 845 const base::Closure& callback, |
| 832 const net::CookieList& cookie_list) { | 846 const net::CookieList& cookie_list) { |
| 833 cookie_list_ = cookie_list; | 847 cookie_list_ = cookie_list; |
| 834 content::BrowserThread::PostTask(content::BrowserThread::UI, | 848 content::BrowserThread::PostTask(content::BrowserThread::UI, |
| 835 FROM_HERE, | 849 FROM_HERE, |
| 836 callback); | 850 callback); |
| 837 } | 851 } |
| 838 | 852 |
| 839 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, DISABLED_PRE_NoSAML) { | 853 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_NoSAML) { |
| 840 // Set the offline login time limit for SAML users to zero. | 854 // Set the offline login time limit for SAML users to zero. |
| 841 SetSAMLOfflineSigninTimeLimitPolicy(0); | 855 SetSAMLOfflineSigninTimeLimitPolicy(0); |
| 842 | 856 |
| 843 WaitForSigninScreen(); | 857 WaitForSigninScreen(); |
| 844 | 858 |
| 845 // Log in without SAML. | 859 // Log in without SAML. |
| 846 GetLoginDisplay()->ShowSigninScreenForCreds(kNonSAMLUserEmail, "password"); | 860 GetLoginDisplay()->ShowSigninScreenForCreds(kNonSAMLUserEmail, "password"); |
| 847 | 861 |
| 848 content::WindowedNotificationObserver( | 862 content::WindowedNotificationObserver( |
| 849 chrome::NOTIFICATION_SESSION_STARTED, | 863 chrome::NOTIFICATION_SESSION_STARTED, |
| 850 content::NotificationService::AllSources()).Wait(); | 864 content::NotificationService::AllSources()).Wait(); |
| 851 } | 865 } |
| 852 | 866 |
| 853 // Verifies that the offline login time limit does not affect a user who | 867 // Verifies that the offline login time limit does not affect a user who |
| 854 // authenticated without SAML. | 868 // authenticated without SAML. |
| 855 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, DISABLED_NoSAML) { | 869 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, NoSAML) { |
| 856 login_screen_load_observer_->Wait(); | 870 login_screen_load_observer_->Wait(); |
| 857 // Verify that offline login is allowed. | 871 // Verify that offline login is allowed. |
| 858 JsExpect("window.getComputedStyle(document.querySelector(" | 872 JsExpect("window.getComputedStyle(document.querySelector(" |
| 859 " '#pod-row .signin-button-container')).display == 'none'"); | 873 " '#pod-row .signin-button-container')).display == 'none'"); |
| 860 } | 874 } |
| 861 | 875 |
| 862 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_SAMLNoLimit) { | 876 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_SAMLNoLimit) { |
| 863 // Remove the offline login time limit for SAML users. | 877 // Remove the offline login time limit for SAML users. |
| 864 SetSAMLOfflineSigninTimeLimitPolicy(-1); | 878 SetSAMLOfflineSigninTimeLimitPolicy(-1); |
| 865 | 879 |
| 866 LogInWithSAML(kFirstSAMLUserEmail); | 880 LogInWithSAML(kFirstSAMLUserEmail, kTestAuthSIDCookie1, kTestAuthLSIDCookie1); |
| 867 } | 881 } |
| 868 | 882 |
| 869 // Verifies that when no offline login time limit is set, a user who | 883 // Verifies that when no offline login time limit is set, a user who |
| 870 // authenticated with SAML is allowed to log in offline. | 884 // authenticated with SAML is allowed to log in offline. |
| 871 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLNoLimit) { | 885 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLNoLimit) { |
| 872 login_screen_load_observer_->Wait(); | 886 login_screen_load_observer_->Wait(); |
| 873 // Verify that offline login is allowed. | 887 // Verify that offline login is allowed. |
| 874 JsExpect("window.getComputedStyle(document.querySelector(" | 888 JsExpect("window.getComputedStyle(document.querySelector(" |
| 875 " '#pod-row .signin-button-container')).display == 'none'"); | 889 " '#pod-row .signin-button-container')).display == 'none'"); |
| 876 } | 890 } |
| 877 | 891 |
| 878 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_SAMLZeroLimit) { | 892 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_SAMLZeroLimit) { |
| 879 // Set the offline login time limit for SAML users to zero. | 893 // Set the offline login time limit for SAML users to zero. |
| 880 SetSAMLOfflineSigninTimeLimitPolicy(0); | 894 SetSAMLOfflineSigninTimeLimitPolicy(0); |
| 881 | 895 |
| 882 LogInWithSAML(kFirstSAMLUserEmail); | 896 LogInWithSAML(kFirstSAMLUserEmail, kTestAuthSIDCookie1, kTestAuthLSIDCookie1); |
| 883 } | 897 } |
| 884 | 898 |
| 885 // Verifies that when the offline login time limit is exceeded for a user who | 899 // Verifies that when the offline login time limit is exceeded for a user who |
| 886 // authenticated via SAML, that user is forced to log in online the next time. | 900 // authenticated via SAML, that user is forced to log in online the next time. |
| 887 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLZeroLimit) { | 901 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLZeroLimit) { |
| 888 login_screen_load_observer_->Wait(); | 902 login_screen_load_observer_->Wait(); |
| 889 // Verify that offline login is not allowed. | 903 // Verify that offline login is not allowed. |
| 890 JsExpect("window.getComputedStyle(document.querySelector(" | 904 JsExpect("window.getComputedStyle(document.querySelector(" |
| 891 " '#pod-row .signin-button-container')).display != 'none'"); | 905 " '#pod-row .signin-button-container')).display != 'none'"); |
| 892 } | 906 } |
| 893 | 907 |
| 894 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, DISABLED_PRE_PRE_TransferCookiesAffiliate
d) { | 908 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_PRE_TransferCookiesAffiliated) { |
| 895 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue1); | 909 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue1); |
| 896 LogInWithSAML(kFirstSAMLUserEmail); | 910 LogInWithSAML(kFirstSAMLUserEmail, kTestAuthSIDCookie1, kTestAuthLSIDCookie1); |
| 897 VerifySAMLIdPCookieValue(kSAMLIdPCookieValue1); | 911 |
| 912 GetCookies(); |
| 913 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
| 914 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
| 915 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
| 898 } | 916 } |
| 899 | 917 |
| 900 // Verifies that when the DeviceTransferSAMLCookies policy is not enabled, SAML | 918 // Verifies that when the DeviceTransferSAMLCookies policy is not enabled, SAML |
| 901 // IdP cookies are not transferred to a user's profile on subsequent login, even | 919 // IdP cookies are not transferred to a user's profile on subsequent login, even |
| 902 // if the user belongs to the domain that the device is enrolled into. | 920 // if the user belongs to the domain that the device is enrolled into. Also |
| 903 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, DISABLED_PRE_TransferCookiesAffiliated) { | 921 // verifies that GAIA cookies are not transferred. |
| 922 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_TransferCookiesAffiliated) { |
| 904 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); | 923 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); |
| 905 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 924 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 906 ShowGAIALoginForm(); | 925 ShowGAIALoginForm(); |
| 926 LogInWithSAML(kFirstSAMLUserEmail, kTestAuthSIDCookie2, kTestAuthLSIDCookie2); |
| 907 | 927 |
| 908 LogInWithSAML(kFirstSAMLUserEmail); | 928 GetCookies(); |
| 909 VerifySAMLIdPCookieValue(kSAMLIdPCookieValue1); | 929 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
| 930 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
| 931 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
| 910 } | 932 } |
| 911 | 933 |
| 912 // Verifies that when the DeviceTransferSAMLCookies policy is enabled, SAML IdP | 934 // Verifies that when the DeviceTransferSAMLCookies policy is enabled, SAML IdP |
| 913 // cookies are transferred to a user's profile on subsequent login when the user | 935 // cookies are transferred to a user's profile on subsequent login when the user |
| 914 // belongs to the domain that the device is enrolled into. | 936 // belongs to the domain that the device is enrolled into. Also verifies that |
| 915 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, DISABLED_TransferCookiesAffiliated) { | 937 // GAIA cookies are not transferred. |
| 938 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, TransferCookiesAffiliated) { |
| 916 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); | 939 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); |
| 917 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 940 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 918 ShowGAIALoginForm(); | 941 ShowGAIALoginForm(); |
| 919 | 942 |
| 920 EnableTransferSAMLCookiesPolicy(); | 943 EnableTransferSAMLCookiesPolicy(); |
| 944 LogInWithSAML(kFirstSAMLUserEmail, kTestAuthSIDCookie2, kTestAuthLSIDCookie2); |
| 921 | 945 |
| 922 LogInWithSAML(kFirstSAMLUserEmail); | 946 GetCookies(); |
| 923 VerifySAMLIdPCookieValue(kSAMLIdPCookieValue2); | 947 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
| 948 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
| 949 EXPECT_EQ(kSAMLIdPCookieValue2, GetCookieValue(kSAMLIdPCookieName)); |
| 924 } | 950 } |
| 925 | 951 |
| 926 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_TransferCookiesUnaffiliated) { | 952 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_TransferCookiesUnaffiliated) { |
| 927 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue1); | 953 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue1); |
| 928 LogInWithSAML(kDifferentDomainSAMLUserEmail); | 954 LogInWithSAML(kDifferentDomainSAMLUserEmail, |
| 929 VerifySAMLIdPCookieValue(kSAMLIdPCookieValue1); | 955 kTestAuthSIDCookie1, |
| 956 kTestAuthLSIDCookie1); |
| 957 |
| 958 GetCookies(); |
| 959 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
| 960 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
| 961 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
| 930 } | 962 } |
| 931 | 963 |
| 932 // Verifies that even if the DeviceTransferSAMLCookies policy is enabled, SAML | 964 // Verifies that even if the DeviceTransferSAMLCookies policy is enabled, SAML |
| 933 // IdP are not transferred to a user's profile on subsequent login if the user | 965 // IdP are not transferred to a user's profile on subsequent login if the user |
| 934 // does not belong to the domain that the device is enrolled into. | 966 // does not belong to the domain that the device is enrolled into. Also verifies |
| 967 // that GAIA cookies are not transferred. |
| 935 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, TransferCookiesUnaffiliated) { | 968 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, TransferCookiesUnaffiliated) { |
| 936 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); | 969 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); |
| 937 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 970 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 938 ShowGAIALoginForm(); | 971 ShowGAIALoginForm(); |
| 939 | 972 |
| 940 EnableTransferSAMLCookiesPolicy(); | 973 EnableTransferSAMLCookiesPolicy(); |
| 974 LogInWithSAML(kDifferentDomainSAMLUserEmail, |
| 975 kTestAuthSIDCookie1, |
| 976 kTestAuthLSIDCookie1); |
| 941 | 977 |
| 942 LogInWithSAML(kDifferentDomainSAMLUserEmail); | 978 GetCookies(); |
| 943 VerifySAMLIdPCookieValue(kSAMLIdPCookieValue1); | 979 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
| 980 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
| 981 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
| 944 } | 982 } |
| 945 | 983 |
| 946 } // namespace chromeos | 984 } // namespace chromeos |
| OLD | NEW |