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 <cert.h> | 5 #include <cert.h> |
6 #include <pk11pub.h> | 6 #include <pk11pub.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/crypto/scoped_nss_types.h" | 10 #include "base/crypto/scoped_nss_types.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 base::ScopedPK11Slot slot_; | 129 base::ScopedPK11Slot slot_; |
130 CertDatabase cert_db_; | 130 CertDatabase cert_db_; |
131 | 131 |
132 private: | 132 private: |
133 static bool temp_db_initialized_; | 133 static bool temp_db_initialized_; |
134 }; | 134 }; |
135 | 135 |
136 // static | 136 // static |
137 bool CertDatabaseNSSTest::temp_db_initialized_ = false; | 137 bool CertDatabaseNSSTest::temp_db_initialized_ = false; |
138 | 138 |
| 139 TEST_F(CertDatabaseNSSTest, ListCerts) { |
| 140 // This test isn't terribly useful, though it will at least let valgrind test |
| 141 // for leaks. |
| 142 CertificateList certs; |
| 143 cert_db_.ListCerts(&certs); |
| 144 // The test DB is empty, but let's assume there will always be something in |
| 145 // the other slots. |
| 146 EXPECT_LT(0U, certs.size()); |
| 147 } |
| 148 |
139 TEST_F(CertDatabaseNSSTest, ImportFromPKCS12WrongPassword) { | 149 TEST_F(CertDatabaseNSSTest, ImportFromPKCS12WrongPassword) { |
140 std::string pkcs12_data = ReadTestFile("client.p12"); | 150 std::string pkcs12_data = ReadTestFile("client.p12"); |
141 | 151 |
142 EXPECT_EQ(ERR_PKCS12_IMPORT_BAD_PASSWORD, | 152 EXPECT_EQ(ERR_PKCS12_IMPORT_BAD_PASSWORD, |
143 cert_db_.ImportFromPKCS12(pkcs12_data, ASCIIToUTF16(""))); | 153 cert_db_.ImportFromPKCS12(pkcs12_data, ASCIIToUTF16(""))); |
144 | 154 |
145 // Test db should still be empty. | 155 // Test db should still be empty. |
146 EXPECT_EQ(0U, ListCertsInSlot(slot_.get()).size()); | 156 EXPECT_EQ(0U, ListCertsInSlot(slot_.get()).size()); |
147 } | 157 } |
148 | 158 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 EXPECT_EQ("DOD CA-17", failed[1].certificate->subject().common_name); | 412 EXPECT_EQ("DOD CA-17", failed[1].certificate->subject().common_name); |
403 EXPECT_EQ(ERR_FAILED, failed[1].net_error); | 413 EXPECT_EQ(ERR_FAILED, failed[1].net_error); |
404 | 414 |
405 CertificateList cert_list = ListCertsInSlot(slot_.get()); | 415 CertificateList cert_list = ListCertsInSlot(slot_.get()); |
406 ASSERT_EQ(1U, cert_list.size()); | 416 ASSERT_EQ(1U, cert_list.size()); |
407 EXPECT_EQ("Test CA", cert_list[0]->subject().common_name); | 417 EXPECT_EQ("Test CA", cert_list[0]->subject().common_name); |
408 } | 418 } |
409 | 419 |
410 | 420 |
411 } // namespace net | 421 } // namespace net |
OLD | NEW |