OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/crypto/rsa_private_key.h" | 5 #include "base/crypto/rsa_private_key.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 #include "net/base/cert_status_flags.h" | 10 #include "net/base/cert_status_flags.h" |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 TEST(X509CertificateTest, CreateSelfSigned) { | 665 TEST(X509CertificateTest, CreateSelfSigned) { |
666 scoped_ptr<base::RSAPrivateKey> private_key( | 666 scoped_ptr<base::RSAPrivateKey> private_key( |
667 base::RSAPrivateKey::Create(1024)); | 667 base::RSAPrivateKey::Create(1024)); |
668 scoped_refptr<net::X509Certificate> cert = | 668 scoped_refptr<net::X509Certificate> cert = |
669 net::X509Certificate::CreateSelfSigned( | 669 net::X509Certificate::CreateSelfSigned( |
670 private_key.get(), "CN=subject", 1, base::TimeDelta::FromDays(1)); | 670 private_key.get(), "CN=subject", 1, base::TimeDelta::FromDays(1)); |
671 | 671 |
672 EXPECT_EQ("subject", cert->subject().GetDisplayName()); | 672 EXPECT_EQ("subject", cert->subject().GetDisplayName()); |
673 EXPECT_FALSE(cert->HasExpired()); | 673 EXPECT_FALSE(cert->HasExpired()); |
674 } | 674 } |
| 675 |
| 676 TEST(X509CertificateTest, GetDEREncoded) { |
| 677 scoped_ptr<base::RSAPrivateKey> private_key( |
| 678 base::RSAPrivateKey::Create(1024)); |
| 679 scoped_refptr<net::X509Certificate> cert = |
| 680 net::X509Certificate::CreateSelfSigned( |
| 681 private_key.get(), "CN=subject", 0, base::TimeDelta::FromDays(1)); |
| 682 |
| 683 std::string der_cert; |
| 684 EXPECT_TRUE(cert->GetDEREncoded(&der_cert)); |
| 685 EXPECT_FALSE(der_cert.empty()); |
| 686 } |
675 #endif | 687 #endif |
676 | 688 |
677 class X509CertificateParseTest | 689 class X509CertificateParseTest |
678 : public testing::TestWithParam<CertificateFormatTestData> { | 690 : public testing::TestWithParam<CertificateFormatTestData> { |
679 public: | 691 public: |
680 virtual ~X509CertificateParseTest() {} | 692 virtual ~X509CertificateParseTest() {} |
681 virtual void SetUp() { | 693 virtual void SetUp() { |
682 test_data_ = GetParam(); | 694 test_data_ = GetParam(); |
683 } | 695 } |
684 virtual void TearDown() {} | 696 virtual void TearDown() {} |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 728 |
717 for (size_t j = 0; j < 20; ++j) | 729 for (size_t j = 0; j < 20; ++j) |
718 EXPECT_EQ(expected_fingerprint[j], actual_fingerprint.data[j]); | 730 EXPECT_EQ(expected_fingerprint[j], actual_fingerprint.data[j]); |
719 } | 731 } |
720 } | 732 } |
721 | 733 |
722 INSTANTIATE_TEST_CASE_P(, X509CertificateParseTest, | 734 INSTANTIATE_TEST_CASE_P(, X509CertificateParseTest, |
723 testing::ValuesIn(FormatTestData)); | 735 testing::ValuesIn(FormatTestData)); |
724 | 736 |
725 } // namespace net | 737 } // namespace net |
OLD | NEW |