Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: net/base/cert_database_nss_unittest.cc

Issue 5686002: NSS: PKCS 11 password prompt. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/cert_database_nss_unittest.cc
diff --git a/net/base/cert_database_nss_unittest.cc b/net/base/cert_database_nss_unittest.cc
index 5056e5dfbfdac1d57476b46c94c9786de268e00f..1ab176fe0716773736536776950df84e5527181a 100644
--- a/net/base/cert_database_nss_unittest.cc
+++ b/net/base/cert_database_nss_unittest.cc
@@ -21,6 +21,7 @@
#include "net/base/cert_status_flags.h"
#include "net/base/cert_verify_result.h"
#include "net/base/net_errors.h"
+#include "net/base/pk11_slot.h"
#include "net/base/x509_certificate.h"
#include "net/third_party/mozilla_security_manager/nsNSSCertificateDB.h"
#include "net/third_party/mozilla_security_manager/nsNSSCertTrust.h"
@@ -115,6 +116,7 @@ class CertDatabaseNSSTest : public testing::Test {
temp_db_initialized_ = true;
}
slot_.reset(base::GetDefaultNSSKeySlot());
+ slot_wrapper_ = PK11Slot::CreateFromHandle(slot_.get());
// Test db should be empty at start of test.
EXPECT_EQ(0U, ListCertsInSlot(slot_.get()).size());
@@ -130,6 +132,7 @@ class CertDatabaseNSSTest : public testing::Test {
protected:
base::ScopedPK11Slot slot_;
+ scoped_refptr<PK11Slot> slot_wrapper_;
wtc 2010/12/15 20:54:36 Nit: we only need one of slot_ and slot_wrapper_.
mattm 2011/01/12 01:22:07 Done.
CertDatabase cert_db_;
private:
@@ -149,11 +152,22 @@ TEST_F(CertDatabaseNSSTest, ListCerts) {
EXPECT_LT(0U, certs.size());
}
+TEST_F(CertDatabaseNSSTest, ListTokensForPKCS12) {
+ // This test isn't terribly useful, though it will at least let valgrind test
+ // for leaks.
+ PK11SlotList slots;
+ cert_db_.ListTokensForPKCS12(&slots);
+ // Should have the main slot and the temp test slot.
+ EXPECT_EQ(2U, slots.size());
+}
+
TEST_F(CertDatabaseNSSTest, ImportFromPKCS12WrongPassword) {
std::string pkcs12_data = ReadTestFile("client.p12");
EXPECT_EQ(ERR_PKCS12_IMPORT_BAD_PASSWORD,
- cert_db_.ImportFromPKCS12(pkcs12_data, ASCIIToUTF16("")));
+ cert_db_.ImportFromPKCS12(slot_wrapper_,
+ pkcs12_data,
+ ASCIIToUTF16("")));
// Test db should still be empty.
EXPECT_EQ(0U, ListCertsInSlot(slot_.get()).size());
@@ -162,7 +176,9 @@ TEST_F(CertDatabaseNSSTest, ImportFromPKCS12WrongPassword) {
TEST_F(CertDatabaseNSSTest, ImportFromPKCS12AndExportAgain) {
std::string pkcs12_data = ReadTestFile("client.p12");
- EXPECT_EQ(OK, cert_db_.ImportFromPKCS12(pkcs12_data, ASCIIToUTF16("12345")));
+ EXPECT_EQ(OK, cert_db_.ImportFromPKCS12(slot_wrapper_,
+ pkcs12_data,
+ ASCIIToUTF16("12345")));
CertificateList cert_list = ListCertsInSlot(slot_.get());
ASSERT_EQ(1U, cert_list.size());

Powered by Google App Engine
This is Rietveld 408576698