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

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

Issue 2682733003: Add AIA fetching feature info to certificate reports (Closed)
Patch Set: Add UMA statistic for AIA fetches Created 3 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 unified diff | Download patch
« no previous file with comments | « components/certificate_reporting/error_report.cc ('k') | net/cert/cert_verify_proc_android.cc » ('j') | 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/path_service.h" 13 #include "base/path_service.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "base/time/default_clock.h" 15 #include "base/time/default_clock.h"
16 #include "base/time/default_tick_clock.h" 16 #include "base/time/default_tick_clock.h"
17 #include "components/certificate_reporting/cert_logger.pb.h" 17 #include "components/certificate_reporting/cert_logger.pb.h"
18 #include "components/network_time/network_time_test_utils.h" 18 #include "components/network_time/network_time_test_utils.h"
19 #include "components/prefs/testing_pref_service.h" 19 #include "components/prefs/testing_pref_service.h"
20 #include "net/cert/cert_status_flags.h" 20 #include "net/cert/cert_status_flags.h"
21 #include "net/ssl/ssl_info.h" 21 #include "net/ssl/ssl_info.h"
22 #include "net/test/cert_test_util.h" 22 #include "net/test/cert_test_util.h"
23 #include "net/test/test_data_directory.h" 23 #include "net/test/test_data_directory.h"
24 #include "net/url_request/url_request_test_util.h" 24 #include "net/url_request/url_request_test_util.h"
25 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 27
28 #if defined(OS_ANDROID)
29 #include "base/test/scoped_feature_list.h"
30 #include "net/cert/cert_verify_proc_android.h"
31 #endif
32
28 using net::SSLInfo; 33 using net::SSLInfo;
29 using testing::UnorderedElementsAre; 34 using testing::UnorderedElementsAre;
30 using testing::UnorderedElementsAreArray; 35 using testing::UnorderedElementsAreArray;
31 36
32 namespace certificate_reporting { 37 namespace certificate_reporting {
33 38
34 namespace { 39 namespace {
35 40
36 const char kDummyHostname[] = "dummy.hostname.com"; 41 const char kDummyHostname[] = "dummy.hostname.com";
37 const char kDummyFailureLog[] = "dummy failure log"; 42 const char kDummyFailureLog[] = "dummy failure log";
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 GetTestSSLInfo(INCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, 188 GetTestSSLInfo(INCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info,
184 net::CERT_STATUS_CERTIFICATE_TRANSPARENCY_REQUIRED)); 189 net::CERT_STATUS_CERTIFICATE_TRANSPARENCY_REQUIRED));
185 ErrorReport report_known(kDummyHostname, ssl_info); 190 ErrorReport report_known(kDummyHostname, ssl_info);
186 std::vector<CertLoggerRequest::CertError> cert_errors; 191 std::vector<CertLoggerRequest::CertError> cert_errors;
187 cert_errors.push_back( 192 cert_errors.push_back(
188 CertLoggerRequest::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED); 193 CertLoggerRequest::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED);
189 ASSERT_NO_FATAL_FAILURE( 194 ASSERT_NO_FATAL_FAILURE(
190 VerifyErrorReportSerialization(report_known, ssl_info, cert_errors)); 195 VerifyErrorReportSerialization(report_known, ssl_info, cert_errors));
191 } 196 }
192 197
193 // Tests that information about relevant features are included in the 198 // Tests that information about network time querying is included in the
194 // report. 199 // report.
195 TEST(ErrorReportTest, FeatureInfo) { 200 TEST(ErrorReportTest, NetworkTimeQueryingFeatureInfo) {
196 base::Thread io_thread("IO thread"); 201 base::Thread io_thread("IO thread");
197 base::Thread::Options thread_options; 202 base::Thread::Options thread_options;
198 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; 203 thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
199 EXPECT_TRUE(io_thread.StartWithOptions(thread_options)); 204 EXPECT_TRUE(io_thread.StartWithOptions(thread_options));
200 205
201 std::unique_ptr<network_time::FieldTrialTest> field_trial_test( 206 std::unique_ptr<network_time::FieldTrialTest> field_trial_test(
202 new network_time::FieldTrialTest()); 207 new network_time::FieldTrialTest());
203 field_trial_test->SetNetworkQueriesWithVariationsService( 208 field_trial_test->SetNetworkQueriesWithVariationsService(
204 true, 0.0, network_time::NetworkTimeTracker::FETCHES_ON_DEMAND_ONLY); 209 true, 0.0, network_time::NetworkTimeTracker::FETCHES_ON_DEMAND_ONLY);
205 210
(...skipping 21 matching lines...) Expand all
227 EXPECT_TRUE(parsed.features_info() 232 EXPECT_TRUE(parsed.features_info()
228 .network_time_querying_info() 233 .network_time_querying_info()
229 .network_time_queries_enabled()); 234 .network_time_queries_enabled());
230 EXPECT_EQ(CertLoggerFeaturesInfo::NetworkTimeQueryingInfo:: 235 EXPECT_EQ(CertLoggerFeaturesInfo::NetworkTimeQueryingInfo::
231 NETWORK_TIME_FETCHES_ON_DEMAND_ONLY, 236 NETWORK_TIME_FETCHES_ON_DEMAND_ONLY,
232 parsed.features_info() 237 parsed.features_info()
233 .network_time_querying_info() 238 .network_time_querying_info()
234 .network_time_query_behavior()); 239 .network_time_query_behavior());
235 } 240 }
236 241
242 #if defined(OS_ANDROID)
243 // Tests that information about the Android AIA fetching feature is included in
244 // the report when the feature is disabled.
245 TEST(ErrorReportTest, AndroidAIAFetchingFeatureDisabled) {
246 base::test::ScopedFeatureList feature_list;
247 feature_list.InitAndDisableFeature(
248 net::CertVerifyProcAndroid::kAIAFetchingFeature);
249
250 SSLInfo ssl_info;
251 ASSERT_NO_FATAL_FAILURE(
252 GetTestSSLInfo(INCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, kCertStatus));
253 ErrorReport report(kDummyHostname, ssl_info);
254 std::string serialized_report;
255 ASSERT_TRUE(report.Serialize(&serialized_report));
256 CertLoggerRequest parsed;
257 ASSERT_TRUE(parsed.ParseFromString(serialized_report));
258 EXPECT_EQ(CertLoggerFeaturesInfo::ANDROID_AIA_FETCHING_DISABLED,
259 parsed.features_info().android_aia_fetching_status());
260 }
261
262 // Tests that information about the Android AIA fetching feature is included in
263 // the report when the feature is enabled.
264 TEST(ErrorReportTest, AndroidAIAFetchingFeatureEnabled) {
265 base::test::ScopedFeatureList feature_list;
266 feature_list.InitAndEnableFeature(
267 net::CertVerifyProcAndroid::kAIAFetchingFeature);
268
269 SSLInfo ssl_info;
270 ASSERT_NO_FATAL_FAILURE(
271 GetTestSSLInfo(INCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, kCertStatus));
272 ErrorReport report(kDummyHostname, ssl_info);
273 std::string serialized_report;
274 ASSERT_TRUE(report.Serialize(&serialized_report));
275 CertLoggerRequest parsed;
276 ASSERT_TRUE(parsed.ParseFromString(serialized_report));
277 EXPECT_EQ(CertLoggerFeaturesInfo::ANDROID_AIA_FETCHING_ENABLED,
278 parsed.features_info().android_aia_fetching_status());
279 }
280 #endif
281
237 } // namespace 282 } // namespace
238 283
239 } // namespace certificate_reporting 284 } // namespace certificate_reporting
OLDNEW
« no previous file with comments | « components/certificate_reporting/error_report.cc ('k') | net/cert/cert_verify_proc_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698