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" |
11 #include "base/sha1.h" | 11 #include "base/sha1.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "crypto/rsa_private_key.h" | 15 #include "crypto/rsa_private_key.h" |
16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
17 #include "net/base/test_data_directory.h" | 17 #include "net/base/test_data_directory.h" |
18 #include "net/cert/asn1_util.h" | 18 #include "net/cert/asn1_util.h" |
19 #include "net/test/cert_test_util.h" | 19 #include "net/test/cert_test_util.h" |
20 #include "net/test/test_certificate_data.h" | 20 #include "net/test/test_certificate_data.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
23 #if defined(USE_NSS) | 23 #if defined(USE_NSS_CERTS) |
24 #include <cert.h> | 24 #include <cert.h> |
25 #endif | 25 #endif |
26 | 26 |
27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
28 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
29 #endif | 29 #endif |
30 | 30 |
31 using base::HexEncode; | 31 using base::HexEncode; |
32 using base::Time; | 32 using base::Time; |
33 | 33 |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 issuers.clear(); | 789 issuers.clear(); |
790 issuers.push_back(mit_issuer); | 790 issuers.push_back(mit_issuer); |
791 EXPECT_FALSE(cert_chain->IsIssuedByEncoded(issuers)); | 791 EXPECT_FALSE(cert_chain->IsIssuedByEncoded(issuers)); |
792 } | 792 } |
793 | 793 |
794 // Tests that FreeOSCertHandle ignores NULL on each OS. | 794 // Tests that FreeOSCertHandle ignores NULL on each OS. |
795 TEST(X509CertificateTest, FreeNullHandle) { | 795 TEST(X509CertificateTest, FreeNullHandle) { |
796 X509Certificate::FreeOSCertHandle(NULL); | 796 X509Certificate::FreeOSCertHandle(NULL); |
797 } | 797 } |
798 | 798 |
799 #if defined(USE_NSS) | 799 #if defined(USE_NSS_CERTS) |
800 TEST(X509CertificateTest, GetDefaultNickname) { | 800 TEST(X509CertificateTest, GetDefaultNickname) { |
801 base::FilePath certs_dir = GetTestCertsDirectory(); | 801 base::FilePath certs_dir = GetTestCertsDirectory(); |
802 | 802 |
803 scoped_refptr<X509Certificate> test_cert( | 803 scoped_refptr<X509Certificate> test_cert( |
804 ImportCertFromFile(certs_dir, "no_subject_common_name_cert.pem")); | 804 ImportCertFromFile(certs_dir, "no_subject_common_name_cert.pem")); |
805 ASSERT_NE(static_cast<X509Certificate*>(NULL), test_cert.get()); | 805 ASSERT_NE(static_cast<X509Certificate*>(NULL), test_cert.get()); |
806 | 806 |
807 std::string nickname = test_cert->GetDefaultNickname(USER_CERT); | 807 std::string nickname = test_cert->GetDefaultNickname(USER_CERT); |
808 EXPECT_EQ("wtc@google.com's COMODO Client Authentication and " | 808 EXPECT_EQ("wtc@google.com's COMODO Client Authentication and " |
809 "Secure Email CA ID", nickname); | 809 "Secure Email CA ID", nickname); |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 &actual_type); | 1193 &actual_type); |
1194 | 1194 |
1195 EXPECT_EQ(data.expected_bits, actual_bits); | 1195 EXPECT_EQ(data.expected_bits, actual_bits); |
1196 EXPECT_EQ(data.expected_type, actual_type); | 1196 EXPECT_EQ(data.expected_type, actual_type); |
1197 } | 1197 } |
1198 | 1198 |
1199 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest, | 1199 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest, |
1200 testing::ValuesIn(kPublicKeyInfoTestData)); | 1200 testing::ValuesIn(kPublicKeyInfoTestData)); |
1201 | 1201 |
1202 } // namespace net | 1202 } // namespace net |
OLD | NEW |