OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 const net::SSLInfo& ssl_info, | 144 const net::SSLInfo& ssl_info, |
145 bool sni_available) { | 145 bool sni_available) { |
146 DCHECK(!hostname.empty()); | 146 DCHECK(!hostname.empty()); |
147 DCHECK(ssl_info.is_valid()); | 147 DCHECK(ssl_info.is_valid()); |
148 ChromeFraudulentCertificateReporter::SendReport(hostname, ssl_info, | 148 ChromeFraudulentCertificateReporter::SendReport(hostname, ssl_info, |
149 sni_available); | 149 sni_available); |
150 } | 150 } |
151 }; | 151 }; |
152 | 152 |
153 static void DoReportIsSent() { | 153 static void DoReportIsSent() { |
154 scoped_refptr<ChromeURLRequestContext> context = new ChromeURLRequestContext; | 154 ChromeURLRequestContext context; |
155 SendingTestReporter reporter(context.get()); | 155 SendingTestReporter reporter(&context); |
156 SSLInfo info = GetGoodSSLInfo(); | 156 SSLInfo info = GetGoodSSLInfo(); |
157 reporter.SendReport("mail.google.com", info, true); | 157 reporter.SendReport("mail.google.com", info, true); |
158 } | 158 } |
159 | 159 |
160 static void DoReportIsNotSent() { | 160 static void DoReportIsNotSent() { |
161 scoped_refptr<ChromeURLRequestContext> context = new ChromeURLRequestContext; | 161 ChromeURLRequestContext context; |
162 NotSendingTestReporter reporter(context.get()); | 162 NotSendingTestReporter reporter(&context); |
163 SSLInfo info = GetBadSSLInfo(); | 163 SSLInfo info = GetBadSSLInfo(); |
164 reporter.SendReport("www.example.com", info, true); | 164 reporter.SendReport("www.example.com", info, true); |
165 } | 165 } |
166 | 166 |
167 static void DoMockReportIsSent() { | 167 static void DoMockReportIsSent() { |
168 scoped_refptr<ChromeURLRequestContext> context = new ChromeURLRequestContext; | 168 ChromeURLRequestContext context; |
169 MockReporter reporter(context.get()); | 169 MockReporter reporter(&context); |
170 SSLInfo info = GetGoodSSLInfo(); | 170 SSLInfo info = GetGoodSSLInfo(); |
171 reporter.SendReport("mail.google.com", info, true); | 171 reporter.SendReport("mail.google.com", info, true); |
172 } | 172 } |
173 | 173 |
174 TEST(ChromeFraudulentCertificateReporterTest, GoodBadInfo) { | 174 TEST(ChromeFraudulentCertificateReporterTest, GoodBadInfo) { |
175 SSLInfo good = GetGoodSSLInfo(); | 175 SSLInfo good = GetGoodSSLInfo(); |
176 EXPECT_TRUE(IsGoodSSLInfo(good)); | 176 EXPECT_TRUE(IsGoodSSLInfo(good)); |
177 | 177 |
178 SSLInfo bad = GetBadSSLInfo(); | 178 SSLInfo bad = GetBadSSLInfo(); |
179 EXPECT_FALSE(IsGoodSSLInfo(bad)); | 179 EXPECT_FALSE(IsGoodSSLInfo(bad)); |
(...skipping 14 matching lines...) Expand all Loading... |
194 } | 194 } |
195 | 195 |
196 TEST(ChromeFraudulentCertificateReporterTest, ReportIsNotSent) { | 196 TEST(ChromeFraudulentCertificateReporterTest, ReportIsNotSent) { |
197 MessageLoop loop(MessageLoop::TYPE_IO); | 197 MessageLoop loop(MessageLoop::TYPE_IO); |
198 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); | 198 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); |
199 loop.PostTask(FROM_HERE, base::Bind(&DoReportIsNotSent)); | 199 loop.PostTask(FROM_HERE, base::Bind(&DoReportIsNotSent)); |
200 loop.RunAllPending(); | 200 loop.RunAllPending(); |
201 } | 201 } |
202 | 202 |
203 } // namespace chrome_browser_net | 203 } // namespace chrome_browser_net |
204 | |
OLD | NEW |