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

Unified Diff: net/http/transport_security_state_unittest.cc

Issue 2365353004: Add Content-Type header to net::ReportSender reports (Closed)
Patch Set: eroman comment 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
« no previous file with comments | « net/http/transport_security_state.cc ('k') | net/url_request/report_sender.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..35536d91871a132c2b48ad792d7342cb6145b81c 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,
+ base::StringPiece content_type,
+ base::StringPiece report) override {
latest_report_uri_ = report_uri;
- latest_report_ = report;
+ report.CopyToString(&latest_report_);
+ content_type.CopyToString(&latest_content_type_);
}
void SetErrorCallback(
@@ -101,14 +104,17 @@ class MockCertificateReportSender
void Clear() {
latest_report_uri_ = GURL();
latest_report_ = std::string();
+ latest_content_type_ = std::string();
}
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 +127,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,
+ base::StringPiece content_type,
+ base::StringPiece report) override {
ASSERT_FALSE(error_callback_.is_null());
error_callback_.Run(report_uri, net_error_);
}
@@ -339,6 +347,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; charset=utf-8", 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 +1453,8 @@ 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; charset=utf-8",
+ 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 +1470,8 @@ 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; charset=utf-8",
+ 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 +1582,8 @@ 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; charset=utf-8",
+ 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 +1710,8 @@ TEST_F(TransportSecurityStateTest, PreloadedPKPReportUri) {
std::string report = mock_report_sender.latest_report();
ASSERT_FALSE(report.empty());
+ EXPECT_EQ("application/json; charset=utf-8",
+ 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));
« no previous file with comments | « net/http/transport_security_state.cc ('k') | net/url_request/report_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698