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

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

Issue 1267383002: Allow preloaded pins to contain report URIs; remove special-case reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase fixup Created 5 years, 4 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « chrome/browser/net/certificate_error_reporter.cc ('k') | chrome/browser/profiles/off_the_record_profile_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698