Chromium Code Reviews| Index: content/common/origin_trials/trial_token_validator_unittest.cc |
| diff --git a/content/common/origin_trials/trial_token_validator_unittest.cc b/content/common/origin_trials/trial_token_validator_unittest.cc |
| index 19b5d44c57e6f5b46d8c425c3049c970ef8acdeb..877216a8c5bc2398e62b5b266011c0527e225471 100644 |
| --- a/content/common/origin_trials/trial_token_validator_unittest.cc |
| +++ b/content/common/origin_trials/trial_token_validator_unittest.cc |
| @@ -98,6 +98,12 @@ const char kInsecureOriginToken[] = |
| "YW1wbGUuY29tOjgwIiwgImZlYXR1cmUiOiAiRnJvYnVsYXRlIiwgImV4cGlyeSI6" |
| "IDIwMDAwMDAwMDB9"; |
| +// These timestamps should be in the past and future, respectively. Sanity |
| +// checks within the tests assert that that is true, to guard against poorly-set |
| +// system clocks. (And against the inevitable march of time past the year 2033) |
| +double kPastTimestamp = 1000000000; |
| +double kFutureTimestamp = 2000000000; |
|
Marc Treib
2016/12/08 16:40:45
Should probably make these const
|
| + |
| class TestOriginTrialPolicy : public OriginTrialPolicy { |
| public: |
| base::StringPiece GetPublicKey() const override { |
| @@ -152,6 +158,15 @@ class TrialTokenValidatorTest : public testing::Test { |
| ~TrialTokenValidatorTest() override { SetContentClient(nullptr); } |
| + void SetUp() override { |
| + // Ensure that the system clock is set to a date that the matches the test |
| + // expectations. If this fails, either the clock on the test device is |
| + // incorrect, or the actual date is after 2033-05-18, and the tokens need to |
| + // be regenerated. |
| + ASSERT_GT(base::Time::Now(), base::Time::FromDoubleT(kPastTimestamp)); |
| + ASSERT_LT(base::Time::Now(), base::Time::FromDoubleT(kFutureTimestamp)); |
| + } |
| + |
| void SetPublicKey(const uint8_t* key) { |
| test_content_client_.SetOriginTrialPublicKey(key); |
| } |