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

Unified Diff: components/certificate_reporting/error_report_unittest.cc

Issue 2964283002: Add chrome channel to cert logger reports (Closed)
Patch Set: Revert unneeded change Created 3 years, 6 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: components/certificate_reporting/error_report_unittest.cc
diff --git a/components/certificate_reporting/error_report_unittest.cc b/components/certificate_reporting/error_report_unittest.cc
index 03667c5b973ed262cbb8d99cb6095a1b4518336a..17322f533a9f8eeac4c00b02d7053d0940d297eb 100644
--- a/components/certificate_reporting/error_report_unittest.cc
+++ b/components/certificate_reporting/error_report_unittest.cc
@@ -18,6 +18,7 @@
#include "components/certificate_reporting/cert_logger.pb.h"
#include "components/network_time/network_time_test_utils.h"
#include "components/prefs/testing_pref_service.h"
+#include "components/version_info/version_info.h"
#include "net/cert/cert_status_flags.h"
#include "net/ssl/ssl_info.h"
#include "net/test/cert_test_util.h"
@@ -247,6 +248,37 @@ TEST(ErrorReportTest, NetworkTimeQueryingFeatureInfo) {
.network_time_query_behavior());
}
+struct ChannelTestCase {
+ version_info::Channel channel;
+ CertLoggerRequest::ChromeChannel expected_channel;
+};
meacer 2017/06/30 23:58:39 nit: This works but could be slightly more compact
sperigo 2017/07/05 23:02:48 Done.
+
+TEST(ErrorReportTest, TestChromeChannelIncluded) {
+ ChannelTestCase kTestCases[] = {
+ {version_info::Channel::UNKNOWN, CertLoggerRequest::UNKNOWN},
+ {version_info::Channel::DEV, CertLoggerRequest::DEV},
+ {version_info::Channel::CANARY, CertLoggerRequest::CANARY},
+ {version_info::Channel::BETA, CertLoggerRequest::BETA},
+ {version_info::Channel::STABLE, CertLoggerRequest::STABLE}};
+
+ // Create a report, set its channel value and check if we
+ // get back testCase.expected_channel.
+ for (const ChannelTestCase& testCase : kTestCases) {
estark 2017/07/01 17:19:01 nit: test_case (and don't forget to change the com
sperigo 2017/07/05 23:02:48 Done.
sperigo 2017/07/05 23:02:48 Oops! Thank you.
+ SSLInfo ssl_info;
+ ASSERT_NO_FATAL_FAILURE(
+ GetTestSSLInfo(INCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, kCertStatus));
+ ErrorReport report(kDummyHostname, ssl_info);
+
+ report.AddChromeChannel(testCase.channel);
+ std::string serialized_report;
+ ASSERT_TRUE(report.Serialize(&serialized_report));
+
+ CertLoggerRequest parsed;
+ ASSERT_TRUE(parsed.ParseFromString(serialized_report));
+ EXPECT_EQ(testCase.expected_channel, parsed.chrome_channel());
+ }
+}
+
#if defined(OS_ANDROID)
// Tests that information about the Android AIA fetching feature is included in
// the report.

Powered by Google App Engine
This is Rietveld 408576698