Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(905)

Unified Diff: chrome/browser/ssl/chrome_fraudulent_certificate_reporter_unittest.cc

Issue 1212973002: Add net::CertificateReportSender for handling cert report sending (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing NET_EXPORT Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ssl/chrome_fraudulent_certificate_reporter.cc ('k') | net/http/transport_security_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « chrome/browser/ssl/chrome_fraudulent_certificate_reporter.cc ('k') | net/http/transport_security_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698