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

Side by Side Diff: components/certificate_reporting/error_report_unittest.cc

Issue 2964283002: Add chrome channel to cert logger reports (Closed)
Patch Set: Fix build errors Created 3 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 unified diff | Download patch
« no previous file with comments | « components/certificate_reporting/error_report.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/certificate_reporting/error_report.h" 5 #include "components/certificate_reporting/error_report.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "base/time/default_clock.h" 16 #include "base/time/default_clock.h"
17 #include "base/time/default_tick_clock.h" 17 #include "base/time/default_tick_clock.h"
18 #include "components/certificate_reporting/cert_logger.pb.h" 18 #include "components/certificate_reporting/cert_logger.pb.h"
19 #include "components/network_time/network_time_test_utils.h" 19 #include "components/network_time/network_time_test_utils.h"
20 #include "components/prefs/testing_pref_service.h" 20 #include "components/prefs/testing_pref_service.h"
21 #include "components/version_info/version_info.h"
21 #include "net/cert/cert_status_flags.h" 22 #include "net/cert/cert_status_flags.h"
22 #include "net/ssl/ssl_info.h" 23 #include "net/ssl/ssl_info.h"
23 #include "net/test/cert_test_util.h" 24 #include "net/test/cert_test_util.h"
24 #include "net/test/test_data_directory.h" 25 #include "net/test/test_data_directory.h"
25 #include "net/url_request/url_request_test_util.h" 26 #include "net/url_request/url_request_test_util.h"
26 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 29
29 #if defined(OS_ANDROID) 30 #if defined(OS_ANDROID)
30 #include "base/test/scoped_feature_list.h" 31 #include "base/test/scoped_feature_list.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 EXPECT_TRUE(parsed.features_info() 241 EXPECT_TRUE(parsed.features_info()
241 .network_time_querying_info() 242 .network_time_querying_info()
242 .network_time_queries_enabled()); 243 .network_time_queries_enabled());
243 EXPECT_EQ(CertLoggerFeaturesInfo::NetworkTimeQueryingInfo:: 244 EXPECT_EQ(CertLoggerFeaturesInfo::NetworkTimeQueryingInfo::
244 NETWORK_TIME_FETCHES_ON_DEMAND_ONLY, 245 NETWORK_TIME_FETCHES_ON_DEMAND_ONLY,
245 parsed.features_info() 246 parsed.features_info()
246 .network_time_querying_info() 247 .network_time_querying_info()
247 .network_time_query_behavior()); 248 .network_time_query_behavior());
248 } 249 }
249 250
251 TEST(ErrorReportTest, TestChromeChannelIncluded) {
252 struct ChannelTestCase {
253 version_info::Channel channel;
254 CertLoggerRequest::ChromeChannel expected_channel;
255 } kTestCases[] = {
256 {version_info::Channel::UNKNOWN,
257 CertLoggerRequest::CHROME_CHANNEL_UNKNOWN},
258 {version_info::Channel::DEV, CertLoggerRequest::CHROME_CHANNEL_DEV},
259 {version_info::Channel::CANARY, CertLoggerRequest::CHROME_CHANNEL_CANARY},
260 {version_info::Channel::BETA, CertLoggerRequest::CHROME_CHANNEL_BETA},
261 {version_info::Channel::STABLE,
262 CertLoggerRequest::CHROME_CHANNEL_STABLE}};
263
264 // Create a report, set its channel value and check if we
265 // get back test_case.expected_channel.
266 for (const ChannelTestCase& test_case : kTestCases) {
267 SSLInfo ssl_info;
268 ASSERT_NO_FATAL_FAILURE(
269 GetTestSSLInfo(INCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, kCertStatus));
270 ErrorReport report(kDummyHostname, ssl_info);
271
272 report.AddChromeChannel(test_case.channel);
273 std::string serialized_report;
274 ASSERT_TRUE(report.Serialize(&serialized_report));
275
276 CertLoggerRequest parsed;
277 ASSERT_TRUE(parsed.ParseFromString(serialized_report));
278 EXPECT_EQ(test_case.expected_channel, parsed.chrome_channel());
279 }
280 }
281
250 #if defined(OS_ANDROID) 282 #if defined(OS_ANDROID)
251 // Tests that information about the Android AIA fetching feature is included in 283 // Tests that information about the Android AIA fetching feature is included in
252 // the report. 284 // the report.
253 TEST(ErrorReportTest, AndroidAIAFetchingFeatureEnabled) { 285 TEST(ErrorReportTest, AndroidAIAFetchingFeatureEnabled) {
254 SSLInfo ssl_info; 286 SSLInfo ssl_info;
255 ASSERT_NO_FATAL_FAILURE( 287 ASSERT_NO_FATAL_FAILURE(
256 GetTestSSLInfo(INCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, kCertStatus)); 288 GetTestSSLInfo(INCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, kCertStatus));
257 ErrorReport report(kDummyHostname, ssl_info); 289 ErrorReport report(kDummyHostname, ssl_info);
258 std::string serialized_report; 290 std::string serialized_report;
259 ASSERT_TRUE(report.Serialize(&serialized_report)); 291 ASSERT_TRUE(report.Serialize(&serialized_report));
260 CertLoggerRequest parsed; 292 CertLoggerRequest parsed;
261 ASSERT_TRUE(parsed.ParseFromString(serialized_report)); 293 ASSERT_TRUE(parsed.ParseFromString(serialized_report));
262 EXPECT_EQ(CertLoggerFeaturesInfo::ANDROID_AIA_FETCHING_ENABLED, 294 EXPECT_EQ(CertLoggerFeaturesInfo::ANDROID_AIA_FETCHING_ENABLED,
263 parsed.features_info().android_aia_fetching_status()); 295 parsed.features_info().android_aia_fetching_status());
264 } 296 }
265 #endif 297 #endif
266 298
267 } // namespace 299 } // namespace
268 300
269 } // namespace certificate_reporting 301 } // namespace certificate_reporting
OLDNEW
« no previous file with comments | « components/certificate_reporting/error_report.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698