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

Unified Diff: net/http/transport_security_state_unittest.cc

Issue 2365353004: Add Content-Type header to net::ReportSender reports (Closed)
Patch Set: make content type a required parameter to Send() Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: net/http/transport_security_state_unittest.cc
diff --git a/net/http/transport_security_state_unittest.cc b/net/http/transport_security_state_unittest.cc
index 2026aa5b7038c673a03a27655ad2f825f5bb134b..78db8bade3f06f89cad0ebd90177391500f28f96 100644
--- a/net/http/transport_security_state_unittest.cc
+++ b/net/http/transport_security_state_unittest.cc
@@ -90,9 +90,12 @@ class MockCertificateReportSender
MockCertificateReportSender() {}
~MockCertificateReportSender() override {}
- void Send(const GURL& report_uri, const std::string& report) override {
+ void Send(const GURL& report_uri,
+ const std::string& content_type,
+ const std::string& report) override {
latest_report_uri_ = report_uri;
latest_report_ = report;
+ latest_content_type_ = content_type;
}
void SetErrorCallback(
@@ -105,10 +108,12 @@ class MockCertificateReportSender
const GURL& latest_report_uri() { return latest_report_uri_; }
const std::string& latest_report() { return latest_report_; }
+ const std::string& latest_content_type() { return latest_content_type_; }
private:
GURL latest_report_uri_;
std::string latest_report_;
+ std::string latest_content_type_;
};
// A mock ReportSenderInterface that simulates a net error on every report sent.
@@ -121,7 +126,9 @@ class MockFailingCertificateReportSender
int net_error() { return net_error_; }
// TransportSecurityState::ReportSenderInterface:
- void Send(const GURL& report_uri, const std::string& report) override {
+ void Send(const GURL& report_uri,
+ const std::string& content_type,
+ const std::string& report) override {
ASSERT_FALSE(error_callback_.is_null());
error_callback_.Run(report_uri, net_error_);
}
@@ -339,6 +346,7 @@ void CheckExpectStapleReport(TransportSecurityState* state,
state->SetReportSender(reporter);
state->CheckExpectStaple(host_port, ssl_info, ocsp_response);
EXPECT_EQ(GURL(kExpectStapleStaticReportURI), reporter->latest_report_uri());
+ EXPECT_EQ("application/json", reporter->latest_content_type());
std::string serialized_report = reporter->latest_report();
EXPECT_NO_FATAL_FAILURE(CheckSerializedExpectStapleReport(
serialized_report, host_port, ssl_info, ocsp_response, response_status,
@@ -1444,6 +1452,7 @@ TEST_F(TransportSecurityStateTest, HPKPReporting) {
EXPECT_EQ(report_uri, mock_report_sender.latest_report_uri());
std::string report = mock_report_sender.latest_report();
ASSERT_FALSE(report.empty());
+ EXPECT_EQ("application/json", mock_report_sender.latest_content_type());
ASSERT_NO_FATAL_FAILURE(CheckHPKPReport(report, host_port_pair, true, kHost,
cert1.get(), cert2.get(),
good_hashes));
@@ -1459,6 +1468,7 @@ TEST_F(TransportSecurityStateTest, HPKPReporting) {
EXPECT_EQ(report_uri, mock_report_sender.latest_report_uri());
report = mock_report_sender.latest_report();
ASSERT_FALSE(report.empty());
+ EXPECT_EQ("application/json", mock_report_sender.latest_content_type());
ASSERT_NO_FATAL_FAILURE(CheckHPKPReport(report, subdomain_host_port_pair,
true, kHost, cert1.get(), cert2.get(),
good_hashes));
@@ -1569,6 +1579,7 @@ TEST_F(TransportSecurityStateTest, HPKPReportOnly) {
EXPECT_EQ(report_uri, mock_report_sender.latest_report_uri());
std::string report = mock_report_sender.latest_report();
ASSERT_FALSE(report.empty());
+ EXPECT_EQ("application/json", mock_report_sender.latest_content_type());
ASSERT_NO_FATAL_FAILURE(CheckHPKPReport(report, host_port_pair, true, kHost,
cert1.get(), cert2.get(),
ssl_info.public_key_hashes));
@@ -1695,6 +1706,7 @@ TEST_F(TransportSecurityStateTest, PreloadedPKPReportUri) {
std::string report = mock_report_sender.latest_report();
ASSERT_FALSE(report.empty());
+ EXPECT_EQ("application/json", mock_report_sender.latest_content_type());
ASSERT_NO_FATAL_FAILURE(CheckHPKPReport(
report, host_port_pair, pkp_state.include_subdomains, pkp_state.domain,
cert1.get(), cert2.get(), pkp_state.spki_hashes));

Powered by Google App Engine
This is Rietveld 408576698