| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 16 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 17 #include "chrome/browser/chromeos/login/test/https_forwarder.h" | 17 #include "chrome/browser/chromeos/login/test/https_forwarder.h" |
| 18 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" | 18 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
| 19 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 19 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 20 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 20 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 21 #include "chrome/browser/chromeos/login/users/user.h" | |
| 22 #include "chrome/browser/chromeos/login/users/user_manager.h" | 21 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 23 #include "chrome/browser/chromeos/login/wizard_controller.h" | 22 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 24 #include "chrome/browser/lifetime/application_lifetime.h" | 23 #include "chrome/browser/lifetime/application_lifetime.h" |
| 25 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 26 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/test/base/in_process_browser_test.h" | 26 #include "chrome/test/base/in_process_browser_test.h" |
| 28 #include "chromeos/chromeos_switches.h" | 27 #include "chromeos/chromeos_switches.h" |
| 29 #include "components/policy/core/browser/browser_policy_connector.h" | 28 #include "components/policy/core/browser/browser_policy_connector.h" |
| 30 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 29 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
| 31 #include "components/policy/core/common/policy_map.h" | 30 #include "components/policy/core/common/policy_map.h" |
| 32 #include "components/policy/core/common/policy_types.h" | 31 #include "components/policy/core/common/policy_types.h" |
| 32 #include "components/user_manager/user.h" |
| 33 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 34 #include "content/public/test/browser_test_utils.h" | 34 #include "content/public/test/browser_test_utils.h" |
| 35 #include "content/public/test/test_utils.h" | 35 #include "content/public/test/test_utils.h" |
| 36 #include "google_apis/gaia/fake_gaia.h" | 36 #include "google_apis/gaia/fake_gaia.h" |
| 37 #include "google_apis/gaia/gaia_switches.h" | 37 #include "google_apis/gaia/gaia_switches.h" |
| 38 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
| 39 #include "net/base/url_util.h" | 39 #include "net/base/url_util.h" |
| 40 #include "net/dns/mock_host_resolver.h" | 40 #include "net/dns/mock_host_resolver.h" |
| 41 #include "net/test/embedded_test_server/embedded_test_server.h" | 41 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 42 #include "net/test/embedded_test_server/http_request.h" | 42 #include "net/test/embedded_test_server/http_request.h" |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 SetSignFormField("Email", "fake_user"); | 521 SetSignFormField("Email", "fake_user"); |
| 522 SetSignFormField("Password", "fake_password"); | 522 SetSignFormField("Password", "fake_password"); |
| 523 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); | 523 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); |
| 524 | 524 |
| 525 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); | 525 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); |
| 526 | 526 |
| 527 SendConfirmPassword("fake_password"); | 527 SendConfirmPassword("fake_password"); |
| 528 content::WindowedNotificationObserver( | 528 content::WindowedNotificationObserver( |
| 529 chrome::NOTIFICATION_SESSION_STARTED, | 529 chrome::NOTIFICATION_SESSION_STARTED, |
| 530 content::NotificationService::AllSources()).Wait(); | 530 content::NotificationService::AllSources()).Wait(); |
| 531 const User* user = UserManager::Get()->GetActiveUser(); | 531 const user_manager::User* user = UserManager::Get()->GetActiveUser(); |
| 532 ASSERT_TRUE(user); | 532 ASSERT_TRUE(user); |
| 533 EXPECT_EQ(kFirstSAMLUserEmail, user->email()); | 533 EXPECT_EQ(kFirstSAMLUserEmail, user->email()); |
| 534 } | 534 } |
| 535 | 535 |
| 536 // Verifies that if the authenticated user's e-mail address cannot be retrieved, | 536 // Verifies that if the authenticated user's e-mail address cannot be retrieved, |
| 537 // an error message is shown. | 537 // an error message is shown. |
| 538 IN_PROC_BROWSER_TEST_F(SamlTest, FailToRetrieveAutenticatedUserEmailAddress) { | 538 IN_PROC_BROWSER_TEST_F(SamlTest, FailToRetrieveAutenticatedUserEmailAddress) { |
| 539 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 539 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 540 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); | 540 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); |
| 541 | 541 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 | 637 |
| 638 EXPECT_CALL(provider_, IsInitializationComplete(_)) | 638 EXPECT_CALL(provider_, IsInitializationComplete(_)) |
| 639 .WillRepeatedly(Return(true)); | 639 .WillRepeatedly(Return(true)); |
| 640 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); | 640 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); |
| 641 } | 641 } |
| 642 | 642 |
| 643 void SAMLPolicyTest::SetUpOnMainThread() { | 643 void SAMLPolicyTest::SetUpOnMainThread() { |
| 644 SamlTest::SetUpOnMainThread(); | 644 SamlTest::SetUpOnMainThread(); |
| 645 | 645 |
| 646 // Pretend that the test users' OAuth tokens are valid. | 646 // Pretend that the test users' OAuth tokens are valid. |
| 647 UserManager::Get()->SaveUserOAuthStatus(kFirstSAMLUserEmail, | 647 UserManager::Get()->SaveUserOAuthStatus( |
| 648 User::OAUTH2_TOKEN_STATUS_VALID); | 648 kFirstSAMLUserEmail, user_manager::User::OAUTH2_TOKEN_STATUS_VALID); |
| 649 UserManager::Get()->SaveUserOAuthStatus(kNonSAMLUserEmail, | 649 UserManager::Get()->SaveUserOAuthStatus( |
| 650 User::OAUTH2_TOKEN_STATUS_VALID); | 650 kNonSAMLUserEmail, user_manager::User::OAUTH2_TOKEN_STATUS_VALID); |
| 651 } | 651 } |
| 652 | 652 |
| 653 void SAMLPolicyTest::SetSAMLOfflineSigninTimeLimitPolicy(int limit) { | 653 void SAMLPolicyTest::SetSAMLOfflineSigninTimeLimitPolicy(int limit) { |
| 654 policy::PolicyMap policy; | 654 policy::PolicyMap policy; |
| 655 policy.Set(policy::key::kSAMLOfflineSigninTimeLimit, | 655 policy.Set(policy::key::kSAMLOfflineSigninTimeLimit, |
| 656 policy::POLICY_LEVEL_MANDATORY, | 656 policy::POLICY_LEVEL_MANDATORY, |
| 657 policy::POLICY_SCOPE_USER, | 657 policy::POLICY_SCOPE_USER, |
| 658 new base::FundamentalValue(limit), | 658 new base::FundamentalValue(limit), |
| 659 NULL); | 659 NULL); |
| 660 provider_.UpdateChromePolicy(policy); | 660 provider_.UpdateChromePolicy(policy); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 // Verifies that when the offline login time limit is exceeded for a user who | 736 // Verifies that when the offline login time limit is exceeded for a user who |
| 737 // authenticated via SAML, that user is forced to log in online the next time. | 737 // authenticated via SAML, that user is forced to log in online the next time. |
| 738 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLZeroLimit) { | 738 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLZeroLimit) { |
| 739 login_screen_load_observer_->Wait(); | 739 login_screen_load_observer_->Wait(); |
| 740 // Verify that offline login is not allowed. | 740 // Verify that offline login is not allowed. |
| 741 JsExpect("window.getComputedStyle(document.querySelector(" | 741 JsExpect("window.getComputedStyle(document.querySelector(" |
| 742 " '#pod-row .signin-button-container')).display != 'none'"); | 742 " '#pod-row .signin-button-container')).display != 'none'"); |
| 743 } | 743 } |
| 744 | 744 |
| 745 } // namespace chromeos | 745 } // namespace chromeos |
| OLD | NEW |