| 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 "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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 crypto::curve25519::ScalarBaseMult(server_private_key_, server_public_key_); | 56 crypto::curve25519::ScalarBaseMult(server_private_key_, server_public_key_); |
| 57 } | 57 } |
| 58 | 58 |
| 59 ~CertificateErrorReporterTest() override {} | 59 ~CertificateErrorReporterTest() override {} |
| 60 | 60 |
| 61 protected: | 61 protected: |
| 62 uint8_t server_public_key_[32]; | 62 uint8_t server_public_key_[32]; |
| 63 uint8_t server_private_key_[32]; | 63 uint8_t server_private_key_[32]; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 // Test that CertificateErrorReporter::SendPinningViolationReport sends | |
| 67 // a plaintext report for pinning violation reports. | |
| 68 TEST_F(CertificateErrorReporterTest, PinningViolationSendReport) { | |
| 69 GURL url(kDummyHttpReportUri); | |
| 70 MockCertificateReportSender* mock_report_sender = | |
| 71 new MockCertificateReportSender(); | |
| 72 CertificateErrorReporter reporter(url, server_public_key_, | |
| 73 kServerPublicKeyTestVersion, | |
| 74 make_scoped_ptr(mock_report_sender)); | |
| 75 reporter.SendPinningViolationReport(kDummyReport); | |
| 76 EXPECT_EQ(mock_report_sender->latest_report_uri(), url); | |
| 77 EXPECT_EQ(mock_report_sender->latest_report(), kDummyReport); | |
| 78 } | |
| 79 | |
| 80 // Test that CertificateErrorReporter::SendExtendedReportingReport sends | 66 // Test that CertificateErrorReporter::SendExtendedReportingReport sends |
| 81 // an encrypted or plaintext extended reporting report as appropriate. | 67 // an encrypted or plaintext extended reporting report as appropriate. |
| 82 TEST_F(CertificateErrorReporterTest, ExtendedReportingSendReport) { | 68 TEST_F(CertificateErrorReporterTest, ExtendedReportingSendReport) { |
| 83 // Data should not be encrypted when sent to an HTTPS URL. | 69 // Data should not be encrypted when sent to an HTTPS URL. |
| 84 MockCertificateReportSender* mock_report_sender = | 70 MockCertificateReportSender* mock_report_sender = |
| 85 new MockCertificateReportSender(); | 71 new MockCertificateReportSender(); |
| 86 GURL https_url(kDummyHttpsReportUri); | 72 GURL https_url(kDummyHttpsReportUri); |
| 87 CertificateErrorReporter https_reporter(https_url, server_public_key_, | 73 CertificateErrorReporter https_reporter(https_url, server_public_key_, |
| 88 kServerPublicKeyTestVersion, | 74 kServerPublicKeyTestVersion, |
| 89 make_scoped_ptr(mock_report_sender)); | 75 make_scoped_ptr(mock_report_sender)); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 std::string(reinterpret_cast<const char*>(kSerializedEncryptedReport), | 267 std::string(reinterpret_cast<const char*>(kSerializedEncryptedReport), |
| 282 sizeof(kSerializedEncryptedReport)))); | 268 sizeof(kSerializedEncryptedReport)))); |
| 283 ASSERT_TRUE( | 269 ASSERT_TRUE( |
| 284 chrome_browser_net::CertificateErrorReporter:: | 270 chrome_browser_net::CertificateErrorReporter:: |
| 285 DecryptCertificateErrorReport(server_private_key_, encrypted_request, | 271 DecryptCertificateErrorReport(server_private_key_, encrypted_request, |
| 286 &decrypted_serialized_report)); | 272 &decrypted_serialized_report)); |
| 287 } | 273 } |
| 288 #endif | 274 #endif |
| 289 | 275 |
| 290 } // namespace | 276 } // namespace |
| OLD | NEW |