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

Side by Side Diff: chrome/browser/net/certificate_error_reporter_unittest.cc

Issue 935663004: Add checkbox for reporting invalid TLS/SSL cert chains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert accidental deletion (fixes failing CaptivePortal tests) Created 5 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/net/certificate_error_reporter.h" 5 #include "chrome/browser/net/certificate_error_reporter.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 TestURLRequestContext* context, 194 TestURLRequestContext* context,
195 const std::string& report_hostname, 195 const std::string& report_hostname,
196 const GURL& url, 196 const GURL& url,
197 int request_sequence_number) { 197 int request_sequence_number) {
198 base::RunLoop run_loop; 198 base::RunLoop run_loop;
199 network_delegate->set_url_request_destroyed_callback(run_loop.QuitClosure()); 199 network_delegate->set_url_request_destroyed_callback(run_loop.QuitClosure());
200 200
201 network_delegate->set_expected_url(url); 201 network_delegate->set_expected_url(url);
202 network_delegate->ExpectHostname(report_hostname); 202 network_delegate->ExpectHostname(report_hostname);
203 203
204 CertificateErrorReporter reporter(context, url); 204 CertificateErrorReporter reporter(
205 context, url, CertificateErrorReporter::DO_NOT_SEND_COOKIES);
205 206
206 EXPECT_EQ(request_sequence_number, network_delegate->num_requests()); 207 EXPECT_EQ(request_sequence_number, network_delegate->num_requests());
207 208
208 reporter.SendReport(CertificateErrorReporter::REPORT_TYPE_PINNING_VIOLATION, 209 reporter.SendReport(CertificateErrorReporter::REPORT_TYPE_PINNING_VIOLATION,
209 report_hostname, GetTestSSLInfo()); 210 report_hostname, GetTestSSLInfo());
210 run_loop.Run(); 211 run_loop.Run();
211 212
212 EXPECT_EQ(request_sequence_number + 1, network_delegate->num_requests()); 213 EXPECT_EQ(request_sequence_number + 1, network_delegate->num_requests());
213 } 214 }
214 215
(...skipping 13 matching lines...) Expand all
228 TEST_F(CertificateErrorReporterTest, SendMultipleReportsSimultaneously) { 229 TEST_F(CertificateErrorReporterTest, SendMultipleReportsSimultaneously) {
229 base::RunLoop run_loop; 230 base::RunLoop run_loop;
230 network_delegate()->set_all_url_requests_destroyed_callback( 231 network_delegate()->set_all_url_requests_destroyed_callback(
231 run_loop.QuitClosure()); 232 run_loop.QuitClosure());
232 233
233 GURL url = net::URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1); 234 GURL url = net::URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1);
234 network_delegate()->set_expected_url(url); 235 network_delegate()->set_expected_url(url);
235 network_delegate()->ExpectHostname(kHostname); 236 network_delegate()->ExpectHostname(kHostname);
236 network_delegate()->ExpectHostname(kSecondRequestHostname); 237 network_delegate()->ExpectHostname(kSecondRequestHostname);
237 238
238 CertificateErrorReporter reporter(context(), url); 239 CertificateErrorReporter reporter(
240 context(), url, CertificateErrorReporter::DO_NOT_SEND_COOKIES);
239 241
240 EXPECT_EQ(0, network_delegate()->num_requests()); 242 EXPECT_EQ(0, network_delegate()->num_requests());
241 243
242 reporter.SendReport(CertificateErrorReporter::REPORT_TYPE_PINNING_VIOLATION, 244 reporter.SendReport(CertificateErrorReporter::REPORT_TYPE_PINNING_VIOLATION,
243 kHostname, GetTestSSLInfo()); 245 kHostname, GetTestSSLInfo());
244 reporter.SendReport(CertificateErrorReporter::REPORT_TYPE_PINNING_VIOLATION, 246 reporter.SendReport(CertificateErrorReporter::REPORT_TYPE_PINNING_VIOLATION,
245 kSecondRequestHostname, GetTestSSLInfo()); 247 kSecondRequestHostname, GetTestSSLInfo());
246 248
247 run_loop.Run(); 249 run_loop.Run();
248 250
249 EXPECT_EQ(2, network_delegate()->num_requests()); 251 EXPECT_EQ(2, network_delegate()->num_requests());
250 } 252 }
251 253
252 // Test that pending URLRequests get cleaned up when the reporter is 254 // Test that pending URLRequests get cleaned up when the reporter is
253 // deleted. 255 // deleted.
254 TEST_F(CertificateErrorReporterTest, PendingRequestGetsDeleted) { 256 TEST_F(CertificateErrorReporterTest, PendingRequestGetsDeleted) {
255 base::RunLoop run_loop; 257 base::RunLoop run_loop;
256 network_delegate()->set_url_request_destroyed_callback( 258 network_delegate()->set_url_request_destroyed_callback(
257 run_loop.QuitClosure()); 259 run_loop.QuitClosure());
258 260
259 GURL url = net::URLRequestMockHTTPJob::GetMockUrlWithFailure( 261 GURL url = net::URLRequestMockHTTPJob::GetMockUrlWithFailure(
260 base::FilePath(FILE_PATH_LITERAL("empty.html")), 262 base::FilePath(FILE_PATH_LITERAL("empty.html")),
261 net::URLRequestMockHTTPJob::START, net::ERR_IO_PENDING); 263 net::URLRequestMockHTTPJob::START, net::ERR_IO_PENDING);
262 network_delegate()->set_expected_url(url); 264 network_delegate()->set_expected_url(url);
263 network_delegate()->ExpectHostname(kHostname); 265 network_delegate()->ExpectHostname(kHostname);
264 266
265 EXPECT_EQ(0, network_delegate()->num_requests()); 267 EXPECT_EQ(0, network_delegate()->num_requests());
266 268
267 scoped_ptr<CertificateErrorReporter> reporter( 269 scoped_ptr<CertificateErrorReporter> reporter(new CertificateErrorReporter(
268 new CertificateErrorReporter(context(), url)); 270 context(), url, CertificateErrorReporter::DO_NOT_SEND_COOKIES));
269 reporter->SendReport(CertificateErrorReporter::REPORT_TYPE_PINNING_VIOLATION, 271 reporter->SendReport(CertificateErrorReporter::REPORT_TYPE_PINNING_VIOLATION,
270 kHostname, GetTestSSLInfo()); 272 kHostname, GetTestSSLInfo());
271 reporter.reset(); 273 reporter.reset();
272 274
273 run_loop.Run(); 275 run_loop.Run();
274 276
275 EXPECT_EQ(1, network_delegate()->num_requests()); 277 EXPECT_EQ(1, network_delegate()->num_requests());
276 } 278 }
277 279
278 // Test that a request that returns an error gets cleaned up. 280 // Test that a request that returns an error gets cleaned up.
279 TEST_F(CertificateErrorReporterTest, ErroredRequestGetsDeleted) { 281 TEST_F(CertificateErrorReporterTest, ErroredRequestGetsDeleted) {
280 GURL url = net::URLRequestFailedJob::GetMockHttpsUrl(net::ERR_FAILED); 282 GURL url = net::URLRequestFailedJob::GetMockHttpsUrl(net::ERR_FAILED);
281 SendReport(network_delegate(), context(), kHostname, url, 0); 283 SendReport(network_delegate(), context(), kHostname, url, 0);
282 } 284 }
283 285
284 } // namespace 286 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/net/certificate_error_reporter.cc ('k') | chrome/browser/net/chrome_fraudulent_certificate_reporter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698