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

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

Issue 935663004: Add checkbox for reporting invalid TLS/SSL cert chains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test for not sending reports when flag is disabled Created 5 years, 10 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
Index: chrome/browser/net/chrome_fraudulent_certificate_reporter_unittest.cc
diff --git a/chrome/browser/net/chrome_fraudulent_certificate_reporter_unittest.cc b/chrome/browser/net/chrome_fraudulent_certificate_reporter_unittest.cc
index 6aff91899b2c0bfdb209acaddd441db5d0c429bf..0a8d77b21bf820f71bcb282a37643295ed79a9c5 100644
--- a/chrome/browser/net/chrome_fraudulent_certificate_reporter_unittest.cc
+++ b/chrome/browser/net/chrome_fraudulent_certificate_reporter_unittest.cc
@@ -26,6 +26,7 @@
#include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread;
+using net::FraudulentCertificateReporter;
using net::SSLInfo;
namespace chrome_browser_net {
@@ -82,7 +83,8 @@ class SendingTestReporter : public TestReporter {
// Passes if invoked with a good SSLInfo and for a hostname that is a Google
// pinned property.
- void SendReport(const std::string& hostname,
+ void SendReport(ReportType type,
+ const std::string& hostname,
const SSLInfo& ssl_info) override {
EXPECT_TRUE(IsGoodSSLInfo(ssl_info));
EXPECT_TRUE(net::TransportSecurityState::IsGooglePinnedProperty(hostname));
@@ -105,7 +107,8 @@ class NotSendingTestReporter : public TestReporter {
// Passes if invoked with a bad SSLInfo and for a hostname that is not a
// Google pinned property.
- void SendReport(const std::string& hostname,
+ void SendReport(ReportType type,
+ const std::string& hostname,
const SSLInfo& ssl_info) override {
EXPECT_FALSE(IsGoodSSLInfo(ssl_info));
EXPECT_FALSE(net::TransportSecurityState::IsGooglePinnedProperty(hostname));
@@ -120,18 +123,21 @@ class MockReporter : public ChromeFraudulentCertificateReporter {
: ChromeFraudulentCertificateReporter(request_context) {}
scoped_ptr<net::URLRequest> CreateURLRequest(
- net::URLRequestContext* context) override {
+ net::URLRequestContext* context,
+ const GURL& upload_url) override {
return context->CreateRequest(GURL(std::string()),
net::DEFAULT_PRIORITY,
NULL,
NULL);
}
- void SendReport(const std::string& hostname,
+ void SendReport(ReportType type,
+ const std::string& hostname,
const net::SSLInfo& ssl_info) override {
DCHECK(!hostname.empty());
DCHECK(ssl_info.is_valid());
- ChromeFraudulentCertificateReporter::SendReport(hostname, ssl_info);
+ ChromeFraudulentCertificateReporter::SendReport(REPORT_TYPE_PIN_VIOLATION,
+ hostname, ssl_info);
}
};
@@ -139,21 +145,24 @@ static void DoReportIsSent() {
net::TestURLRequestContext context;
SendingTestReporter reporter(&context);
SSLInfo info = GetGoodSSLInfo();
- reporter.SendReport("mail.google.com", info);
+ reporter.SendReport(FraudulentCertificateReporter::REPORT_TYPE_PIN_VIOLATION,
+ "mail.google.com", info);
}
static void DoReportIsNotSent() {
net::TestURLRequestContext context;
NotSendingTestReporter reporter(&context);
SSLInfo info = GetBadSSLInfo();
- reporter.SendReport("www.example.com", info);
+ reporter.SendReport(FraudulentCertificateReporter::REPORT_TYPE_PIN_VIOLATION,
+ "www.example.com", info);
}
static void DoMockReportIsSent() {
net::TestURLRequestContext context;
MockReporter reporter(&context);
SSLInfo info = GetGoodSSLInfo();
- reporter.SendReport("mail.google.com", info);
+ reporter.SendReport(FraudulentCertificateReporter::REPORT_TYPE_PIN_VIOLATION,
+ "mail.google.com", info);
}
TEST(ChromeFraudulentCertificateReporterTest, GoodBadInfo) {

Powered by Google App Engine
This is Rietveld 408576698