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

Unified Diff: net/cert/ct_policy_enforcer_unittest.cc

Issue 2090713003: Make callers of FromUTC(Local)Exploded in net/ use new time API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 4 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: net/cert/ct_policy_enforcer_unittest.cc
diff --git a/net/cert/ct_policy_enforcer_unittest.cc b/net/cert/ct_policy_enforcer_unittest.cc
index e86ff256b85f0e80f7de45da0a87cfb450e6264a..85f733408c7c7de97d1e41dc9635879da4aae52b 100644
--- a/net/cert/ct_policy_enforcer_unittest.cc
+++ b/net/cert/ct_policy_enforcer_unittest.cc
@@ -84,11 +84,11 @@ class CTPolicyEnforcerTest : public ::testing::Test {
sct->log_id = std::string(crypto::kSHA256Length, static_cast<char>(i));
if (timestamp_past_enforcement_date) {
- sct->timestamp =
- base::Time::FromUTCExploded({2015, 8, 0, 15, 0, 0, 0, 0});
+ EXPECT_TRUE(base::Time::FromUTCExploded({2015, 8, 0, 15, 0, 0, 0, 0},
+ &sct->timestamp));
} else {
- sct->timestamp =
- base::Time::FromUTCExploded({2015, 6, 0, 15, 0, 0, 0, 0});
+ EXPECT_TRUE(base::Time::FromUTCExploded({2015, 6, 0, 15, 0, 0, 0, 0},
+ &sct->timestamp));
}
verified_scts->push_back(sct);
@@ -110,10 +110,11 @@ class CTPolicyEnforcerTest : public ::testing::Test {
sct->origin = desired_origin;
sct->log_id = std::string(kCertlyLogID, crypto::kSHA256Length);
if (timestamp_after_disqualification_date) {
- sct->timestamp =
- base::Time::FromUTCExploded({2016, 4, 0, 16, 0, 0, 0, 0});
+ EXPECT_TRUE(base::Time::FromUTCExploded({2016, 4, 0, 16, 0, 0, 0, 0},
+ &sct->timestamp));
} else {
- sct->timestamp = base::Time::FromUTCExploded({2016, 4, 0, 1, 0, 0, 0, 0});
+ EXPECT_TRUE(base::Time::FromUTCExploded({2016, 4, 0, 1, 0, 0, 0, 0},
+ &sct->timestamp));
}
verified_scts->push_back(sct);
@@ -442,38 +443,56 @@ TEST_F(CTPolicyEnforcerTest,
ASSERT_TRUE(private_key);
// Test multiple validity periods
+ base::Time time_2015_3_0_25_11_25_0_0;
+ EXPECT_TRUE(base::Time::FromUTCExploded({2015, 3, 0, 25, 11, 25, 0, 0},
+ &time_2015_3_0_25_11_25_0_0));
+
+ base::Time time_2016_6_0_6_11_25_0_0;
+ EXPECT_TRUE(base::Time::FromUTCExploded({2016, 6, 0, 6, 11, 25, 0, 0},
+ &time_2016_6_0_6_11_25_0_0));
+
+ base::Time time_2016_6_0_25_11_25_0_0;
+ EXPECT_TRUE(base::Time::FromUTCExploded({2016, 6, 0, 25, 11, 25, 0, 0},
+ &time_2016_6_0_25_11_25_0_0));
+
+ base::Time time_2016_6_0_27_11_25_0_0;
+ EXPECT_TRUE(base::Time::FromUTCExploded({2016, 6, 0, 27, 11, 25, 0, 0},
+ &time_2016_6_0_27_11_25_0_0));
+
+ base::Time time_2017_6_0_25_11_25_0_0;
+ EXPECT_TRUE(base::Time::FromUTCExploded({2017, 6, 0, 25, 11, 25, 0, 0},
+ &time_2017_6_0_25_11_25_0_0));
+
+ base::Time time_2017_6_0_28_11_25_0_0;
+ EXPECT_TRUE(base::Time::FromUTCExploded({2017, 6, 0, 28, 11, 25, 0, 0},
+ &time_2017_6_0_28_11_25_0_0));
+
+ base::Time time_2018_6_0_25_11_25_0_0;
+ EXPECT_TRUE(base::Time::FromUTCExploded({2018, 6, 0, 25, 11, 25, 0, 0},
+ &time_2018_6_0_25_11_25_0_0));
+
+ base::Time time_2018_6_0_27_11_25_0_0;
+ EXPECT_TRUE(base::Time::FromUTCExploded({2018, 6, 0, 27, 11, 25, 0, 0},
+ &time_2018_6_0_27_11_25_0_0));
+
const struct TestData {
base::Time validity_start;
base::Time validity_end;
size_t scts_required;
} kTestData[] = {{// Cert valid for 14 months, needs 2 SCTs.
- base::Time::FromUTCExploded({2015, 3, 0, 25, 11, 25, 0, 0}),
- base::Time::FromUTCExploded({2016, 6, 0, 6, 11, 25, 0, 0}),
- 2},
+ time_2015_3_0_25_11_25_0_0, time_2016_6_0_6_11_25_0_0, 2},
{// Cert valid for exactly 15 months, needs 3 SCTs.
- base::Time::FromUTCExploded({2015, 3, 0, 25, 11, 25, 0, 0}),
- base::Time::FromUTCExploded({2016, 6, 0, 25, 11, 25, 0, 0}),
- 3},
+ time_2015_3_0_25_11_25_0_0, time_2016_6_0_25_11_25_0_0, 3},
{// Cert valid for over 15 months, needs 3 SCTs.
- base::Time::FromUTCExploded({2015, 3, 0, 25, 11, 25, 0, 0}),
- base::Time::FromUTCExploded({2016, 6, 0, 27, 11, 25, 0, 0}),
- 3},
+ time_2015_3_0_25_11_25_0_0, time_2016_6_0_27_11_25_0_0, 3},
{// Cert valid for exactly 27 months, needs 3 SCTs.
- base::Time::FromUTCExploded({2015, 3, 0, 25, 11, 25, 0, 0}),
- base::Time::FromUTCExploded({2017, 6, 0, 25, 11, 25, 0, 0}),
- 3},
+ time_2015_3_0_25_11_25_0_0, time_2017_6_0_25_11_25_0_0, 3},
{// Cert valid for over 27 months, needs 4 SCTs.
- base::Time::FromUTCExploded({2015, 3, 0, 25, 11, 25, 0, 0}),
- base::Time::FromUTCExploded({2017, 6, 0, 28, 11, 25, 0, 0}),
- 4},
+ time_2015_3_0_25_11_25_0_0, time_2017_6_0_28_11_25_0_0, 4},
{// Cert valid for exactly 39 months, needs 4 SCTs.
- base::Time::FromUTCExploded({2015, 3, 0, 25, 11, 25, 0, 0}),
- base::Time::FromUTCExploded({2018, 6, 0, 25, 11, 25, 0, 0}),
- 4},
+ time_2015_3_0_25_11_25_0_0, time_2018_6_0_25_11_25_0_0, 4},
{// Cert valid for over 39 months, needs 5 SCTs.
- base::Time::FromUTCExploded({2015, 3, 0, 25, 11, 25, 0, 0}),
- base::Time::FromUTCExploded({2018, 6, 0, 27, 11, 25, 0, 0}),
- 5}};
+ time_2015_3_0_25_11_25_0_0, time_2018_6_0_27_11_25_0_0, 5}};
for (size_t i = 0; i < arraysize(kTestData); ++i) {
SCOPED_TRACE(i);
« no previous file with comments | « net/cert/cert_verify_proc.cc ('k') | net/cert/x509_cert_types.cc » ('j') | net/ftp/ftp_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698