| 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 "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" | 5 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 EXPECT_FALSE(IsGoodSSLInfo(ssl_info)); | 111 EXPECT_FALSE(IsGoodSSLInfo(ssl_info)); |
| 112 EXPECT_FALSE(net::TransportSecurityState::IsGooglePinnedProperty(hostname)); | 112 EXPECT_FALSE(net::TransportSecurityState::IsGooglePinnedProperty(hostname)); |
| 113 } | 113 } |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 // A CertificateErrorReporter that uses a MockURLRequest, but is | 116 // A CertificateErrorReporter that uses a MockURLRequest, but is |
| 117 // otherwise normal: reports are constructed and sent in the usual way. | 117 // otherwise normal: reports are constructed and sent in the usual way. |
| 118 class MockReporter : public CertificateErrorReporter { | 118 class MockReporter : public CertificateErrorReporter { |
| 119 public: | 119 public: |
| 120 explicit MockReporter(net::URLRequestContext* request_context) | 120 explicit MockReporter(net::URLRequestContext* request_context) |
| 121 : CertificateErrorReporter(request_context, GURL("http://example.com")) {} | 121 : CertificateErrorReporter( |
| 122 request_context, |
| 123 GURL("http://example.com"), |
| 124 CertificateErrorReporter::DO_NOT_SEND_COOKIES) {} |
| 122 | 125 |
| 123 void SendReport(ReportType type, | 126 void SendReport(ReportType type, |
| 124 const std::string& hostname, | 127 const std::string& hostname, |
| 125 const net::SSLInfo& ssl_info) override { | 128 const net::SSLInfo& ssl_info) override { |
| 126 EXPECT_EQ(type, REPORT_TYPE_PINNING_VIOLATION); | 129 EXPECT_EQ(type, REPORT_TYPE_PINNING_VIOLATION); |
| 127 EXPECT_FALSE(hostname.empty()); | 130 EXPECT_FALSE(hostname.empty()); |
| 128 EXPECT_TRUE(ssl_info.is_valid()); | 131 EXPECT_TRUE(ssl_info.is_valid()); |
| 129 CertificateErrorReporter::SendReport(type, hostname, ssl_info); | 132 CertificateErrorReporter::SendReport(type, hostname, ssl_info); |
| 130 } | 133 } |
| 131 | 134 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 186 } |
| 184 | 187 |
| 185 TEST(ChromeFraudulentCertificateReporterTest, ReportIsNotSent) { | 188 TEST(ChromeFraudulentCertificateReporterTest, ReportIsNotSent) { |
| 186 base::MessageLoopForIO loop; | 189 base::MessageLoopForIO loop; |
| 187 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); | 190 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); |
| 188 loop.PostTask(FROM_HERE, base::Bind(&DoReportIsNotSent)); | 191 loop.PostTask(FROM_HERE, base::Bind(&DoReportIsNotSent)); |
| 189 loop.RunUntilIdle(); | 192 loop.RunUntilIdle(); |
| 190 } | 193 } |
| 191 | 194 |
| 192 } // namespace chrome_browser_net | 195 } // namespace chrome_browser_net |
| OLD | NEW |