| OLD | NEW |
| 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 "net/cert/x509_util.h" | 7 #include "net/cert/x509_util.h" |
| 8 #include "net/cert/x509_util_openssl.h" | 8 #include "net/cert/x509_util_openssl.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 base::Time too_late = base::Time::UnixEpoch() + | 28 base::Time too_late = base::Time::UnixEpoch() + |
| 29 base::TimeDelta::FromDays(kDaysFromUnixEpochToYear10000 + 1); | 29 base::TimeDelta::FromDays(kDaysFromUnixEpochToYear10000 + 1); |
| 30 | 30 |
| 31 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_old, too_old)); | 31 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_old, too_old)); |
| 32 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_old, now)); | 32 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_old, now)); |
| 33 | 33 |
| 34 EXPECT_FALSE(x509_util::IsSupportedValidityRange(now, too_late)); | 34 EXPECT_FALSE(x509_util::IsSupportedValidityRange(now, too_late)); |
| 35 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_late, too_late)); | 35 EXPECT_FALSE(x509_util::IsSupportedValidityRange(too_late, too_late)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // For OpenSSL, x509_util::CreateDomainBoundCertEC() is not yet implemented | 38 // For OpenSSL, x509_util::CreateKeyAndDomainBoundCertEC() is not yet |
| 39 // and should return false. This unit test ensures that a stub implementation | 39 // implemented and should return false. This unit test ensures that a stub |
| 40 // is present. | 40 // implementation is present. |
| 41 TEST(X509UtilOpenSSLTest, CreateDomainBoundCertNotImplemented) { | 41 TEST(X509UtilOpenSSLTest, CreateDomainBoundCertNotImplemented) { |
| 42 std::string domain = "weborigin.com"; | 42 std::string domain = "weborigin.com"; |
| 43 base::Time now = base::Time::Now(); | 43 base::Time now = base::Time::Now(); |
| 44 scoped_ptr<crypto::ECPrivateKey> private_key( | 44 crypto::ECPrivateKey* raw_key = NULL; |
| 45 crypto::ECPrivateKey::Create()); | |
| 46 std::string der_cert; | 45 std::string der_cert; |
| 47 EXPECT_FALSE(x509_util::CreateDomainBoundCertEC( | 46 EXPECT_FALSE(x509_util::CreateKeyAndDomainBoundCertEC( |
| 48 private_key.get(), | |
| 49 domain, 1, | 47 domain, 1, |
| 50 now, | 48 now, |
| 51 now + base::TimeDelta::FromDays(1), | 49 now + base::TimeDelta::FromDays(1), |
| 50 &raw_key, |
| 52 &der_cert)); | 51 &der_cert)); |
| 53 EXPECT_TRUE(der_cert.empty()); | 52 EXPECT_TRUE(der_cert.empty()); |
| 54 | 53 EXPECT_FALSE(raw_key != NULL); |
| 55 } | 54 } |
| 56 | 55 |
| 57 } // namespace net | 56 } // namespace net |
| OLD | NEW |