| 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 c49b5448a5365ddbf56d91749c003edcd4c5ac48..df0dbef294ca946a112da283b57836f9c20324d1 100644
|
| --- a/components/certificate_reporting/error_report_unittest.cc
|
| +++ b/components/certificate_reporting/error_report_unittest.cc
|
| @@ -10,11 +10,17 @@
|
| #include "base/files/file_path.h"
|
| #include "base/files/file_util.h"
|
| #include "base/path_service.h"
|
| +#include "base/threading/thread.h"
|
| +#include "base/time/default_clock.h"
|
| +#include "base/time/default_tick_clock.h"
|
| #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 "net/cert/cert_status_flags.h"
|
| #include "net/ssl/ssl_info.h"
|
| #include "net/test/cert_test_util.h"
|
| #include "net/test/test_data_directory.h"
|
| +#include "net/url_request/url_request_test_util.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -178,6 +184,50 @@ TEST(ErrorReportTest, CertificateTransparencyError) {
|
| VerifyErrorReportSerialization(report_known, ssl_info, cert_errors));
|
| }
|
|
|
| +// Tests that information about relevant features are included in the
|
| +// report.
|
| +TEST(ErrorReportTest, FeatureInfo) {
|
| + base::Thread io_thread("IO thread");
|
| + base::Thread::Options thread_options;
|
| + thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
|
| + EXPECT_TRUE(io_thread.StartWithOptions(thread_options));
|
| +
|
| + std::unique_ptr<network_time::FieldTrialTest> field_trial_test(
|
| + network_time::FieldTrialTest::CreateForUnitTest());
|
| + field_trial_test->SetNetworkQueriesWithVariationsService(
|
| + true, 0.0, network_time::NetworkTimeTracker::FETCHES_ON_DEMAND_ONLY);
|
| +
|
| + TestingPrefServiceSimple pref_service;
|
| + network_time::NetworkTimeTracker::RegisterPrefs(pref_service.registry());
|
| + network_time::NetworkTimeTracker network_time_tracker(
|
| + base::MakeUnique<base::DefaultClock>(),
|
| + base::MakeUnique<base::DefaultTickClock>(), &pref_service,
|
| + new net::TestURLRequestContextGetter(io_thread.task_runner()));
|
| +
|
| + // Serialize a report containing information about the network time querying
|
| + // feature.
|
| + SSLInfo ssl_info;
|
| + ASSERT_NO_FATAL_FAILURE(
|
| + GetTestSSLInfo(INCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, kCertStatus));
|
| + ErrorReport report(kDummyHostname, ssl_info);
|
| + report.AddNetworkTimeInfo(&network_time_tracker);
|
| + std::string serialized_report;
|
| + ASSERT_TRUE(report.Serialize(&serialized_report));
|
| +
|
| + // Check that the report contains the network time querying feature
|
| + // information.
|
| + CertLoggerRequest parsed;
|
| + ASSERT_TRUE(parsed.ParseFromString(serialized_report));
|
| + EXPECT_TRUE(parsed.features_info()
|
| + .network_time_querying_info()
|
| + .network_time_queries_enabled());
|
| + EXPECT_EQ(CertLoggerFeaturesInfo::NetworkTimeQueryingInfo::
|
| + NETWORK_TIME_FETCHES_ON_DEMAND_ONLY,
|
| + parsed.features_info()
|
| + .network_time_querying_info()
|
| + .network_time_query_behavior());
|
| +}
|
| +
|
| } // namespace
|
|
|
| } // namespace certificate_reporting
|
|
|