Index: chrome/browser/ssl/chrome_fraudulent_certificate_reporter_unittest.cc |
diff --git a/chrome/browser/ssl/chrome_fraudulent_certificate_reporter_unittest.cc b/chrome/browser/ssl/chrome_fraudulent_certificate_reporter_unittest.cc |
index 79ae4280eec9eab95d4b901f8e56095fb5ea2ff4..40051f96a9726a6689fcc7a38b8a5dc37e7bd3ac 100644 |
--- a/chrome/browser/ssl/chrome_fraudulent_certificate_reporter_unittest.cc |
+++ b/chrome/browser/ssl/chrome_fraudulent_certificate_reporter_unittest.cc |
@@ -22,6 +22,7 @@ |
#include "net/http/transport_security_state.h" |
#include "net/ssl/ssl_info.h" |
#include "net/test/cert_test_util.h" |
+#include "net/url_request/certificate_report_sender.h" |
#include "net/url_request/fraudulent_certificate_reporter.h" |
#include "net/url_request/url_request.h" |
#include "net/url_request/url_request_context.h" |
@@ -34,6 +35,11 @@ using net::SSLInfo; |
namespace { |
+const uint32 kServerPublicKeyVersion = 1; |
+const uint8 kServerPublicKey[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
+ |
// Builds an SSLInfo from an invalid cert chain. In this case, the cert is |
// expired; what matters is that the cert would not pass even a normal |
// sanity check. We test that we DO NOT send a fraudulent certificate report |
@@ -116,15 +122,35 @@ class NotSendingTestReporter : public TestReporter { |
} |
}; |
+class MockCertificateReportSender : public net::CertificateReportSender { |
+ public: |
+ MockCertificateReportSender( |
+ net::URLRequestContext* request_context, |
+ net::CertificateReportSender::CookiesPreference cookies_preference) |
+ : net::CertificateReportSender(request_context, cookies_preference) {} |
+ |
+ private: |
+ scoped_ptr<net::URLRequest> CreateURLRequest( |
+ net::URLRequestContext* context, |
+ const GURL& report_uri) override { |
+ return context->CreateRequest(GURL(std::string()), net::DEFAULT_PRIORITY, |
+ NULL); |
+ } |
+}; |
+ |
// A CertificateErrorReporter that uses a MockURLRequest, but is |
// otherwise normal: reports are constructed and sent in the usual way. |
class MockReporter : public CertificateErrorReporter { |
public: |
explicit MockReporter(net::URLRequestContext* request_context) |
: CertificateErrorReporter( |
- request_context, |
GURL("http://example.com"), |
- CertificateErrorReporter::DO_NOT_SEND_COOKIES) {} |
+ kServerPublicKey, |
+ kServerPublicKeyVersion, |
+ scoped_ptr<net::CertificateReportSender>( |
+ new MockCertificateReportSender( |
+ request_context, |
+ net::CertificateReportSender::DO_NOT_SEND_COOKIES))) {} |
void SendReport(ReportType type, |
const std::string& serialized_report) override { |
@@ -132,13 +158,6 @@ class MockReporter : public CertificateErrorReporter { |
EXPECT_FALSE(serialized_report.empty()); |
CertificateErrorReporter::SendReport(type, serialized_report); |
} |
- |
- private: |
- scoped_ptr<net::URLRequest> CreateURLRequest( |
- net::URLRequestContext* context) override { |
- return context->CreateRequest(GURL(std::string()), net::DEFAULT_PRIORITY, |
- NULL); |
- } |
}; |
static void DoReportIsSent() { |