OLD | NEW |
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" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 // Checks that the |serialized_report| deserializes properly and | 232 // Checks that the |serialized_report| deserializes properly and |
233 // contains the correct information (hostname, port, served and | 233 // contains the correct information (hostname, port, served and |
234 // validated certificate chains, SCTs) for the given |host_port| and | 234 // validated certificate chains, SCTs) for the given |host_port| and |
235 // |ssl_info|. | 235 // |ssl_info|. |
236 void CheckExpectCTReport(const std::string& serialized_report, | 236 void CheckExpectCTReport(const std::string& serialized_report, |
237 const net::HostPortPair& host_port, | 237 const net::HostPortPair& host_port, |
238 const net::SSLInfo& ssl_info) { | 238 const net::SSLInfo& ssl_info) { |
239 std::unique_ptr<base::Value> value(base::JSONReader::Read(serialized_report)); | 239 std::unique_ptr<base::Value> value(base::JSONReader::Read(serialized_report)); |
240 ASSERT_TRUE(value); | 240 ASSERT_TRUE(value); |
241 ASSERT_TRUE(value->IsType(base::Value::TYPE_DICTIONARY)); | 241 ASSERT_TRUE(value->IsType(base::Value::Type::DICTIONARY)); |
242 | 242 |
243 base::DictionaryValue* report_dict; | 243 base::DictionaryValue* report_dict; |
244 ASSERT_TRUE(value->GetAsDictionary(&report_dict)); | 244 ASSERT_TRUE(value->GetAsDictionary(&report_dict)); |
245 | 245 |
246 std::string report_hostname; | 246 std::string report_hostname; |
247 EXPECT_TRUE(report_dict->GetString("hostname", &report_hostname)); | 247 EXPECT_TRUE(report_dict->GetString("hostname", &report_hostname)); |
248 EXPECT_EQ(host_port.host(), report_hostname); | 248 EXPECT_EQ(host_port.host(), report_hostname); |
249 int report_port; | 249 int report_port; |
250 EXPECT_TRUE(report_dict->GetInteger("port", &report_port)); | 250 EXPECT_TRUE(report_dict->GetInteger("port", &report_port)); |
251 EXPECT_EQ(host_port.port(), report_port); | 251 EXPECT_EQ(host_port.port(), report_port); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 EXPECT_EQ(report_uri, sender->latest_report_uri()); | 493 EXPECT_EQ(report_uri, sender->latest_report_uri()); |
494 EXPECT_FALSE(sender->latest_serialized_report().empty()); | 494 EXPECT_FALSE(sender->latest_serialized_report().empty()); |
495 EXPECT_EQ("application/json; charset=utf-8", sender->latest_content_type()); | 495 EXPECT_EQ("application/json; charset=utf-8", sender->latest_content_type()); |
496 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport( | 496 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport( |
497 sender->latest_serialized_report(), host_port, ssl_info)); | 497 sender->latest_serialized_report(), host_port, ssl_info)); |
498 | 498 |
499 histograms.ExpectTotalCount(kFailureHistogramName, 0); | 499 histograms.ExpectTotalCount(kFailureHistogramName, 0); |
500 histograms.ExpectTotalCount(kSendHistogramName, 1); | 500 histograms.ExpectTotalCount(kSendHistogramName, 1); |
501 histograms.ExpectBucketCount(kSendHistogramName, true, 1); | 501 histograms.ExpectBucketCount(kSendHistogramName, true, 1); |
502 } | 502 } |
OLD | NEW |