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

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

Issue 2120683002: Fix up certificate error reporting histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unused ios certificate_reporting dependency Created 4 years, 5 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/chrome_expect_ct_reporter.cc ('k') | components/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ssl/chrome_expect_ct_reporter.h" 5 #include "chrome/browser/ssl/chrome_expect_ct_reporter.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 10 matching lines...) Expand all
21 #include "net/test/url_request/url_request_failed_job.h" 21 #include "net/test/url_request/url_request_failed_job.h"
22 #include "net/url_request/report_sender.h" 22 #include "net/url_request/report_sender.h"
23 #include "net/url_request/url_request_filter.h" 23 #include "net/url_request/url_request_filter.h"
24 #include "net/url_request/url_request_test_util.h" 24 #include "net/url_request/url_request_test_util.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 27
28 namespace { 28 namespace {
29 29
30 const char kSendHistogramName[] = "SSL.ExpectCTReportSendingAttempt"; 30 const char kSendHistogramName[] = "SSL.ExpectCTReportSendingAttempt";
31 const char kFailureHistogramName[] = "SSL.ExpectCTReportFailure"; 31 const char kFailureHistogramName[] = "SSL.ExpectCTReportFailure2";
32 32
33 // A test ReportSender that exposes the latest report URI and 33 // A test ReportSender that exposes the latest report URI and
34 // serialized report to be sent. 34 // serialized report to be sent.
35 class TestCertificateReportSender : public net::ReportSender { 35 class TestCertificateReportSender : public net::ReportSender {
36 public: 36 public:
37 TestCertificateReportSender() 37 TestCertificateReportSender()
38 : ReportSender(nullptr, net::ReportSender::DO_NOT_SEND_COOKIES) {} 38 : ReportSender(nullptr, net::ReportSender::DO_NOT_SEND_COOKIES) {}
39 ~TestCertificateReportSender() override {} 39 ~TestCertificateReportSender() override {}
40 40
41 void Send(const GURL& report_uri, 41 void Send(const GURL& report_uri,
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 net::GetTestCertsDirectory(), "localhost_cert.pem"); 392 net::GetTestCertsDirectory(), "localhost_cert.pem");
393 393
394 net::HostPortPair host_port("example.test", 443); 394 net::HostPortPair host_port("example.test", 443);
395 GURL report_uri( 395 GURL report_uri(
396 net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_FAILED)); 396 net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_FAILED));
397 397
398 SendReport(&reporter, host_port, report_uri, ssl_info); 398 SendReport(&reporter, host_port, report_uri, ssl_info);
399 399
400 histograms.ExpectTotalCount(kFailureHistogramName, 1); 400 histograms.ExpectTotalCount(kFailureHistogramName, 1);
401 histograms.ExpectBucketCount(kFailureHistogramName, 401 histograms.ExpectBucketCount(kFailureHistogramName,
402 net::ERR_CONNECTION_FAILED, 1); 402 -net::ERR_CONNECTION_FAILED, 1);
403 histograms.ExpectTotalCount(kSendHistogramName, 1); 403 histograms.ExpectTotalCount(kSendHistogramName, 1);
404 histograms.ExpectBucketCount(kSendHistogramName, true, 1); 404 histograms.ExpectBucketCount(kSendHistogramName, true, 1);
405 } 405 }
406 406
407 // Test that a sent report has the right format. 407 // Test that a sent report has the right format.
408 TEST(ChromeExpectCTReporterTest, SendReport) { 408 TEST(ChromeExpectCTReporterTest, SendReport) {
409 base::HistogramTester histograms; 409 base::HistogramTester histograms;
410 histograms.ExpectTotalCount(kFailureHistogramName, 0); 410 histograms.ExpectTotalCount(kFailureHistogramName, 0);
411 histograms.ExpectTotalCount(kSendHistogramName, 0); 411 histograms.ExpectTotalCount(kSendHistogramName, 0);
412 412
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 reporter.OnExpectCTFailed(host_port, report_uri, ssl_info); 463 reporter.OnExpectCTFailed(host_port, report_uri, ssl_info);
464 EXPECT_EQ(report_uri, sender->latest_report_uri()); 464 EXPECT_EQ(report_uri, sender->latest_report_uri());
465 EXPECT_FALSE(sender->latest_serialized_report().empty()); 465 EXPECT_FALSE(sender->latest_serialized_report().empty());
466 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport( 466 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport(
467 sender->latest_serialized_report(), host_port, ssl_info)); 467 sender->latest_serialized_report(), host_port, ssl_info));
468 468
469 histograms.ExpectTotalCount(kFailureHistogramName, 0); 469 histograms.ExpectTotalCount(kFailureHistogramName, 0);
470 histograms.ExpectTotalCount(kSendHistogramName, 1); 470 histograms.ExpectTotalCount(kSendHistogramName, 1);
471 histograms.ExpectBucketCount(kSendHistogramName, true, 1); 471 histograms.ExpectBucketCount(kSendHistogramName, true, 1);
472 } 472 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/chrome_expect_ct_reporter.cc ('k') | components/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698