| 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 "net/cert/x509_certificate.h" | 5 #include "net/cert/x509_certificate.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 EXPECT_TRUE(google_cert->IsIssuedByEncoded(issuers)); | 707 EXPECT_TRUE(google_cert->IsIssuedByEncoded(issuers)); |
| 708 | 708 |
| 709 // Check that they both pass when given a list of the two issuers. | 709 // Check that they both pass when given a list of the two issuers. |
| 710 issuers.clear(); | 710 issuers.clear(); |
| 711 issuers.push_back(mit_issuer); | 711 issuers.push_back(mit_issuer); |
| 712 issuers.push_back(thawte_issuer); | 712 issuers.push_back(thawte_issuer); |
| 713 EXPECT_TRUE(mit_davidben_cert->IsIssuedByEncoded(issuers)); | 713 EXPECT_TRUE(mit_davidben_cert->IsIssuedByEncoded(issuers)); |
| 714 EXPECT_TRUE(google_cert->IsIssuedByEncoded(issuers)); | 714 EXPECT_TRUE(google_cert->IsIssuedByEncoded(issuers)); |
| 715 } | 715 } |
| 716 | 716 |
| 717 TEST(X509CertificateTest, IsSelfSigned) { |
| 718 base::FilePath certs_dir = GetTestCertsDirectory(); |
| 719 |
| 720 scoped_refptr<X509Certificate> cert( |
| 721 ImportCertFromFile(certs_dir, "mit.davidben.der")); |
| 722 ASSERT_NE(static_cast<X509Certificate*>(NULL), cert.get()); |
| 723 EXPECT_FALSE(X509Certificate::IsSelfSigned(cert->os_cert_handle())); |
| 724 |
| 725 scoped_refptr<X509Certificate> self_signed( |
| 726 ImportCertFromFile(certs_dir, "aia-root.pem")); |
| 727 ASSERT_NE(static_cast<X509Certificate*>(NULL), self_signed.get()); |
| 728 EXPECT_TRUE(X509Certificate::IsSelfSigned(self_signed->os_cert_handle())); |
| 729 } |
| 730 |
| 717 TEST(X509CertificateTest, IsIssuedByEncodedWithIntermediates) { | 731 TEST(X509CertificateTest, IsIssuedByEncodedWithIntermediates) { |
| 718 static const unsigned char kPolicyRootDN[] = { | 732 static const unsigned char kPolicyRootDN[] = { |
| 719 0x30, 0x1e, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, | 733 0x30, 0x1e, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, |
| 720 0x13, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, | 734 0x13, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, |
| 721 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41 | 735 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41 |
| 722 }; | 736 }; |
| 723 static const unsigned char kPolicyIntermediateDN[] = { | 737 static const unsigned char kPolicyIntermediateDN[] = { |
| 724 0x30, 0x26, 0x31, 0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, | 738 0x30, 0x26, 0x31, 0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, |
| 725 0x1b, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, | 739 0x1b, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, |
| 726 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, | 740 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 &actual_type); | 1191 &actual_type); |
| 1178 | 1192 |
| 1179 EXPECT_EQ(data.expected_bits, actual_bits); | 1193 EXPECT_EQ(data.expected_bits, actual_bits); |
| 1180 EXPECT_EQ(data.expected_type, actual_type); | 1194 EXPECT_EQ(data.expected_type, actual_type); |
| 1181 } | 1195 } |
| 1182 | 1196 |
| 1183 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest, | 1197 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest, |
| 1184 testing::ValuesIn(kPublicKeyInfoTestData)); | 1198 testing::ValuesIn(kPublicKeyInfoTestData)); |
| 1185 | 1199 |
| 1186 } // namespace net | 1200 } // namespace net |
| OLD | NEW |