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

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

Issue 2575233003: Record the time when the interstitial is constructed (Closed)
Patch Set: Created 4 years 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"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 TEST(ErrorReportTest, SerializedReportAsProtobufWithInterstitialInfo) { 121 TEST(ErrorReportTest, SerializedReportAsProtobufWithInterstitialInfo) {
122 std::string serialized_report; 122 std::string serialized_report;
123 SSLInfo ssl_info; 123 SSLInfo ssl_info;
124 // Use EXCLUDE_UNVERIFIED_CERT_CHAIN here to exercise the code path 124 // Use EXCLUDE_UNVERIFIED_CERT_CHAIN here to exercise the code path
125 // where SSLInfo does not contain the unverified cert chain. (The test 125 // where SSLInfo does not contain the unverified cert chain. (The test
126 // above exercises the path where it does.) 126 // above exercises the path where it does.)
127 ASSERT_NO_FATAL_FAILURE( 127 ASSERT_NO_FATAL_FAILURE(
128 GetTestSSLInfo(EXCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, kCertStatus)); 128 GetTestSSLInfo(EXCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, kCertStatus));
129 ErrorReport report(kDummyHostname, ssl_info); 129 ErrorReport report(kDummyHostname, ssl_info);
130 130
131 report.SetInterstitialInfo(ErrorReport::INTERSTITIAL_CLOCK, 131 const base::Time interstitial_time = base::Time::Now();
132 ErrorReport::USER_PROCEEDED, 132 report.SetInterstitialInfo(
133 ErrorReport::INTERSTITIAL_OVERRIDABLE); 133 ErrorReport::INTERSTITIAL_CLOCK, ErrorReport::USER_PROCEEDED,
134 ErrorReport::INTERSTITIAL_OVERRIDABLE, interstitial_time);
134 135
135 ASSERT_TRUE(report.Serialize(&serialized_report)); 136 ASSERT_TRUE(report.Serialize(&serialized_report));
136 137
137 CertLoggerRequest deserialized_report; 138 CertLoggerRequest deserialized_report;
138 ASSERT_TRUE(deserialized_report.ParseFromString(serialized_report)); 139 ASSERT_TRUE(deserialized_report.ParseFromString(serialized_report));
139 EXPECT_EQ(kDummyHostname, deserialized_report.hostname()); 140 EXPECT_EQ(kDummyHostname, deserialized_report.hostname());
140 EXPECT_EQ(GetPEMEncodedChain(), deserialized_report.cert_chain()); 141 EXPECT_EQ(GetPEMEncodedChain(), deserialized_report.cert_chain());
141 EXPECT_EQ(std::string(), deserialized_report.unverified_cert_chain()); 142 EXPECT_EQ(std::string(), deserialized_report.unverified_cert_chain());
142 EXPECT_EQ(1, deserialized_report.pin().size()); 143 EXPECT_EQ(1, deserialized_report.pin().size());
143 EXPECT_EQ(kDummyFailureLog, deserialized_report.pin().Get(0)); 144 EXPECT_EQ(kDummyFailureLog, deserialized_report.pin().Get(0));
144 145
145 EXPECT_EQ(CertLoggerInterstitialInfo::INTERSTITIAL_CLOCK, 146 EXPECT_EQ(CertLoggerInterstitialInfo::INTERSTITIAL_CLOCK,
146 deserialized_report.interstitial_info().interstitial_reason()); 147 deserialized_report.interstitial_info().interstitial_reason());
147 EXPECT_EQ(true, deserialized_report.interstitial_info().user_proceeded()); 148 EXPECT_EQ(true, deserialized_report.interstitial_info().user_proceeded());
148 EXPECT_EQ(true, deserialized_report.interstitial_info().overridable()); 149 EXPECT_EQ(true, deserialized_report.interstitial_info().overridable());
149 EXPECT_EQ( 150 EXPECT_EQ(
150 ssl_info.is_issued_by_known_root, 151 ssl_info.is_issued_by_known_root,
151 deserialized_report.is_issued_by_known_root()); 152 deserialized_report.is_issued_by_known_root());
152 153
153 EXPECT_THAT( 154 EXPECT_THAT(
154 deserialized_report.cert_error(), 155 deserialized_report.cert_error(),
155 UnorderedElementsAre(kFirstReportedCertError, kSecondReportedCertError)); 156 UnorderedElementsAre(kFirstReportedCertError, kSecondReportedCertError));
157
158 EXPECT_EQ(
159 interstitial_time.ToInternalValue(),
160 deserialized_report.interstitial_info().interstitial_created_time_usec());
156 } 161 }
157 162
158 // Test that a serialized report can be parsed. 163 // Test that a serialized report can be parsed.
159 TEST(ErrorReportTest, ParseSerializedReport) { 164 TEST(ErrorReportTest, ParseSerializedReport) {
160 std::string serialized_report; 165 std::string serialized_report;
161 SSLInfo ssl_info; 166 SSLInfo ssl_info;
162 ASSERT_NO_FATAL_FAILURE( 167 ASSERT_NO_FATAL_FAILURE(
163 GetTestSSLInfo(INCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, kCertStatus)); 168 GetTestSSLInfo(INCLUDE_UNVERIFIED_CERT_CHAIN, &ssl_info, kCertStatus));
164 ErrorReport report(kDummyHostname, ssl_info); 169 ErrorReport report(kDummyHostname, ssl_info);
165 EXPECT_EQ(kDummyHostname, report.hostname()); 170 EXPECT_EQ(kDummyHostname, report.hostname());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 EXPECT_EQ(CertLoggerFeaturesInfo::NetworkTimeQueryingInfo:: 229 EXPECT_EQ(CertLoggerFeaturesInfo::NetworkTimeQueryingInfo::
225 NETWORK_TIME_FETCHES_ON_DEMAND_ONLY, 230 NETWORK_TIME_FETCHES_ON_DEMAND_ONLY,
226 parsed.features_info() 231 parsed.features_info()
227 .network_time_querying_info() 232 .network_time_querying_info()
228 .network_time_query_behavior()); 233 .network_time_query_behavior());
229 } 234 }
230 235
231 } // namespace 236 } // namespace
232 237
233 } // namespace certificate_reporting 238 } // 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