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

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: revert Created 4 years, 2 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 59544094c29c26b8dbeab36c6c4c1060a7105ce1..eb62200b236d1502a614cf072f834fd4df7aad19 100644
--- a/net/cert/ct_policy_enforcer_unittest.cc
+++ b/net/cert/ct_policy_enforcer_unittest.cc
@@ -85,11 +85,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);
@@ -111,10 +111,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);
@@ -443,38 +444,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},
eroman 2016/10/20 18:05:21 This pattern is common enough in this file that I
maksims (do not use this acc) 2016/10/26 08:16:40 Done.
+ &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);

Powered by Google App Engine
This is Rietveld 408576698