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

Side by Side Diff: chrome/browser/ssl/chrome_expect_ct_reporter_unittest.cc

Issue 2963783003: Revert of Update SCT serialization format in Expect-CT reports (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « chrome/browser/ssl/chrome_expect_ct_reporter.cc ('k') | net/cert/ct_serialization.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ssl/chrome_expect_ct_reporter.h" 5 #include "chrome/browser/ssl/chrome_expect_ct_reporter.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/test/histogram_tester.h" 14 #include "base/test/histogram_tester.h"
15 #include "base/test/scoped_feature_list.h" 15 #include "base/test/scoped_feature_list.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/common/chrome_features.h" 17 #include "chrome/common/chrome_features.h"
18 #include "content/public/test/test_browser_thread_bundle.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
19 #include "net/cert/ct_serialization.h"
20 #include "net/cert/signed_certificate_timestamp_and_status.h" 19 #include "net/cert/signed_certificate_timestamp_and_status.h"
21 #include "net/test/cert_test_util.h" 20 #include "net/test/cert_test_util.h"
22 #include "net/test/test_data_directory.h" 21 #include "net/test/test_data_directory.h"
23 #include "net/test/url_request/url_request_failed_job.h" 22 #include "net/test/url_request/url_request_failed_job.h"
24 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" 23 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
25 #include "net/url_request/report_sender.h" 24 #include "net/url_request/report_sender.h"
26 #include "net/url_request/url_request_filter.h" 25 #include "net/url_request/url_request_filter.h"
27 #include "net/url_request/url_request_test_util.h" 26 #include "net/url_request/url_request_test_util.h"
28 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
29 #include "url/gurl.h" 28 #include "url/gurl.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 EXPECT_EQ(pem_encoded_chain[i], cert_pem); 103 EXPECT_EQ(pem_encoded_chain[i], cert_pem);
105 } 104 }
106 } 105 }
107 106
108 // Converts the string value of a reported SCT's origin to a 107 // Converts the string value of a reported SCT's origin to a
109 // net::ct::SignedCertificateTimestamp::Origin value. 108 // net::ct::SignedCertificateTimestamp::Origin value.
110 net::ct::SignedCertificateTimestamp::Origin SCTOriginStringToOrigin( 109 net::ct::SignedCertificateTimestamp::Origin SCTOriginStringToOrigin(
111 const std::string& origin_string) { 110 const std::string& origin_string) {
112 if (origin_string == "embedded") 111 if (origin_string == "embedded")
113 return net::ct::SignedCertificateTimestamp::SCT_EMBEDDED; 112 return net::ct::SignedCertificateTimestamp::SCT_EMBEDDED;
114 if (origin_string == "tls-extension") 113 if (origin_string == "from-tls-extension")
115 return net::ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION; 114 return net::ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION;
116 if (origin_string == "ocsp") 115 if (origin_string == "from-ocsp-response")
117 return net::ct::SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE; 116 return net::ct::SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE;
118 NOTREACHED(); 117 NOTREACHED();
119 return net::ct::SignedCertificateTimestamp::SCT_EMBEDDED; 118 return net::ct::SignedCertificateTimestamp::SCT_EMBEDDED;
120 } 119 }
121 120
122 // Checks that an SCT |sct| appears with status |status| in |report_list|, a 121 // Checks that an SCT |sct| appears (with the format determined by
123 // list of SCTs from an Expect-CT report. 122 // |status|) in |report_list|, a list of SCTs from an Expect CT
124 ::testing::AssertionResult FindSCTInReportList( 123 // report. |status| determines the format in that only certain fields
125 const scoped_refptr<net::ct::SignedCertificateTimestamp>& expected_sct, 124 // are reported for certain verify statuses; SCTs from unknown logs
126 net::ct::SCTVerifyStatus expected_status, 125 // contain very little information, for example, to avoid compromising
126 // privacy.
127 void FindSCTInReportList(
128 const scoped_refptr<net::ct::SignedCertificateTimestamp>& sct,
129 net::ct::SCTVerifyStatus status,
127 const base::ListValue& report_list) { 130 const base::ListValue& report_list) {
128 std::string expected_serialized_sct; 131 bool found = false;
129 net::ct::EncodeSignedCertificateTimestamp(expected_sct, 132 for (size_t i = 0; !found && i < report_list.GetSize(); i++) {
130 &expected_serialized_sct); 133 const base::DictionaryValue* report_sct;
134 ASSERT_TRUE(report_list.GetDictionary(i, &report_sct));
131 135
132 for (size_t i = 0; i < report_list.GetSize(); i++) { 136 std::string origin;
133 const base::DictionaryValue* report_sct; 137 ASSERT_TRUE(report_sct->GetString("origin", &origin));
134 if (!report_list.GetDictionary(i, &report_sct)) {
135 return ::testing::AssertionFailure()
136 << "Failed to get dictionary value from report SCT list";
137 }
138 138
139 std::string serialized_sct; 139 switch (status) {
140 EXPECT_TRUE(report_sct->GetString("serialized_sct", &serialized_sct)); 140 case net::ct::SCT_STATUS_LOG_UNKNOWN:
141 std::string decoded_serialized_sct; 141 // SCTs from unknown logs only have an origin.
142 EXPECT_TRUE(base::Base64Decode(serialized_sct, &decoded_serialized_sct)); 142 EXPECT_FALSE(report_sct->HasKey("sct"));
143 if (decoded_serialized_sct != expected_serialized_sct) 143 EXPECT_FALSE(report_sct->HasKey("id"));
144 continue; 144 if (SCTOriginStringToOrigin(origin) == sct->origin)
145 found = true;
146 break;
145 147
146 std::string source;
147 EXPECT_TRUE(report_sct->GetString("source", &source));
148 EXPECT_EQ(expected_sct->origin, SCTOriginStringToOrigin(source));
149
150 std::string report_status;
151 EXPECT_TRUE(report_sct->GetString("status", &report_status));
152 switch (expected_status) {
153 case net::ct::SCT_STATUS_LOG_UNKNOWN:
154 EXPECT_EQ("unknown", report_status);
155 break;
156 case net::ct::SCT_STATUS_INVALID_SIGNATURE: 148 case net::ct::SCT_STATUS_INVALID_SIGNATURE:
157 case net::ct::SCT_STATUS_INVALID_TIMESTAMP: { 149 case net::ct::SCT_STATUS_INVALID_TIMESTAMP: {
158 EXPECT_EQ("invalid", report_status); 150 // Invalid SCTs have a log id and an origin and nothing else.
151 EXPECT_FALSE(report_sct->HasKey("sct"));
152 std::string id_base64;
153 ASSERT_TRUE(report_sct->GetString("id", &id_base64));
154 std::string id;
155 ASSERT_TRUE(base::Base64Decode(id_base64, &id));
156 if (SCTOriginStringToOrigin(origin) == sct->origin && id == sct->log_id)
157 found = true;
159 break; 158 break;
160 } 159 }
160
161 case net::ct::SCT_STATUS_OK: { 161 case net::ct::SCT_STATUS_OK: {
162 EXPECT_EQ("valid", report_status); 162 // Valid SCTs have the full SCT.
163 const base::DictionaryValue* report_sct_object;
164 ASSERT_TRUE(report_sct->GetDictionary("sct", &report_sct_object));
165 int version;
166 ASSERT_TRUE(report_sct_object->GetInteger("sct_version", &version));
167 std::string id_base64;
168 ASSERT_TRUE(report_sct_object->GetString("id", &id_base64));
169 std::string id;
170 ASSERT_TRUE(base::Base64Decode(id_base64, &id));
171 std::string extensions_base64;
172 ASSERT_TRUE(
173 report_sct_object->GetString("extensions", &extensions_base64));
174 std::string extensions;
175 ASSERT_TRUE(base::Base64Decode(extensions_base64, &extensions));
176 std::string signature_data_base64;
177 ASSERT_TRUE(
178 report_sct_object->GetString("signature", &signature_data_base64));
179 std::string signature_data;
180 ASSERT_TRUE(base::Base64Decode(signature_data_base64, &signature_data));
181
182 if (version == sct->version &&
183 SCTOriginStringToOrigin(origin) == sct->origin &&
184 id == sct->log_id && extensions == sct->extensions &&
185 signature_data == sct->signature.signature_data) {
186 found = true;
187 }
163 break; 188 break;
164 } 189 }
165 case net::ct::SCT_STATUS_NONE: 190 default:
166 NOTREACHED(); 191 NOTREACHED();
167 } 192 }
168 return ::testing::AssertionSuccess();
169 } 193 }
170 194 EXPECT_TRUE(found);
171 return ::testing::AssertionFailure() << "Failed to find SCT in report list";
172 } 195 }
173 196
174 // Checks that all |expected_scts| appears in the given lists of SCTs 197 // Checks that all |expected_scts| appears in the given lists of SCTs
175 // from an Expect CT report. 198 // from an Expect CT report.
176 void CheckReportSCTs( 199 void CheckReportSCTs(
177 const net::SignedCertificateTimestampAndStatusList& expected_scts, 200 const net::SignedCertificateTimestampAndStatusList& expected_scts,
178 const base::ListValue& scts) { 201 const base::ListValue& unknown_scts,
179 EXPECT_EQ(expected_scts.size(), scts.GetSize()); 202 const base::ListValue& invalid_scts,
203 const base::ListValue& valid_scts) {
204 EXPECT_EQ(
205 expected_scts.size(),
206 unknown_scts.GetSize() + invalid_scts.GetSize() + valid_scts.GetSize());
180 for (const auto& expected_sct : expected_scts) { 207 for (const auto& expected_sct : expected_scts) {
181 ASSERT_TRUE( 208 switch (expected_sct.status) {
182 FindSCTInReportList(expected_sct.sct, expected_sct.status, scts)); 209 case net::ct::SCT_STATUS_LOG_UNKNOWN:
210 ASSERT_NO_FATAL_FAILURE(FindSCTInReportList(
211 expected_sct.sct, net::ct::SCT_STATUS_LOG_UNKNOWN, unknown_scts));
212 break;
213 case net::ct::SCT_STATUS_INVALID_SIGNATURE:
214 ASSERT_NO_FATAL_FAILURE(FindSCTInReportList(
215 expected_sct.sct, net::ct::SCT_STATUS_INVALID_SIGNATURE,
216 invalid_scts));
217 break;
218 case net::ct::SCT_STATUS_INVALID_TIMESTAMP:
219 ASSERT_NO_FATAL_FAILURE(FindSCTInReportList(
220 expected_sct.sct, net::ct::SCT_STATUS_INVALID_TIMESTAMP,
221 invalid_scts));
222 break;
223 case net::ct::SCT_STATUS_OK:
224 ASSERT_NO_FATAL_FAILURE(FindSCTInReportList(
225 expected_sct.sct, net::ct::SCT_STATUS_OK, valid_scts));
226 break;
227 default:
228 NOTREACHED();
229 }
183 } 230 }
184 } 231 }
185 232
186 // Checks that the |serialized_report| deserializes properly and 233 // Checks that the |serialized_report| deserializes properly and
187 // contains the correct information (hostname, port, served and 234 // contains the correct information (hostname, port, served and
188 // validated certificate chains, SCTs) for the given |host_port| and 235 // validated certificate chains, SCTs) for the given |host_port| and
189 // |ssl_info|. 236 // |ssl_info|.
190 void CheckExpectCTReport(const std::string& serialized_report, 237 void CheckExpectCTReport(const std::string& serialized_report,
191 const net::HostPortPair& host_port, 238 const net::HostPortPair& host_port,
192 const std::string& expiration, 239 const std::string& expiration,
193 const net::SSLInfo& ssl_info) { 240 const net::SSLInfo& ssl_info) {
194 std::unique_ptr<base::Value> value(base::JSONReader::Read(serialized_report)); 241 std::unique_ptr<base::Value> value(base::JSONReader::Read(serialized_report));
195 ASSERT_TRUE(value); 242 ASSERT_TRUE(value);
196 ASSERT_TRUE(value->IsType(base::Value::Type::DICTIONARY)); 243 ASSERT_TRUE(value->IsType(base::Value::Type::DICTIONARY));
197 244
198 base::DictionaryValue* outer_report_dict;
199 ASSERT_TRUE(value->GetAsDictionary(&outer_report_dict));
200
201 base::DictionaryValue* report_dict; 245 base::DictionaryValue* report_dict;
202 ASSERT_TRUE( 246 ASSERT_TRUE(value->GetAsDictionary(&report_dict));
203 outer_report_dict->GetDictionary("expect-ct-report", &report_dict));
204 247
205 std::string report_hostname; 248 std::string report_hostname;
206 EXPECT_TRUE(report_dict->GetString("hostname", &report_hostname)); 249 EXPECT_TRUE(report_dict->GetString("hostname", &report_hostname));
207 EXPECT_EQ(host_port.host(), report_hostname); 250 EXPECT_EQ(host_port.host(), report_hostname);
208 int report_port; 251 int report_port;
209 EXPECT_TRUE(report_dict->GetInteger("port", &report_port)); 252 EXPECT_TRUE(report_dict->GetInteger("port", &report_port));
210 EXPECT_EQ(host_port.port(), report_port); 253 EXPECT_EQ(host_port.port(), report_port);
211 254
212 std::string report_expiration; 255 std::string report_expiration;
213 EXPECT_TRUE( 256 EXPECT_TRUE(
214 report_dict->GetString("effective-expiration-date", &report_expiration)); 257 report_dict->GetString("effective-expiration-date", &report_expiration));
215 EXPECT_EQ(expiration, report_expiration); 258 EXPECT_EQ(expiration, report_expiration);
216 259
217 const base::ListValue* report_served_certificate_chain = nullptr; 260 const base::ListValue* report_served_certificate_chain = nullptr;
218 ASSERT_TRUE(report_dict->GetList("served-certificate-chain", 261 ASSERT_TRUE(report_dict->GetList("served-certificate-chain",
219 &report_served_certificate_chain)); 262 &report_served_certificate_chain));
220 ASSERT_NO_FATAL_FAILURE(CheckReportCertificateChain( 263 ASSERT_NO_FATAL_FAILURE(CheckReportCertificateChain(
221 ssl_info.unverified_cert, *report_served_certificate_chain)); 264 ssl_info.unverified_cert, *report_served_certificate_chain));
222 265
223 const base::ListValue* report_validated_certificate_chain = nullptr; 266 const base::ListValue* report_validated_certificate_chain = nullptr;
224 ASSERT_TRUE(report_dict->GetList("validated-certificate-chain", 267 ASSERT_TRUE(report_dict->GetList("validated-certificate-chain",
225 &report_validated_certificate_chain)); 268 &report_validated_certificate_chain));
226 ASSERT_NO_FATAL_FAILURE(CheckReportCertificateChain( 269 ASSERT_NO_FATAL_FAILURE(CheckReportCertificateChain(
227 ssl_info.cert, *report_validated_certificate_chain)); 270 ssl_info.cert, *report_validated_certificate_chain));
228 271
229 const base::ListValue* report_scts = nullptr; 272 const base::ListValue* report_unknown_scts = nullptr;
230 ASSERT_TRUE(report_dict->GetList("scts", &report_scts)); 273 ASSERT_TRUE(report_dict->GetList("unknown-scts", &report_unknown_scts));
274 const base::ListValue* report_invalid_scts = nullptr;
275 ASSERT_TRUE(report_dict->GetList("invalid-scts", &report_invalid_scts));
276 const base::ListValue* report_valid_scts = nullptr;
277 ASSERT_TRUE(report_dict->GetList("valid-scts", &report_valid_scts));
231 278
232 ASSERT_NO_FATAL_FAILURE( 279 ASSERT_NO_FATAL_FAILURE(CheckReportSCTs(
233 CheckReportSCTs(ssl_info.signed_certificate_timestamps, *report_scts)); 280 ssl_info.signed_certificate_timestamps, *report_unknown_scts,
281 *report_invalid_scts, *report_valid_scts));
234 } 282 }
235 283
236 // A test network delegate that allows the user to specify a callback to 284 // A test network delegate that allows the user to specify a callback to
237 // be run whenever a net::URLRequest is destroyed. 285 // be run whenever a net::URLRequest is destroyed.
238 class TestExpectCTNetworkDelegate : public net::NetworkDelegateImpl { 286 class TestExpectCTNetworkDelegate : public net::NetworkDelegateImpl {
239 public: 287 public:
240 TestExpectCTNetworkDelegate() 288 TestExpectCTNetworkDelegate()
241 : url_request_destroyed_callback_(base::Bind(&base::DoNothing)) {} 289 : url_request_destroyed_callback_(base::Bind(&base::DoNothing)) {}
242 290
243 void set_url_request_destroyed_callback(const base::Closure& callback) { 291 void set_url_request_destroyed_callback(const base::Closure& callback) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 ssl_info.cert = 450 ssl_info.cert =
403 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); 451 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem");
404 ssl_info.unverified_cert = net::ImportCertFromFile( 452 ssl_info.unverified_cert = net::ImportCertFromFile(
405 net::GetTestCertsDirectory(), "localhost_cert.pem"); 453 net::GetTestCertsDirectory(), "localhost_cert.pem");
406 454
407 base::Time now = base::Time::Now(); 455 base::Time now = base::Time::Now();
408 456
409 // Append a variety of SCTs: two of each possible status, with a 457 // Append a variety of SCTs: two of each possible status, with a
410 // mixture of different origins. 458 // mixture of different origins.
411 459
412 // The particular value of the log ID doesn't matter; it just has to be the
413 // correct length.
414 const char kTestLogId[] = {0xdf, 0x1c, 0x2e, 0xc1, 0x15, 0x00, 0x94, 0x52,
415 0x47, 0xa9, 0x61, 0x68, 0x32, 0x5d, 0xdc, 0x5c,
416 0x79, 0x59, 0xe8, 0xf7, 0xc6, 0xd3, 0x88, 0xfc,
417 0x00, 0x2e, 0x0b, 0xbd, 0x3f, 0x74, 0xd7, 0x01};
418 const std::string log_id(kTestLogId, sizeof(kTestLogId));
419 // The values of the extensions and signature data don't matter
420 // either. However, each SCT has to be unique for the test expectation to be
421 // checked properly in CheckExpectCTReport(), so each SCT has a unique
422 // extensions value to make sure the serialized SCTs are unique.
423 MakeTestSCTAndStatus(net::ct::SignedCertificateTimestamp::SCT_EMBEDDED, 460 MakeTestSCTAndStatus(net::ct::SignedCertificateTimestamp::SCT_EMBEDDED,
424 log_id, "extensions1", "signature1", now, 461 "unknown_log_id1", "extensions1", "signature1", now,
425 net::ct::SCT_STATUS_LOG_UNKNOWN, 462 net::ct::SCT_STATUS_LOG_UNKNOWN,
426 &ssl_info.signed_certificate_timestamps); 463 &ssl_info.signed_certificate_timestamps);
427 MakeTestSCTAndStatus(net::ct::SignedCertificateTimestamp::SCT_EMBEDDED, 464 MakeTestSCTAndStatus(net::ct::SignedCertificateTimestamp::SCT_EMBEDDED,
428 log_id, "extensions2", "signature2", now, 465 "unknown_log_id2", "extensions2", "signature2", now,
429 net::ct::SCT_STATUS_LOG_UNKNOWN, 466 net::ct::SCT_STATUS_LOG_UNKNOWN,
430 &ssl_info.signed_certificate_timestamps); 467 &ssl_info.signed_certificate_timestamps);
431 468
432 MakeTestSCTAndStatus( 469 MakeTestSCTAndStatus(
433 net::ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION, log_id, 470 net::ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION,
434 "extensions3", "signature1", now, net::ct::SCT_STATUS_INVALID_TIMESTAMP, 471 "invalid_log_id1", "extensions1", "signature1", now,
472 net::ct::SCT_STATUS_INVALID_TIMESTAMP,
435 &ssl_info.signed_certificate_timestamps); 473 &ssl_info.signed_certificate_timestamps);
436 474
437 MakeTestSCTAndStatus( 475 MakeTestSCTAndStatus(
438 net::ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION, log_id, 476 net::ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION,
439 "extensions4", "signature1", now, net::ct::SCT_STATUS_INVALID_SIGNATURE, 477 "invalid_log_id1", "extensions1", "signature1", now,
478 net::ct::SCT_STATUS_INVALID_SIGNATURE,
440 &ssl_info.signed_certificate_timestamps); 479 &ssl_info.signed_certificate_timestamps);
441 480
442 MakeTestSCTAndStatus(net::ct::SignedCertificateTimestamp::SCT_EMBEDDED, 481 MakeTestSCTAndStatus(net::ct::SignedCertificateTimestamp::SCT_EMBEDDED,
443 log_id, "extensions5", "signature2", now, 482 "invalid_log_id2", "extensions2", "signature2", now,
444 net::ct::SCT_STATUS_INVALID_SIGNATURE, 483 net::ct::SCT_STATUS_INVALID_SIGNATURE,
445 &ssl_info.signed_certificate_timestamps); 484 &ssl_info.signed_certificate_timestamps);
446 485
447 MakeTestSCTAndStatus( 486 MakeTestSCTAndStatus(
448 net::ct::SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE, log_id, 487 net::ct::SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE,
449 "extensions6", "signature1", now, net::ct::SCT_STATUS_OK, 488 "valid_log_id1", "extensions1", "signature1", now, net::ct::SCT_STATUS_OK,
450 &ssl_info.signed_certificate_timestamps); 489 &ssl_info.signed_certificate_timestamps);
451 MakeTestSCTAndStatus(net::ct::SignedCertificateTimestamp::SCT_EMBEDDED, 490 MakeTestSCTAndStatus(net::ct::SignedCertificateTimestamp::SCT_EMBEDDED,
452 log_id, "extensions7", "signature2", now, 491 "valid_log_id2", "extensions2", "signature2", now,
453 net::ct::SCT_STATUS_OK, 492 net::ct::SCT_STATUS_OK,
454 &ssl_info.signed_certificate_timestamps); 493 &ssl_info.signed_certificate_timestamps);
455 494
456 net::HostPortPair host_port("example.test", 443); 495 net::HostPortPair host_port("example.test", 443);
457 GURL report_uri("http://example-report.test"); 496 GURL report_uri("http://example-report.test");
458 497
459 const char kExpirationTimeStr[] = "2017-01-01T00:00:00.000Z"; 498 const char kExpirationTimeStr[] = "2017-01-01T00:00:00.000Z";
460 base::Time expiration; 499 base::Time expiration;
461 ASSERT_TRUE( 500 ASSERT_TRUE(
462 base::Time::FromUTCExploded({2017, 1, 0, 1, 0, 0, 0, 0}, &expiration)); 501 base::Time::FromUTCExploded({2017, 1, 0, 1, 0, 0, 0, 0}, &expiration));
463 502
464 // Check that the report is sent and contains the correct information. 503 // Check that the report is sent and contains the correct information.
465 reporter.OnExpectCTFailed(host_port, report_uri, expiration, 504 reporter.OnExpectCTFailed(host_port, report_uri, expiration,
466 ssl_info.cert.get(), ssl_info.unverified_cert.get(), 505 ssl_info.cert.get(), ssl_info.unverified_cert.get(),
467 ssl_info.signed_certificate_timestamps); 506 ssl_info.signed_certificate_timestamps);
468 EXPECT_EQ(report_uri, sender->latest_report_uri()); 507 EXPECT_EQ(report_uri, sender->latest_report_uri());
469 EXPECT_FALSE(sender->latest_serialized_report().empty()); 508 EXPECT_FALSE(sender->latest_serialized_report().empty());
470 EXPECT_EQ("application/json; charset=utf-8", sender->latest_content_type()); 509 EXPECT_EQ("application/json; charset=utf-8", sender->latest_content_type());
471 ASSERT_NO_FATAL_FAILURE( 510 ASSERT_NO_FATAL_FAILURE(
472 CheckExpectCTReport(sender->latest_serialized_report(), host_port, 511 CheckExpectCTReport(sender->latest_serialized_report(), host_port,
473 kExpirationTimeStr, ssl_info)); 512 kExpirationTimeStr, ssl_info));
474 513
475 histograms.ExpectTotalCount(kFailureHistogramName, 0); 514 histograms.ExpectTotalCount(kFailureHistogramName, 0);
476 histograms.ExpectTotalCount(kSendHistogramName, 1); 515 histograms.ExpectTotalCount(kSendHistogramName, 1);
477 histograms.ExpectBucketCount(kSendHistogramName, true, 1); 516 histograms.ExpectBucketCount(kSendHistogramName, true, 1);
478 } 517 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/chrome_expect_ct_reporter.cc ('k') | net/cert/ct_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698