| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 #include "extensions/common/constants.h" | 154 #include "extensions/common/constants.h" |
| 155 #include "extensions/common/extension.h" | 155 #include "extensions/common/extension.h" |
| 156 #include "extensions/common/extension_set.h" | 156 #include "extensions/common/extension_set.h" |
| 157 #include "extensions/common/manifest_handlers/shared_module_info.h" | 157 #include "extensions/common/manifest_handlers/shared_module_info.h" |
| 158 #include "net/base/net_errors.h" | 158 #include "net/base/net_errors.h" |
| 159 #include "net/base/net_util.h" | 159 #include "net/base/net_util.h" |
| 160 #include "net/base/url_util.h" | 160 #include "net/base/url_util.h" |
| 161 #include "net/http/http_stream_factory.h" | 161 #include "net/http/http_stream_factory.h" |
| 162 #include "net/ssl/ssl_config.h" | 162 #include "net/ssl/ssl_config.h" |
| 163 #include "net/ssl/ssl_config_service.h" | 163 #include "net/ssl/ssl_config_service.h" |
| 164 #include "net/test/spawned_test_server/spawned_test_server.h" | 164 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 165 #include "net/test/url_request/url_request_failed_job.h" | 165 #include "net/test/url_request/url_request_failed_job.h" |
| 166 #include "net/test/url_request/url_request_mock_http_job.h" | 166 #include "net/test/url_request/url_request_mock_http_job.h" |
| 167 #include "net/url_request/url_request.h" | 167 #include "net/url_request/url_request.h" |
| 168 #include "net/url_request/url_request_filter.h" | 168 #include "net/url_request/url_request_filter.h" |
| 169 #include "net/url_request/url_request_interceptor.h" | 169 #include "net/url_request/url_request_interceptor.h" |
| 170 #include "policy/policy_constants.h" | 170 #include "policy/policy_constants.h" |
| 171 #include "testing/gmock/include/gmock/gmock.h" | 171 #include "testing/gmock/include/gmock/gmock.h" |
| 172 #include "testing/gtest/include/gtest/gtest.h" | 172 #include "testing/gtest/include/gtest/gtest.h" |
| 173 #include "third_party/WebKit/public/web/WebInputEvent.h" | 173 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 174 #include "ui/base/l10n/l10n_util.h" | 174 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 3521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3696 } | 3696 } |
| 3697 } | 3697 } |
| 3698 | 3698 |
| 3699 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, | 3699 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, |
| 3700 MediaStreamDevicesControllerBrowserTest, | 3700 MediaStreamDevicesControllerBrowserTest, |
| 3701 testing::Bool()); | 3701 testing::Bool()); |
| 3702 | 3702 |
| 3703 // Test that when extended reporting opt-in is disabled by policy, the | 3703 // Test that when extended reporting opt-in is disabled by policy, the |
| 3704 // opt-in checkbox does not appear on SSL blocking pages. | 3704 // opt-in checkbox does not appear on SSL blocking pages. |
| 3705 IN_PROC_BROWSER_TEST_F(PolicyTest, SafeBrowsingExtendedReportingOptInAllowed) { | 3705 IN_PROC_BROWSER_TEST_F(PolicyTest, SafeBrowsingExtendedReportingOptInAllowed) { |
| 3706 net::SpawnedTestServer https_server_expired( | 3706 net::EmbeddedTestServer https_server_expired( |
| 3707 net::SpawnedTestServer::TYPE_HTTPS, | 3707 net::EmbeddedTestServer::TYPE_HTTPS); |
| 3708 net::SpawnedTestServer::SSLOptions( | 3708 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| 3709 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), | 3709 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 3710 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | |
| 3711 ASSERT_TRUE(https_server_expired.Start()); | 3710 ASSERT_TRUE(https_server_expired.Start()); |
| 3712 | 3711 |
| 3713 // Set the enterprise policy to disallow opt-in. | 3712 // Set the enterprise policy to disallow opt-in. |
| 3714 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3713 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 3715 EXPECT_TRUE( | 3714 EXPECT_TRUE( |
| 3716 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); | 3715 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); |
| 3717 PolicyMap policies; | 3716 PolicyMap policies; |
| 3718 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, | 3717 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, |
| 3719 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3718 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3720 new base::FundamentalValue(false), nullptr); | 3719 new base::FundamentalValue(false), nullptr); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3749 SecurityInterstitialPage::CMD_TEXT_FOUND, | 3748 SecurityInterstitialPage::CMD_TEXT_FOUND, |
| 3750 SecurityInterstitialPage::CMD_TEXT_NOT_FOUND, | 3749 SecurityInterstitialPage::CMD_TEXT_NOT_FOUND, |
| 3751 SecurityInterstitialPage::CMD_ERROR); | 3750 SecurityInterstitialPage::CMD_ERROR); |
| 3752 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(rvh, command, &result)); | 3751 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(rvh, command, &result)); |
| 3753 EXPECT_EQ(SecurityInterstitialPage::CMD_TEXT_NOT_FOUND, result); | 3752 EXPECT_EQ(SecurityInterstitialPage::CMD_TEXT_NOT_FOUND, result); |
| 3754 } | 3753 } |
| 3755 | 3754 |
| 3756 // Test that when SSL error overriding is allowed by policy (default), the | 3755 // Test that when SSL error overriding is allowed by policy (default), the |
| 3757 // proceed link appears on SSL blocking pages. | 3756 // proceed link appears on SSL blocking pages. |
| 3758 IN_PROC_BROWSER_TEST_F(PolicyTest, SSLErrorOverridingAllowed) { | 3757 IN_PROC_BROWSER_TEST_F(PolicyTest, SSLErrorOverridingAllowed) { |
| 3759 net::SpawnedTestServer https_server_expired( | 3758 net::EmbeddedTestServer https_server_expired( |
| 3760 net::SpawnedTestServer::TYPE_HTTPS, | 3759 net::EmbeddedTestServer::TYPE_HTTPS); |
| 3761 net::SpawnedTestServer::SSLOptions( | 3760 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| 3762 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), | 3761 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 3763 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | |
| 3764 ASSERT_TRUE(https_server_expired.Start()); | 3762 ASSERT_TRUE(https_server_expired.Start()); |
| 3765 | 3763 |
| 3766 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3764 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 3767 | 3765 |
| 3768 // Policy should allow overriding by default. | 3766 // Policy should allow overriding by default. |
| 3769 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); | 3767 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); |
| 3770 | 3768 |
| 3771 // Policy allows overriding - navigate to an SSL error page and expect the | 3769 // Policy allows overriding - navigate to an SSL error page and expect the |
| 3772 // proceed link. | 3770 // proceed link. |
| 3773 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); | 3771 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); |
| 3774 | 3772 |
| 3775 const content::InterstitialPage* const interstitial = | 3773 const content::InterstitialPage* const interstitial = |
| 3776 content::InterstitialPage::GetInterstitialPage( | 3774 content::InterstitialPage::GetInterstitialPage( |
| 3777 browser()->tab_strip_model()->GetActiveWebContents()); | 3775 browser()->tab_strip_model()->GetActiveWebContents()); |
| 3778 ASSERT_TRUE(interstitial); | 3776 ASSERT_TRUE(interstitial); |
| 3779 EXPECT_TRUE(content::WaitForRenderFrameReady(interstitial->GetMainFrame())); | 3777 EXPECT_TRUE(content::WaitForRenderFrameReady(interstitial->GetMainFrame())); |
| 3780 | 3778 |
| 3781 // The interstitial should display the proceed link. | 3779 // The interstitial should display the proceed link. |
| 3782 EXPECT_TRUE(chrome_browser_interstitials::IsInterstitialDisplayingText( | 3780 EXPECT_TRUE(chrome_browser_interstitials::IsInterstitialDisplayingText( |
| 3783 interstitial, "proceed-link")); | 3781 interstitial, "proceed-link")); |
| 3784 } | 3782 } |
| 3785 | 3783 |
| 3786 // Test that when SSL error overriding is disallowed by policy, the | 3784 // Test that when SSL error overriding is disallowed by policy, the |
| 3787 // proceed link does not appear on SSL blocking pages and users should not | 3785 // proceed link does not appear on SSL blocking pages and users should not |
| 3788 // be able to proceed. | 3786 // be able to proceed. |
| 3789 IN_PROC_BROWSER_TEST_F(PolicyTest, SSLErrorOverridingDisallowed) { | 3787 IN_PROC_BROWSER_TEST_F(PolicyTest, SSLErrorOverridingDisallowed) { |
| 3790 net::SpawnedTestServer https_server_expired( | 3788 net::EmbeddedTestServer https_server_expired( |
| 3791 net::SpawnedTestServer::TYPE_HTTPS, | 3789 net::EmbeddedTestServer::TYPE_HTTPS); |
| 3792 net::SpawnedTestServer::SSLOptions( | 3790 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| 3793 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), | 3791 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 3794 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | |
| 3795 ASSERT_TRUE(https_server_expired.Start()); | 3792 ASSERT_TRUE(https_server_expired.Start()); |
| 3796 | 3793 |
| 3797 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3794 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 3798 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); | 3795 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); |
| 3799 | 3796 |
| 3800 // Disallowing the proceed link by setting the policy to |false|. | 3797 // Disallowing the proceed link by setting the policy to |false|. |
| 3801 PolicyMap policies; | 3798 PolicyMap policies; |
| 3802 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, | 3799 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, |
| 3803 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3800 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3804 new base::FundamentalValue(false), nullptr); | 3801 new base::FundamentalValue(false), nullptr); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3987 POLICY_SCOPE_USER, | 3984 POLICY_SCOPE_USER, |
| 3988 POLICY_SOURCE_CLOUD, | 3985 POLICY_SOURCE_CLOUD, |
| 3989 new base::FundamentalValue(false), | 3986 new base::FundamentalValue(false), |
| 3990 NULL); | 3987 NULL); |
| 3991 UpdateProviderPolicy(policies); | 3988 UpdateProviderPolicy(policies); |
| 3992 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 3989 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
| 3993 } | 3990 } |
| 3994 #endif // defined(OS_CHROMEOS) | 3991 #endif // defined(OS_CHROMEOS) |
| 3995 | 3992 |
| 3996 } // namespace policy | 3993 } // namespace policy |
| OLD | NEW |