| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 6066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6077 base::RunLoop().Run(); | 6077 base::RunLoop().Run(); |
| 6078 | 6078 |
| 6079 // Check that a report was sent. | 6079 // Check that a report was sent. |
| 6080 EXPECT_EQ(report_uri, mock_report_sender.latest_report_uri()); | 6080 EXPECT_EQ(report_uri, mock_report_sender.latest_report_uri()); |
| 6081 ASSERT_FALSE(mock_report_sender.latest_report().empty()); | 6081 ASSERT_FALSE(mock_report_sender.latest_report().empty()); |
| 6082 EXPECT_EQ("application/json; charset=utf-8", | 6082 EXPECT_EQ("application/json; charset=utf-8", |
| 6083 mock_report_sender.latest_content_type()); | 6083 mock_report_sender.latest_content_type()); |
| 6084 std::unique_ptr<base::Value> value( | 6084 std::unique_ptr<base::Value> value( |
| 6085 base::JSONReader::Read(mock_report_sender.latest_report())); | 6085 base::JSONReader::Read(mock_report_sender.latest_report())); |
| 6086 ASSERT_TRUE(value); | 6086 ASSERT_TRUE(value); |
| 6087 ASSERT_TRUE(value->IsType(base::Value::TYPE_DICTIONARY)); | 6087 ASSERT_TRUE(value->IsType(base::Value::Type::DICTIONARY)); |
| 6088 base::DictionaryValue* report_dict; | 6088 base::DictionaryValue* report_dict; |
| 6089 ASSERT_TRUE(value->GetAsDictionary(&report_dict)); | 6089 ASSERT_TRUE(value->GetAsDictionary(&report_dict)); |
| 6090 std::string report_hostname; | 6090 std::string report_hostname; |
| 6091 EXPECT_TRUE(report_dict->GetString("hostname", &report_hostname)); | 6091 EXPECT_TRUE(report_dict->GetString("hostname", &report_hostname)); |
| 6092 EXPECT_EQ(test_server_hostname, report_hostname); | 6092 EXPECT_EQ(test_server_hostname, report_hostname); |
| 6093 } | 6093 } |
| 6094 | 6094 |
| 6095 // Tests that reports get sent on requests with | 6095 // Tests that reports get sent on requests with |
| 6096 // Public-Key-Pins-Report-Only headers. | 6096 // Public-Key-Pins-Report-Only headers. |
| 6097 TEST_F(URLRequestTestHTTP, ProcessPKPReportOnly) { | 6097 TEST_F(URLRequestTestHTTP, ProcessPKPReportOnly) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6142 base::RunLoop().Run(); | 6142 base::RunLoop().Run(); |
| 6143 | 6143 |
| 6144 // Check that a report was sent. | 6144 // Check that a report was sent. |
| 6145 EXPECT_EQ(report_uri, mock_report_sender.latest_report_uri()); | 6145 EXPECT_EQ(report_uri, mock_report_sender.latest_report_uri()); |
| 6146 ASSERT_FALSE(mock_report_sender.latest_report().empty()); | 6146 ASSERT_FALSE(mock_report_sender.latest_report().empty()); |
| 6147 EXPECT_EQ("application/json; charset=utf-8", | 6147 EXPECT_EQ("application/json; charset=utf-8", |
| 6148 mock_report_sender.latest_content_type()); | 6148 mock_report_sender.latest_content_type()); |
| 6149 std::unique_ptr<base::Value> value( | 6149 std::unique_ptr<base::Value> value( |
| 6150 base::JSONReader::Read(mock_report_sender.latest_report())); | 6150 base::JSONReader::Read(mock_report_sender.latest_report())); |
| 6151 ASSERT_TRUE(value); | 6151 ASSERT_TRUE(value); |
| 6152 ASSERT_TRUE(value->IsType(base::Value::TYPE_DICTIONARY)); | 6152 ASSERT_TRUE(value->IsType(base::Value::Type::DICTIONARY)); |
| 6153 base::DictionaryValue* report_dict; | 6153 base::DictionaryValue* report_dict; |
| 6154 ASSERT_TRUE(value->GetAsDictionary(&report_dict)); | 6154 ASSERT_TRUE(value->GetAsDictionary(&report_dict)); |
| 6155 std::string report_hostname; | 6155 std::string report_hostname; |
| 6156 EXPECT_TRUE(report_dict->GetString("hostname", &report_hostname)); | 6156 EXPECT_TRUE(report_dict->GetString("hostname", &report_hostname)); |
| 6157 EXPECT_EQ(test_server_hostname, report_hostname); | 6157 EXPECT_EQ(test_server_hostname, report_hostname); |
| 6158 } | 6158 } |
| 6159 | 6159 |
| 6160 // Tests that reports do not get sent on requests with | 6160 // Tests that reports do not get sent on requests with |
| 6161 // Public-Key-Pins-Report-Only headers that don't have pin violations. | 6161 // Public-Key-Pins-Report-Only headers that don't have pin violations. |
| 6162 TEST_F(URLRequestTestHTTP, ProcessPKPReportOnlyWithNoViolation) { | 6162 TEST_F(URLRequestTestHTTP, ProcessPKPReportOnlyWithNoViolation) { |
| (...skipping 4451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10614 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10614 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
| 10615 | 10615 |
| 10616 req->Start(); | 10616 req->Start(); |
| 10617 req->Cancel(); | 10617 req->Cancel(); |
| 10618 base::RunLoop().RunUntilIdle(); | 10618 base::RunLoop().RunUntilIdle(); |
| 10619 EXPECT_EQ(ERR_ABORTED, d.request_status()); | 10619 EXPECT_EQ(ERR_ABORTED, d.request_status()); |
| 10620 EXPECT_EQ(0, d.received_redirect_count()); | 10620 EXPECT_EQ(0, d.received_redirect_count()); |
| 10621 } | 10621 } |
| 10622 | 10622 |
| 10623 } // namespace net | 10623 } // namespace net |
| OLD | NEW |