Chromium Code Reviews| 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/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 namespace { | 84 namespace { |
| 85 | 85 |
| 86 const char kGAIASIDCookieName[] = "SID"; | 86 const char kGAIASIDCookieName[] = "SID"; |
| 87 const char kGAIALSIDCookieName[] = "LSID"; | 87 const char kGAIALSIDCookieName[] = "LSID"; |
| 88 | 88 |
| 89 const char kTestAuthSIDCookie1[] = "fake-auth-SID-cookie-1"; | 89 const char kTestAuthSIDCookie1[] = "fake-auth-SID-cookie-1"; |
| 90 const char kTestAuthSIDCookie2[] = "fake-auth-SID-cookie-2"; | 90 const char kTestAuthSIDCookie2[] = "fake-auth-SID-cookie-2"; |
| 91 const char kTestAuthLSIDCookie1[] = "fake-auth-LSID-cookie-1"; | 91 const char kTestAuthLSIDCookie1[] = "fake-auth-LSID-cookie-1"; |
| 92 const char kTestAuthLSIDCookie2[] = "fake-auth-LSID-cookie-2"; | 92 const char kTestAuthLSIDCookie2[] = "fake-auth-LSID-cookie-2"; |
| 93 | 93 |
| 94 const char kTestGaiaId[] = "12345"; | |
| 95 | |
| 94 const char kFirstSAMLUserEmail[] = "bob@example.com"; | 96 const char kFirstSAMLUserEmail[] = "bob@example.com"; |
| 95 const char kSecondSAMLUserEmail[] = "alice@example.com"; | 97 const char kSecondSAMLUserEmail[] = "alice@example.com"; |
| 96 const char kHTTPSAMLUserEmail[] = "carol@example.com"; | 98 const char kHTTPSAMLUserEmail[] = "carol@example.com"; |
| 97 const char kNonSAMLUserEmail[] = "dan@example.com"; | 99 const char kNonSAMLUserEmail[] = "dan@example.com"; |
| 98 const char kDifferentDomainSAMLUserEmail[] = "eve@example.test"; | 100 const char kDifferentDomainSAMLUserEmail[] = "eve@example.test"; |
| 99 | 101 |
| 100 const char kSAMLIdPCookieName[] = "saml"; | 102 const char kSAMLIdPCookieName[] = "saml"; |
| 101 const char kSAMLIdPCookieValue1[] = "value-1"; | 103 const char kSAMLIdPCookieValue1[] = "value-1"; |
| 102 const char kSAMLIdPCookieValue2[] = "value-2"; | 104 const char kSAMLIdPCookieValue2[] = "value-2"; |
| 103 | 105 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 fake_gaia_.RegisterSamlUser(kSecondSAMLUserEmail, saml_idp_url); | 291 fake_gaia_.RegisterSamlUser(kSecondSAMLUserEmail, saml_idp_url); |
| 290 fake_gaia_.RegisterSamlUser( | 292 fake_gaia_.RegisterSamlUser( |
| 291 kHTTPSAMLUserEmail, | 293 kHTTPSAMLUserEmail, |
| 292 embedded_test_server()->base_url().Resolve("/SAML")); | 294 embedded_test_server()->base_url().Resolve("/SAML")); |
| 293 fake_gaia_.RegisterSamlUser(kDifferentDomainSAMLUserEmail, saml_idp_url); | 295 fake_gaia_.RegisterSamlUser(kDifferentDomainSAMLUserEmail, saml_idp_url); |
| 294 | 296 |
| 295 fake_gaia_.Initialize(); | 297 fake_gaia_.Initialize(); |
| 296 } | 298 } |
| 297 | 299 |
| 298 virtual void SetUpOnMainThread() override { | 300 virtual void SetUpOnMainThread() override { |
| 299 fake_gaia_.SetFakeMergeSessionParams(kFirstSAMLUserEmail, | 301 fake_gaia_.SetFakeMergeSessionParams(kTestGaiaId, |
| 302 kFirstSAMLUserEmail, | |
| 300 kTestAuthSIDCookie1, | 303 kTestAuthSIDCookie1, |
| 301 kTestAuthLSIDCookie1); | 304 kTestAuthLSIDCookie1); |
| 302 | 305 |
| 303 embedded_test_server()->RegisterRequestHandler( | 306 embedded_test_server()->RegisterRequestHandler( |
| 304 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_))); | 307 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_))); |
| 305 embedded_test_server()->RegisterRequestHandler(base::Bind( | 308 embedded_test_server()->RegisterRequestHandler(base::Bind( |
| 306 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_))); | 309 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_))); |
| 307 | 310 |
| 308 // Restart the thread as the sandbox host process has already been spawned. | 311 // Restart the thread as the sandbox host process has already been spawned. |
| 309 embedded_test_server()->RestartThreadAndListen(); | 312 embedded_test_server()->RestartThreadAndListen(); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 535 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_LOGIN_FATAL_ERROR_NO_PASSWORD), | 538 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_LOGIN_FATAL_ERROR_NO_PASSWORD), |
| 536 WaitForAndGetFatalErrorMessage()); | 539 WaitForAndGetFatalErrorMessage()); |
| 537 } | 540 } |
| 538 | 541 |
| 539 // Types |bob@example.com| into the GAIA login form but then authenticates as | 542 // Types |bob@example.com| into the GAIA login form but then authenticates as |
| 540 // |alice@example.com| via SAML. Verifies that the logged-in user is correctly | 543 // |alice@example.com| via SAML. Verifies that the logged-in user is correctly |
| 541 // identified as Alice. | 544 // identified as Alice. |
| 542 IN_PROC_BROWSER_TEST_F(SamlTest, UseAutenticatedUserEmailAddress) { | 545 IN_PROC_BROWSER_TEST_F(SamlTest, UseAutenticatedUserEmailAddress) { |
| 543 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 546 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 544 // Type |bob@example.com| into the GAIA login form. | 547 // Type |bob@example.com| into the GAIA login form. |
| 545 StartSamlAndWaitForIdpPageLoad(kSecondSAMLUserEmail); | 548 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); |
| 546 | 549 |
| 547 // Authenticate as alice@example.com via SAML (the |Email| provided here is | 550 // Authenticate as alice@example.com via SAML (the |Email| provided here is |
| 548 // irrelevant - the authenticated user's e-mail address that FakeGAIA | 551 // irrelevant - the authenticated user's e-mail address that FakeGAIA |
| 549 // reports was set via |SetFakeMergeSessionParams|. | 552 // reports was set via |SetFakeMergeSessionParams|. |
| 550 SetSignFormField("Email", "fake_user"); | 553 SetSignFormField("Email", "fake_user"); |
| 551 SetSignFormField("Password", "fake_password"); | 554 SetSignFormField("Password", "fake_password"); |
| 552 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); | 555 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); |
| 553 | 556 |
| 554 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); | 557 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); |
| 555 | 558 |
| 556 SendConfirmPassword("fake_password"); | 559 SendConfirmPassword("fake_password"); |
| 557 content::WindowedNotificationObserver( | 560 content::WindowedNotificationObserver( |
| 558 chrome::NOTIFICATION_SESSION_STARTED, | 561 chrome::NOTIFICATION_SESSION_STARTED, |
| 559 content::NotificationService::AllSources()).Wait(); | 562 content::NotificationService::AllSources()).Wait(); |
| 560 const user_manager::User* user = | 563 const user_manager::User* user = |
| 561 user_manager::UserManager::Get()->GetActiveUser(); | 564 user_manager::UserManager::Get()->GetActiveUser(); |
| 562 ASSERT_TRUE(user); | 565 ASSERT_TRUE(user); |
| 563 EXPECT_EQ(kFirstSAMLUserEmail, user->email()); | 566 EXPECT_EQ(kFirstSAMLUserEmail, user->email()); |
|
bartfab (slow)
2014/10/17 09:54:55
This test actually has even more typos in it :(.
Roger Tawa OOO till Jul 10th
2014/10/20 16:04:00
This test is even more complex than that. It uses
bartfab (slow)
2014/10/21 14:47:46
Agreed.
| |
| 564 } | 567 } |
| 565 | 568 |
| 566 // Verifies that if the authenticated user's e-mail address cannot be retrieved, | 569 // Verifies that if the authenticated user's e-mail address cannot be retrieved, |
| 567 // an error message is shown. | 570 // an error message is shown. |
| 568 IN_PROC_BROWSER_TEST_F(SamlTest, FailToRetrieveAutenticatedUserEmailAddress) { | 571 IN_PROC_BROWSER_TEST_F(SamlTest, FailToRetrieveAutenticatedUserEmailAddress) { |
| 569 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 572 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 573 fake_gaia_.SetFakeMergeSessionParams( | |
|
bartfab (slow)
2014/10/17 09:54:55
Once FakeGaia has been fixed to return the e-mail
Roger Tawa OOO till Jul 10th
2014/10/20 16:04:00
Done.
| |
| 574 "", "", kTestAuthSIDCookie1, kTestAuthLSIDCookie1); | |
| 575 | |
| 570 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); | 576 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); |
| 571 | 577 |
| 572 fake_gaia_.SetFakeMergeSessionParams( | |
| 573 "", kTestAuthSIDCookie1, kTestAuthLSIDCookie1); | |
| 574 SetSignFormField("Email", "fake_user"); | 578 SetSignFormField("Email", "fake_user"); |
| 575 SetSignFormField("Password", "fake_password"); | 579 SetSignFormField("Password", "fake_password"); |
| 576 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); | 580 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); |
| 577 | 581 |
| 578 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_LOGIN_FATAL_ERROR_NO_EMAIL), | 582 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_LOGIN_FATAL_ERROR_NO_EMAIL), |
| 579 WaitForAndGetFatalErrorMessage()); | 583 WaitForAndGetFatalErrorMessage()); |
| 580 } | 584 } |
| 581 | 585 |
| 582 // Tests the password confirm flow: show error on the first failure and | 586 // Tests the password confirm flow: show error on the first failure and |
| 583 // fatal error on the second failure. | 587 // fatal error on the second failure. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 virtual ~SAMLPolicyTest(); | 649 virtual ~SAMLPolicyTest(); |
| 646 | 650 |
| 647 // SamlTest: | 651 // SamlTest: |
| 648 virtual void SetUpInProcessBrowserTestFixture() override; | 652 virtual void SetUpInProcessBrowserTestFixture() override; |
| 649 virtual void SetUpOnMainThread() override; | 653 virtual void SetUpOnMainThread() override; |
| 650 | 654 |
| 651 void SetSAMLOfflineSigninTimeLimitPolicy(int limit); | 655 void SetSAMLOfflineSigninTimeLimitPolicy(int limit); |
| 652 void EnableTransferSAMLCookiesPolicy(); | 656 void EnableTransferSAMLCookiesPolicy(); |
| 653 | 657 |
| 654 void ShowGAIALoginForm(); | 658 void ShowGAIALoginForm(); |
| 655 void LogInWithSAML(const std::string& user_id, | 659 void LogInWithSAML(const std::string& gaia_id, |
| 660 const std::string& user_id, | |
| 656 const std::string& auth_sid_cookie, | 661 const std::string& auth_sid_cookie, |
| 657 const std::string& auth_lsid_cookie); | 662 const std::string& auth_lsid_cookie); |
| 658 | 663 |
| 659 std::string GetCookieValue(const std::string& name); | 664 std::string GetCookieValue(const std::string& name); |
| 660 | 665 |
| 661 void GetCookies(); | 666 void GetCookies(); |
| 662 | 667 |
| 663 protected: | 668 protected: |
| 664 void GetCookiesOnIOThread( | 669 void GetCookiesOnIOThread( |
| 665 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 670 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 " window.domAutomationController.setAutomationId(0);" | 762 " window.domAutomationController.setAutomationId(0);" |
| 758 " window.domAutomationController.send('ready');" | 763 " window.domAutomationController.send('ready');" |
| 759 "});" | 764 "});" |
| 760 "$('add-user-button').click();")); | 765 "$('add-user-button').click();")); |
| 761 content::DOMMessageQueue message_queue; | 766 content::DOMMessageQueue message_queue; |
| 762 std::string message; | 767 std::string message; |
| 763 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 768 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 764 EXPECT_EQ("\"ready\"", message); | 769 EXPECT_EQ("\"ready\"", message); |
| 765 } | 770 } |
| 766 | 771 |
| 767 void SAMLPolicyTest::LogInWithSAML(const std::string& user_id, | 772 void SAMLPolicyTest::LogInWithSAML(const std::string& gaia_id, |
| 773 const std::string& user_id, | |
| 768 const std::string& auth_sid_cookie, | 774 const std::string& auth_sid_cookie, |
| 769 const std::string& auth_lsid_cookie) { | 775 const std::string& auth_lsid_cookie) { |
| 770 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 776 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 771 StartSamlAndWaitForIdpPageLoad(user_id); | 777 StartSamlAndWaitForIdpPageLoad(user_id); |
| 772 | 778 |
| 773 fake_gaia_.SetFakeMergeSessionParams( | 779 fake_gaia_.SetFakeMergeSessionParams( |
| 774 user_id, auth_sid_cookie, auth_lsid_cookie); | 780 gaia_id, user_id, auth_sid_cookie, auth_lsid_cookie); |
| 775 SetSignFormField("Email", "fake_user"); | 781 SetSignFormField("Email", "fake_user"); |
| 776 SetSignFormField("Password", "fake_password"); | 782 SetSignFormField("Password", "fake_password"); |
| 777 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); | 783 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); |
| 778 | 784 |
| 779 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); | 785 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); |
| 780 | 786 |
| 781 SendConfirmPassword("fake_password"); | 787 SendConfirmPassword("fake_password"); |
| 782 content::WindowedNotificationObserver( | 788 content::WindowedNotificationObserver( |
| 783 chrome::NOTIFICATION_SESSION_STARTED, | 789 chrome::NOTIFICATION_SESSION_STARTED, |
| 784 content::NotificationService::AllSources()).Wait(); | 790 content::NotificationService::AllSources()).Wait(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 login_screen_load_observer_->Wait(); | 854 login_screen_load_observer_->Wait(); |
| 849 // Verify that offline login is allowed. | 855 // Verify that offline login is allowed. |
| 850 JsExpect("window.getComputedStyle(document.querySelector(" | 856 JsExpect("window.getComputedStyle(document.querySelector(" |
| 851 " '#pod-row .signin-button-container')).display == 'none'"); | 857 " '#pod-row .signin-button-container')).display == 'none'"); |
| 852 } | 858 } |
| 853 | 859 |
| 854 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_SAMLNoLimit) { | 860 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_SAMLNoLimit) { |
| 855 // Remove the offline login time limit for SAML users. | 861 // Remove the offline login time limit for SAML users. |
| 856 SetSAMLOfflineSigninTimeLimitPolicy(-1); | 862 SetSAMLOfflineSigninTimeLimitPolicy(-1); |
| 857 | 863 |
| 858 LogInWithSAML(kFirstSAMLUserEmail, kTestAuthSIDCookie1, kTestAuthLSIDCookie1); | 864 LogInWithSAML(kTestGaiaId, kFirstSAMLUserEmail, kTestAuthSIDCookie1, |
| 865 kTestAuthLSIDCookie1); | |
| 859 } | 866 } |
| 860 | 867 |
| 861 // Verifies that when no offline login time limit is set, a user who | 868 // Verifies that when no offline login time limit is set, a user who |
| 862 // authenticated with SAML is allowed to log in offline. | 869 // authenticated with SAML is allowed to log in offline. |
| 863 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLNoLimit) { | 870 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLNoLimit) { |
| 864 login_screen_load_observer_->Wait(); | 871 login_screen_load_observer_->Wait(); |
| 865 // Verify that offline login is allowed. | 872 // Verify that offline login is allowed. |
| 866 JsExpect("window.getComputedStyle(document.querySelector(" | 873 JsExpect("window.getComputedStyle(document.querySelector(" |
| 867 " '#pod-row .signin-button-container')).display == 'none'"); | 874 " '#pod-row .signin-button-container')).display == 'none'"); |
| 868 } | 875 } |
| 869 | 876 |
| 870 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_SAMLZeroLimit) { | 877 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_SAMLZeroLimit) { |
| 871 // Set the offline login time limit for SAML users to zero. | 878 // Set the offline login time limit for SAML users to zero. |
| 872 SetSAMLOfflineSigninTimeLimitPolicy(0); | 879 SetSAMLOfflineSigninTimeLimitPolicy(0); |
| 873 | 880 |
| 874 LogInWithSAML(kFirstSAMLUserEmail, kTestAuthSIDCookie1, kTestAuthLSIDCookie1); | 881 LogInWithSAML(kTestGaiaId, kFirstSAMLUserEmail, kTestAuthSIDCookie1, |
| 882 kTestAuthLSIDCookie1); | |
| 875 } | 883 } |
| 876 | 884 |
| 877 // Verifies that when the offline login time limit is exceeded for a user who | 885 // Verifies that when the offline login time limit is exceeded for a user who |
| 878 // authenticated via SAML, that user is forced to log in online the next time. | 886 // authenticated via SAML, that user is forced to log in online the next time. |
| 879 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLZeroLimit) { | 887 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLZeroLimit) { |
| 880 login_screen_load_observer_->Wait(); | 888 login_screen_load_observer_->Wait(); |
| 881 // Verify that offline login is not allowed. | 889 // Verify that offline login is not allowed. |
| 882 JsExpect("window.getComputedStyle(document.querySelector(" | 890 JsExpect("window.getComputedStyle(document.querySelector(" |
| 883 " '#pod-row .signin-button-container')).display != 'none'"); | 891 " '#pod-row .signin-button-container')).display != 'none'"); |
| 884 } | 892 } |
| 885 | 893 |
| 886 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_PRE_TransferCookiesAffiliated) { | 894 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_PRE_TransferCookiesAffiliated) { |
| 887 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue1); | 895 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue1); |
| 888 LogInWithSAML(kFirstSAMLUserEmail, kTestAuthSIDCookie1, kTestAuthLSIDCookie1); | 896 LogInWithSAML(kTestGaiaId, kFirstSAMLUserEmail, kTestAuthSIDCookie1, |
| 897 kTestAuthLSIDCookie1); | |
| 889 | 898 |
| 890 GetCookies(); | 899 GetCookies(); |
| 891 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); | 900 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
| 892 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); | 901 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
| 893 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); | 902 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
| 894 } | 903 } |
| 895 | 904 |
| 896 // Verifies that when the DeviceTransferSAMLCookies policy is not enabled, SAML | 905 // Verifies that when the DeviceTransferSAMLCookies policy is not enabled, SAML |
| 897 // IdP cookies are not transferred to a user's profile on subsequent login, even | 906 // IdP cookies are not transferred to a user's profile on subsequent login, even |
| 898 // if the user belongs to the domain that the device is enrolled into. Also | 907 // if the user belongs to the domain that the device is enrolled into. Also |
| 899 // verifies that GAIA cookies are not transferred. | 908 // verifies that GAIA cookies are not transferred. |
| 900 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_TransferCookiesAffiliated) { | 909 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_TransferCookiesAffiliated) { |
| 901 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); | 910 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); |
| 902 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 911 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 903 ShowGAIALoginForm(); | 912 ShowGAIALoginForm(); |
| 904 LogInWithSAML(kFirstSAMLUserEmail, kTestAuthSIDCookie2, kTestAuthLSIDCookie2); | 913 LogInWithSAML(kTestGaiaId, kFirstSAMLUserEmail, kTestAuthSIDCookie2, |
| 914 kTestAuthLSIDCookie2); | |
| 905 | 915 |
| 906 GetCookies(); | 916 GetCookies(); |
| 907 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); | 917 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
| 908 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); | 918 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
| 909 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); | 919 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
| 910 } | 920 } |
| 911 | 921 |
| 912 // Verifies that when the DeviceTransferSAMLCookies policy is enabled, SAML IdP | 922 // 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 | 923 // 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. Also verifies that | 924 // belongs to the domain that the device is enrolled into. Also verifies that |
| 915 // GAIA cookies are not transferred. | 925 // GAIA cookies are not transferred. |
| 916 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, TransferCookiesAffiliated) { | 926 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, TransferCookiesAffiliated) { |
| 917 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); | 927 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); |
| 918 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 928 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 919 ShowGAIALoginForm(); | 929 ShowGAIALoginForm(); |
| 920 | 930 |
| 921 EnableTransferSAMLCookiesPolicy(); | 931 EnableTransferSAMLCookiesPolicy(); |
| 922 LogInWithSAML(kFirstSAMLUserEmail, kTestAuthSIDCookie2, kTestAuthLSIDCookie2); | 932 LogInWithSAML(kTestGaiaId, kFirstSAMLUserEmail, kTestAuthSIDCookie2, |
| 933 kTestAuthLSIDCookie2); | |
| 923 | 934 |
| 924 GetCookies(); | 935 GetCookies(); |
| 925 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); | 936 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
| 926 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); | 937 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
| 927 EXPECT_EQ(kSAMLIdPCookieValue2, GetCookieValue(kSAMLIdPCookieName)); | 938 EXPECT_EQ(kSAMLIdPCookieValue2, GetCookieValue(kSAMLIdPCookieName)); |
| 928 } | 939 } |
| 929 | 940 |
| 930 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_TransferCookiesUnaffiliated) { | 941 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, PRE_TransferCookiesUnaffiliated) { |
| 931 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue1); | 942 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue1); |
| 932 LogInWithSAML(kDifferentDomainSAMLUserEmail, | 943 LogInWithSAML(kTestGaiaId, |
| 944 kDifferentDomainSAMLUserEmail, | |
| 933 kTestAuthSIDCookie1, | 945 kTestAuthSIDCookie1, |
| 934 kTestAuthLSIDCookie1); | 946 kTestAuthLSIDCookie1); |
| 935 | 947 |
| 936 GetCookies(); | 948 GetCookies(); |
| 937 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); | 949 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
| 938 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); | 950 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
| 939 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); | 951 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
| 940 } | 952 } |
| 941 | 953 |
| 942 // Verifies that even if the DeviceTransferSAMLCookies policy is enabled, SAML | 954 // Verifies that even if the DeviceTransferSAMLCookies policy is enabled, SAML |
| 943 // IdP are not transferred to a user's profile on subsequent login if the user | 955 // IdP are not transferred to a user's profile on subsequent login if the user |
| 944 // does not belong to the domain that the device is enrolled into. Also verifies | 956 // does not belong to the domain that the device is enrolled into. Also verifies |
| 945 // that GAIA cookies are not transferred. | 957 // that GAIA cookies are not transferred. |
| 946 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, TransferCookiesUnaffiliated) { | 958 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, TransferCookiesUnaffiliated) { |
| 947 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); | 959 fake_saml_idp()->SetCookieValue(kSAMLIdPCookieValue2); |
| 948 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 960 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 949 ShowGAIALoginForm(); | 961 ShowGAIALoginForm(); |
| 950 | 962 |
| 951 EnableTransferSAMLCookiesPolicy(); | 963 EnableTransferSAMLCookiesPolicy(); |
| 952 LogInWithSAML(kDifferentDomainSAMLUserEmail, | 964 LogInWithSAML(kTestGaiaId, |
| 965 kDifferentDomainSAMLUserEmail, | |
| 953 kTestAuthSIDCookie1, | 966 kTestAuthSIDCookie1, |
| 954 kTestAuthLSIDCookie1); | 967 kTestAuthLSIDCookie1); |
| 955 | 968 |
| 956 GetCookies(); | 969 GetCookies(); |
| 957 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); | 970 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
| 958 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); | 971 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
| 959 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); | 972 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
| 960 } | 973 } |
| 961 | 974 |
| 962 } // namespace chromeos | 975 } // namespace chromeos |
| OLD | NEW |