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

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

Issue 2026213002: Refactor CertificateReportSender (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 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"
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/test/histogram_tester.h" 14 #include "base/test/histogram_tester.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/common/chrome_features.h" 16 #include "chrome/common/chrome_features.h"
17 #include "content/public/test/test_browser_thread_bundle.h" 17 #include "content/public/test/test_browser_thread_bundle.h"
18 #include "net/base/test_data_directory.h" 18 #include "net/base/test_data_directory.h"
19 #include "net/ssl/signed_certificate_timestamp_and_status.h" 19 #include "net/ssl/signed_certificate_timestamp_and_status.h"
20 #include "net/test/cert_test_util.h" 20 #include "net/test/cert_test_util.h"
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/certificate_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.ExpectCTReportFailure";
32 32
33 // A test CertificateReportSender 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::CertificateReportSender { 35 class TestCertificateReportSender : public net::ReportSender {
36 public: 36 public:
37 TestCertificateReportSender() 37 TestCertificateReportSender()
38 : CertificateReportSender( 38 : ReportSender(nullptr, net::ReportSender::DO_NOT_SEND_COOKIES) {}
39 nullptr,
40 net::CertificateReportSender::DO_NOT_SEND_COOKIES) {}
41 ~TestCertificateReportSender() override {} 39 ~TestCertificateReportSender() override {}
42 40
43 void Send(const GURL& report_uri, 41 void Send(const GURL& report_uri,
44 const std::string& serialized_report) override { 42 const std::string& serialized_report) override {
45 latest_report_uri_ = report_uri; 43 latest_report_uri_ = report_uri;
46 latest_serialized_report_ = serialized_report; 44 latest_serialized_report_ = serialized_report;
47 } 45 }
48 46
49 const GURL& latest_report_uri() { return latest_report_uri_; } 47 const GURL& latest_report_uri() { return latest_report_uri_; }
50 48
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 reporter.OnExpectCTFailed(host_port, report_uri, ssl_info); 463 reporter.OnExpectCTFailed(host_port, report_uri, ssl_info);
466 EXPECT_EQ(report_uri, sender->latest_report_uri()); 464 EXPECT_EQ(report_uri, sender->latest_report_uri());
467 EXPECT_FALSE(sender->latest_serialized_report().empty()); 465 EXPECT_FALSE(sender->latest_serialized_report().empty());
468 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport( 466 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport(
469 sender->latest_serialized_report(), host_port, ssl_info)); 467 sender->latest_serialized_report(), host_port, ssl_info));
470 468
471 histograms.ExpectTotalCount(kFailureHistogramName, 0); 469 histograms.ExpectTotalCount(kFailureHistogramName, 0);
472 histograms.ExpectTotalCount(kSendHistogramName, 1); 470 histograms.ExpectTotalCount(kSendHistogramName, 1);
473 histograms.ExpectBucketCount(kSendHistogramName, true, 1); 471 histograms.ExpectBucketCount(kSendHistogramName, true, 1);
474 } 472 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/chrome_expect_ct_reporter.cc ('k') | components/certificate_reporting/error_reporter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698