| OLD | NEW |
| 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 "components/certificate_reporting/error_reporter.h" | 5 #include "components/certificate_reporting/error_reporter.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "components/certificate_reporting/encrypted_cert_logger.pb.h" | 17 #include "components/certificate_reporting/encrypted_cert_logger.pb.h" |
| 18 #include "crypto/curve25519.h" | 18 #include "crypto/curve25519.h" |
| 19 #include "net/url_request/certificate_report_sender.h" | 19 #include "net/url_request/report_sender.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 21 |
| 22 namespace certificate_reporting { | 22 namespace certificate_reporting { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 const char kDummyHttpReportUri[] = "http://example.test"; | 26 const char kDummyHttpReportUri[] = "http://example.test"; |
| 27 const char kDummyHttpsReportUri[] = "https://example.test"; | 27 const char kDummyHttpsReportUri[] = "https://example.test"; |
| 28 const char kDummyReport[] = "a dummy report"; | 28 const char kDummyReport[] = "a dummy report"; |
| 29 const uint32_t kServerPublicKeyTestVersion = 16; | 29 const uint32_t kServerPublicKeyTestVersion = 16; |
| 30 | 30 |
| 31 // A mock CertificateReportSender that keeps track of the last report | 31 // A mock ReportSender that keeps track of the last report |
| 32 // sent. | 32 // sent. |
| 33 class MockCertificateReportSender : public net::CertificateReportSender { | 33 class MockCertificateReportSender : public net::ReportSender { |
| 34 public: | 34 public: |
| 35 MockCertificateReportSender() | 35 MockCertificateReportSender() |
| 36 : net::CertificateReportSender(nullptr, DO_NOT_SEND_COOKIES) {} | 36 : net::ReportSender(nullptr, DO_NOT_SEND_COOKIES) {} |
| 37 ~MockCertificateReportSender() override {} | 37 ~MockCertificateReportSender() override {} |
| 38 | 38 |
| 39 void Send(const GURL& report_uri, const std::string& report) override { | 39 void Send(const GURL& report_uri, const std::string& report) override { |
| 40 latest_report_uri_ = report_uri; | 40 latest_report_uri_ = report_uri; |
| 41 latest_report_ = report; | 41 latest_report_ = report; |
| 42 } | 42 } |
| 43 | 43 |
| 44 const GURL& latest_report_uri() { return latest_report_uri_; } | 44 const GURL& latest_report_uri() { return latest_report_uri_; } |
| 45 | 45 |
| 46 const std::string& latest_report() { return latest_report_; } | 46 const std::string& latest_report() { return latest_report_; } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 ASSERT_TRUE(encrypted_request.ParseFromString( | 263 ASSERT_TRUE(encrypted_request.ParseFromString( |
| 264 std::string(reinterpret_cast<const char*>(kSerializedEncryptedReport), | 264 std::string(reinterpret_cast<const char*>(kSerializedEncryptedReport), |
| 265 sizeof(kSerializedEncryptedReport)))); | 265 sizeof(kSerializedEncryptedReport)))); |
| 266 ASSERT_TRUE(ErrorReporter::DecryptErrorReport( | 266 ASSERT_TRUE(ErrorReporter::DecryptErrorReport( |
| 267 server_private_key_, encrypted_request, &decrypted_serialized_report)); | 267 server_private_key_, encrypted_request, &decrypted_serialized_report)); |
| 268 } | 268 } |
| 269 | 269 |
| 270 } // namespace | 270 } // namespace |
| 271 | 271 |
| 272 } // namespace certificate_reporting | 272 } // namespace certificate_reporting |
| OLD | NEW |