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

Side by Side Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 1035023002: Adding the Finch code for the certificate error reporter experiment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finch support for unittests Created 5 years, 8 months 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
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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/metrics/field_trial.h"
9 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 14 #include "base/time/time.h"
14 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" 18 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
18 #include "chrome/browser/net/certificate_error_reporter.h" 19 #include "chrome/browser/net/certificate_error_reporter.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/safe_browsing/ping_manager.h" 21 #include "chrome/browser/safe_browsing/ping_manager.h"
21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 22 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
22 #include "chrome/browser/ssl/ssl_blocking_page.h" 23 #include "chrome/browser/ssl/ssl_blocking_page.h"
23 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_commands.h" 25 #include "chrome/browser/ui/browser_commands.h"
25 #include "chrome/browser/ui/browser_navigator.h" 26 #include "chrome/browser/ui/browser_navigator.h"
26 #include "chrome/browser/ui/browser_tabstrip.h" 27 #include "chrome/browser/ui/browser_tabstrip.h"
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" 28 #include "chrome/browser/ui/tabs/tab_strip_model.h"
28 #include "chrome/common/chrome_paths.h" 29 #include "chrome/common/chrome_paths.h"
29 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
31 #include "chrome/test/base/in_process_browser_test.h" 32 #include "chrome/test/base/in_process_browser_test.h"
32 #include "chrome/test/base/ui_test_utils.h" 33 #include "chrome/test/base/ui_test_utils.h"
33 #include "components/content_settings/core/browser/host_content_settings_map.h" 34 #include "components/content_settings/core/browser/host_content_settings_map.h"
35 #include "components/variations/variations_associated_data.h"
34 #include "components/web_modal/web_contents_modal_dialog_manager.h" 36 #include "components/web_modal/web_contents_modal_dialog_manager.h"
35 #include "content/public/browser/browser_context.h" 37 #include "content/public/browser/browser_context.h"
36 #include "content/public/browser/interstitial_page.h" 38 #include "content/public/browser/interstitial_page.h"
37 #include "content/public/browser/navigation_controller.h" 39 #include "content/public/browser/navigation_controller.h"
38 #include "content/public/browser/navigation_entry.h" 40 #include "content/public/browser/navigation_entry.h"
39 #include "content/public/browser/notification_service.h" 41 #include "content/public/browser/notification_service.h"
40 #include "content/public/browser/render_frame_host.h" 42 #include "content/public/browser/render_frame_host.h"
41 #include "content/public/browser/render_view_host.h" 43 #include "content/public/browser/render_view_host.h"
42 #include "content/public/browser/render_widget_host_view.h" 44 #include "content/public/browser/render_widget_host_view.h"
43 #include "content/public/browser/web_contents.h" 45 #include "content/public/browser/web_contents.h"
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 1123
1122 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), 1124 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(),
1123 AuthState::DISPLAYED_INSECURE_CONTENT); 1125 AuthState::DISPLAYED_INSECURE_CONTENT);
1124 } 1126 }
1125 1127
1126 // Test that when the checkbox is checked and the user proceeds through 1128 // Test that when the checkbox is checked and the user proceeds through
1127 // the interstitial, the FraudulentCertificateReporter sees a request to 1129 // the interstitial, the FraudulentCertificateReporter sees a request to
1128 // send a report. 1130 // send a report.
1129 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting, 1131 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting,
1130 TestBrokenHTTPSProceedWithReporting) { 1132 TestBrokenHTTPSProceedWithReporting) {
1133 base::FieldTrialList::CreateFieldTrial("ReportCertificateErrors",
1134 "ShowAndPossiblySend");
1135 std::map<std::string, std::string> params;
1136 params["possibly_send"] = "1.0";
1137 variations::AssociateVariationParams("ReportCertificateErrors",
1138 "ShowAndPossiblySend", params);
1131 TestBrokenHTTPSReporting(CertificateReporting::EXTENDED_REPORTING_OPT_IN, 1139 TestBrokenHTTPSReporting(CertificateReporting::EXTENDED_REPORTING_OPT_IN,
1132 CertificateReporting::SSL_INTERSTITIAL_PROCEED, 1140 CertificateReporting::SSL_INTERSTITIAL_PROCEED,
1133 CertificateReporting::CERT_REPORT_EXPECTED, 1141 CertificateReporting::CERT_REPORT_EXPECTED,
1134 browser()); 1142 browser());
1135 } 1143 }
1136 1144
1137 // Test that when the checkbox is checked and the user goes back (does 1145 // Test that when the checkbox is checked and the user goes back (does
1138 // not proceed through the interstitial), the 1146 // not proceed through the interstitial), the
1139 // FraudulentCertificateReporter sees a request to send a report. 1147 // FraudulentCertificateReporter sees a request to send a report.
1140 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting, 1148 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting,
1141 TestBrokenHTTPSGoBackWithReporting) { 1149 TestBrokenHTTPSGoBackWithReporting) {
1150 base::FieldTrialList::CreateFieldTrial("ReportCertificateErrors",
estark 2015/04/01 20:47:43 I think this code should appear on the 4 tests bel
1151 "ShowAndPossiblySend");
1152 std::map<std::string, std::string> params;
1153 params["possibly_send"] = "1.0";
1154 variations::AssociateVariationParams("ReportCertificateErrors",
1155 "ShowAndPossiblySend", params);
1142 TestBrokenHTTPSReporting( 1156 TestBrokenHTTPSReporting(
1143 CertificateReporting::EXTENDED_REPORTING_OPT_IN, 1157 CertificateReporting::EXTENDED_REPORTING_OPT_IN,
1144 CertificateReporting::SSL_INTERSTITIAL_DO_NOT_PROCEED, 1158 CertificateReporting::SSL_INTERSTITIAL_DO_NOT_PROCEED,
1145 CertificateReporting::CERT_REPORT_EXPECTED, browser()); 1159 CertificateReporting::CERT_REPORT_EXPECTED, browser());
1146 } 1160 }
1147 1161
1148 // Test that when the checkbox is not checked and the user proceeds 1162 // Test that when the checkbox is not checked and the user proceeds
1149 // through the interstitial, the FraudulentCertificateReporter does not 1163 // through the interstitial, the FraudulentCertificateReporter does not
1150 // see a request to send a report. 1164 // see a request to send a report.
1151 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting, 1165 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting,
(...skipping 15 matching lines...) Expand all
1167 CertificateReporting::CERT_REPORT_NOT_EXPECTED, browser()); 1181 CertificateReporting::CERT_REPORT_NOT_EXPECTED, browser());
1168 } 1182 }
1169 1183
1170 // Test that when the command-line switch for reporting invalid cert 1184 // Test that when the command-line switch for reporting invalid cert
1171 // chains is not enabled, reports don't get sent, even if the opt-in 1185 // chains is not enabled, reports don't get sent, even if the opt-in
1172 // preference is set. (i.e. if a user enables invalid cert collection in 1186 // preference is set. (i.e. if a user enables invalid cert collection in
1173 // chrome://flags, checks the box on an interstitial, and then disables 1187 // chrome://flags, checks the box on an interstitial, and then disables
1174 // the flag in chrome://flags, reports shouldn't be sent on the next 1188 // the flag in chrome://flags, reports shouldn't be sent on the next
1175 // interstitial). 1189 // interstitial).
1176 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBrokenHTTPSNoReportingWithoutSwitch) { 1190 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBrokenHTTPSNoReportingWithoutSwitch) {
1177 TestBrokenHTTPSReporting(CertificateReporting::EXTENDED_REPORTING_OPT_IN, 1191 TestBrokenHTTPSReporting(CertificateReporting::EXTENDED_REPORTING_OPT_IN,
estark 2015/04/01 20:47:43 This test is supposed to test that reports don't g
estark 2015/04/01 20:49:40 Sorry, I failed at English on that sentence... let
1178 CertificateReporting::SSL_INTERSTITIAL_PROCEED, 1192 CertificateReporting::SSL_INTERSTITIAL_PROCEED,
1179 CertificateReporting::CERT_REPORT_NOT_EXPECTED, 1193 CertificateReporting::CERT_REPORT_NOT_EXPECTED,
1180 browser()); 1194 browser());
1181 } 1195 }
1182 1196
1183 // Test that reports don't get sent in incognito mode even if the opt-in 1197 // Test that reports don't get sent in incognito mode even if the opt-in
1184 // preference is set and the command-line switch is enabled. 1198 // preference is set and the command-line switch is enabled.
1185 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting, 1199 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting,
1186 TestBrokenHTTPSNoReportingInIncognito) { 1200 TestBrokenHTTPSNoReportingInIncognito) {
1187 TestBrokenHTTPSReporting(CertificateReporting::EXTENDED_REPORTING_OPT_IN, 1201 TestBrokenHTTPSReporting(CertificateReporting::EXTENDED_REPORTING_OPT_IN,
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
2152 2166
2153 // Visit a page over https that contains a frame with a redirect. 2167 // Visit a page over https that contains a frame with a redirect.
2154 2168
2155 // XMLHttpRequest insecure content in synchronous mode. 2169 // XMLHttpRequest insecure content in synchronous mode.
2156 2170
2157 // XMLHttpRequest insecure content in asynchronous mode. 2171 // XMLHttpRequest insecure content in asynchronous mode.
2158 2172
2159 // XMLHttpRequest over bad ssl in synchronous mode. 2173 // XMLHttpRequest over bad ssl in synchronous mode.
2160 2174
2161 // XMLHttpRequest over OK ssl in synchronous mode. 2175 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698