diff options
author | digit@chromium.org <digit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-22 17:04:21 +0000 |
---|---|---|
committer | digit@chromium.org <digit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-22 17:04:21 +0000 |
commit | 3d41975570b7c46049ef9e3e2c22bef5727e62ea (patch) | |
tree | bf202ff97a7da5bc5346b16389dc3c850d401570 /net/base/x509_util_openssl_unittest.cc | |
parent | 7f828fd2440991e4b28b7ed60a75d294a81d64ff (diff) | |
download | chromium_src-3d41975570b7c46049ef9e3e2c22bef5727e62ea.zip chromium_src-3d41975570b7c46049ef9e3e2c22bef5727e62ea.tar.gz chromium_src-3d41975570b7c46049ef9e3e2c22bef5727e62ea.tar.bz2 |
Implement x509_util::IsSupportedValidityRange() for Android / openssl.
The previous UNIMPLEMENTED() appears a lot is warnings/errors during
net_unittests otherwise.
BUG=
Review URL: https://chromiumcodereview.appspot.com/11348128
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/x509_util_openssl_unittest.cc')
-rw-r--r-- | net/base/x509_util_openssl_unittest.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/net/base/x509_util_openssl_unittest.cc b/net/base/x509_util_openssl_unittest.cc index 2067505..eea3984 100644 --- a/net/base/x509_util_openssl_unittest.cc +++ b/net/base/x509_util_openssl_unittest.cc @@ -10,6 +10,31 @@ namespace net { +TEST(X509UtilOpenSSLTest, IsSupportedValidityRange) { + base::Time now = base::Time::Now(); + EXPECT_TRUE(x509_util::IsSupportedValidityRange(now, now)); + EXPECT_FALSE(x509_util::IsSupportedValidityRange( + now, now - base::TimeDelta::FromSeconds(1))); + + // See x509_util_openssl.cc to see how these were computed. + const int64 kDaysFromYear0001ToUnixEpoch = 719162; + const int64 kDaysFromUnixEpochToYear10000 = 2932896 + 1; + + // When computing too_old / too_late, add one day to account for + // possible leap seconds. + base::Time too_old = base::Time::UnixEpoch() - + base::TimeDelta::FromDays(kDaysFromYear0001ToUnixEpoch + 1); + + base::Time too_late = base::Time::UnixEpoch() + + base::TimeDelta::FromDays(kDaysFromUnixEpochToYear10000 + 1); + + EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_old, too_old)); + EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_old, now)); + + EXPECT_FALSE(x509_util::IsSupportedValidityRange(now, too_late)); + EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_late, too_late)); +} + // For OpenSSL, x509_util::CreateDomainBoundCertEC() is not yet implemented // and should return false. This unit test ensures that a stub implementation // is present. |