Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(893)

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 1378123003: Adding SSL ETS Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ets
Patch Set: Rebase. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 3522 matching lines...) Expand 10 before | Expand all | Expand 10 after
3697 } 3697 }
3698 } 3698 }
3699 3699
3700 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, 3700 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance,
3701 MediaStreamDevicesControllerBrowserTest, 3701 MediaStreamDevicesControllerBrowserTest,
3702 testing::Bool()); 3702 testing::Bool());
3703 3703
3704 // Test that when extended reporting opt-in is disabled by policy, the 3704 // Test that when extended reporting opt-in is disabled by policy, the
3705 // opt-in checkbox does not appear on SSL blocking pages. 3705 // opt-in checkbox does not appear on SSL blocking pages.
3706 IN_PROC_BROWSER_TEST_F(PolicyTest, SafeBrowsingExtendedReportingOptInAllowed) { 3706 IN_PROC_BROWSER_TEST_F(PolicyTest, SafeBrowsingExtendedReportingOptInAllowed) {
3707 net::SpawnedTestServer https_server_expired( 3707 net::EmbeddedTestServer https_server_expired(
3708 net::SpawnedTestServer::TYPE_HTTPS, 3708 net::EmbeddedTestServer::TYPE_HTTPS);
3709 net::SpawnedTestServer::SSLOptions( 3709 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED);
3710 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), 3710 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data");
3711 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
3712 ASSERT_TRUE(https_server_expired.Start()); 3711 ASSERT_TRUE(https_server_expired.Start());
3713 3712
3714 // Set the enterprise policy to disallow opt-in. 3713 // Set the enterprise policy to disallow opt-in.
3715 const PrefService* const prefs = browser()->profile()->GetPrefs(); 3714 const PrefService* const prefs = browser()->profile()->GetPrefs();
3716 EXPECT_TRUE( 3715 EXPECT_TRUE(
3717 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); 3716 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed));
3718 PolicyMap policies; 3717 PolicyMap policies;
3719 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, 3718 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed,
3720 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 3719 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
3721 new base::FundamentalValue(false), nullptr); 3720 new base::FundamentalValue(false), nullptr);
(...skipping 28 matching lines...) Expand all
3750 SecurityInterstitialPage::CMD_TEXT_FOUND, 3749 SecurityInterstitialPage::CMD_TEXT_FOUND,
3751 SecurityInterstitialPage::CMD_TEXT_NOT_FOUND, 3750 SecurityInterstitialPage::CMD_TEXT_NOT_FOUND,
3752 SecurityInterstitialPage::CMD_ERROR); 3751 SecurityInterstitialPage::CMD_ERROR);
3753 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(rvh, command, &result)); 3752 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(rvh, command, &result));
3754 EXPECT_EQ(SecurityInterstitialPage::CMD_TEXT_NOT_FOUND, result); 3753 EXPECT_EQ(SecurityInterstitialPage::CMD_TEXT_NOT_FOUND, result);
3755 } 3754 }
3756 3755
3757 // Test that when SSL error overriding is allowed by policy (default), the 3756 // Test that when SSL error overriding is allowed by policy (default), the
3758 // proceed link appears on SSL blocking pages. 3757 // proceed link appears on SSL blocking pages.
3759 IN_PROC_BROWSER_TEST_F(PolicyTest, SSLErrorOverridingAllowed) { 3758 IN_PROC_BROWSER_TEST_F(PolicyTest, SSLErrorOverridingAllowed) {
3760 net::SpawnedTestServer https_server_expired( 3759 net::EmbeddedTestServer https_server_expired(
3761 net::SpawnedTestServer::TYPE_HTTPS, 3760 net::EmbeddedTestServer::TYPE_HTTPS);
3762 net::SpawnedTestServer::SSLOptions( 3761 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED);
3763 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), 3762 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data");
3764 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
3765 ASSERT_TRUE(https_server_expired.Start()); 3763 ASSERT_TRUE(https_server_expired.Start());
3766 3764
3767 const PrefService* const prefs = browser()->profile()->GetPrefs(); 3765 const PrefService* const prefs = browser()->profile()->GetPrefs();
3768 3766
3769 // Policy should allow overriding by default. 3767 // Policy should allow overriding by default.
3770 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); 3768 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed));
3771 3769
3772 // Policy allows overriding - navigate to an SSL error page and expect the 3770 // Policy allows overriding - navigate to an SSL error page and expect the
3773 // proceed link. 3771 // proceed link.
3774 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); 3772 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/"));
3775 3773
3776 const content::InterstitialPage* const interstitial = 3774 const content::InterstitialPage* const interstitial =
3777 content::InterstitialPage::GetInterstitialPage( 3775 content::InterstitialPage::GetInterstitialPage(
3778 browser()->tab_strip_model()->GetActiveWebContents()); 3776 browser()->tab_strip_model()->GetActiveWebContents());
3779 ASSERT_TRUE(interstitial); 3777 ASSERT_TRUE(interstitial);
3780 EXPECT_TRUE(content::WaitForRenderFrameReady(interstitial->GetMainFrame())); 3778 EXPECT_TRUE(content::WaitForRenderFrameReady(interstitial->GetMainFrame()));
3781 3779
3782 // The interstitial should display the proceed link. 3780 // The interstitial should display the proceed link.
3783 EXPECT_TRUE(chrome_browser_interstitials::IsInterstitialDisplayingText( 3781 EXPECT_TRUE(chrome_browser_interstitials::IsInterstitialDisplayingText(
3784 interstitial, "proceed-link")); 3782 interstitial, "proceed-link"));
3785 } 3783 }
3786 3784
3787 // Test that when SSL error overriding is disallowed by policy, the 3785 // Test that when SSL error overriding is disallowed by policy, the
3788 // proceed link does not appear on SSL blocking pages and users should not 3786 // proceed link does not appear on SSL blocking pages and users should not
3789 // be able to proceed. 3787 // be able to proceed.
3790 IN_PROC_BROWSER_TEST_F(PolicyTest, SSLErrorOverridingDisallowed) { 3788 IN_PROC_BROWSER_TEST_F(PolicyTest, SSLErrorOverridingDisallowed) {
3791 net::SpawnedTestServer https_server_expired( 3789 net::EmbeddedTestServer https_server_expired(
3792 net::SpawnedTestServer::TYPE_HTTPS, 3790 net::EmbeddedTestServer::TYPE_HTTPS);
3793 net::SpawnedTestServer::SSLOptions( 3791 https_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED);
3794 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), 3792 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data");
3795 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
3796 ASSERT_TRUE(https_server_expired.Start()); 3793 ASSERT_TRUE(https_server_expired.Start());
3797 3794
3798 const PrefService* const prefs = browser()->profile()->GetPrefs(); 3795 const PrefService* const prefs = browser()->profile()->GetPrefs();
3799 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); 3796 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed));
3800 3797
3801 // Disallowing the proceed link by setting the policy to |false|. 3798 // Disallowing the proceed link by setting the policy to |false|.
3802 PolicyMap policies; 3799 PolicyMap policies;
3803 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, 3800 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY,
3804 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 3801 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
3805 new base::FundamentalValue(false), nullptr); 3802 new base::FundamentalValue(false), nullptr);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
3988 POLICY_SCOPE_USER, 3985 POLICY_SCOPE_USER,
3989 POLICY_SOURCE_CLOUD, 3986 POLICY_SOURCE_CLOUD,
3990 new base::FundamentalValue(false), 3987 new base::FundamentalValue(false),
3991 NULL); 3988 NULL);
3992 UpdateProviderPolicy(policies); 3989 UpdateProviderPolicy(policies);
3993 EXPECT_FALSE(display_manager->unified_desktop_enabled()); 3990 EXPECT_FALSE(display_manager->unified_desktop_enabled());
3994 } 3991 }
3995 #endif // defined(OS_CHROMEOS) 3992 #endif // defined(OS_CHROMEOS)
3996 3993
3997 } // namespace policy 3994 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_power_saver_browsertest.cc ('k') | chrome/browser/policy/test/local_policy_test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698