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

Side by Side Diff: net/cert/x509_util_openssl_unittest.cc

Issue 1158923005: Use the exact-width integer types defined in <stdint.h> rather than (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak comments. Exclude mime_sniffer*. Rebase. Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "crypto/ec_private_key.h" 6 #include "crypto/ec_private_key.h"
7 #include "crypto/openssl_util.h" 7 #include "crypto/openssl_util.h"
8 #include "crypto/scoped_openssl_types.h" 8 #include "crypto/scoped_openssl_types.h"
9 #include "net/cert/x509_util.h" 9 #include "net/cert/x509_util.h"
10 #include "net/cert/x509_util_openssl.h" 10 #include "net/cert/x509_util_openssl.h"
11 #include "net/ssl/scoped_openssl_types.h" 11 #include "net/ssl/scoped_openssl_types.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 TEST(X509UtilOpenSSLTest, IsSupportedValidityRange) { 16 TEST(X509UtilOpenSSLTest, IsSupportedValidityRange) {
17 base::Time now = base::Time::Now(); 17 base::Time now = base::Time::Now();
18 EXPECT_TRUE(x509_util::IsSupportedValidityRange(now, now)); 18 EXPECT_TRUE(x509_util::IsSupportedValidityRange(now, now));
19 EXPECT_FALSE(x509_util::IsSupportedValidityRange( 19 EXPECT_FALSE(x509_util::IsSupportedValidityRange(
20 now, now - base::TimeDelta::FromSeconds(1))); 20 now, now - base::TimeDelta::FromSeconds(1)));
21 21
22 // See x509_util_openssl.cc to see how these were computed. 22 // See x509_util_openssl.cc to see how these were computed.
23 const int64 kDaysFromYear0001ToUnixEpoch = 719162; 23 const int64_t kDaysFromYear0001ToUnixEpoch = 719162;
24 const int64 kDaysFromUnixEpochToYear10000 = 2932896 + 1; 24 const int64_t kDaysFromUnixEpochToYear10000 = 2932896 + 1;
25 25
26 // When computing too_old / too_late, add one day to account for 26 // When computing too_old / too_late, add one day to account for
27 // possible leap seconds. 27 // possible leap seconds.
28 base::Time too_old = base::Time::UnixEpoch() - 28 base::Time too_old = base::Time::UnixEpoch() -
29 base::TimeDelta::FromDays(kDaysFromYear0001ToUnixEpoch + 1); 29 base::TimeDelta::FromDays(kDaysFromYear0001ToUnixEpoch + 1);
30 30
31 base::Time too_late = base::Time::UnixEpoch() + 31 base::Time too_late = base::Time::UnixEpoch() +
32 base::TimeDelta::FromDays(kDaysFromUnixEpochToYear10000 + 1); 32 base::TimeDelta::FromDays(kDaysFromUnixEpochToYear10000 + 1);
33 33
34 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_old, too_old)); 34 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_old, too_old));
35 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_old, now)); 35 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_old, now));
36 36
37 EXPECT_FALSE(x509_util::IsSupportedValidityRange(now, too_late)); 37 EXPECT_FALSE(x509_util::IsSupportedValidityRange(now, too_late));
38 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_late, too_late)); 38 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_late, too_late));
39 } 39 }
40 40
41 } // namespace net 41 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698