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

Unified Diff: net/cert/nss_cert_database_unittest.cc

Issue 2600053002: net: change ImportFromPKCS12() to take a PK11SlotInfo* (Closed)
Patch Set: REBASE Created 3 years, 11 months 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
« no previous file with comments | « net/cert/nss_cert_database.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/nss_cert_database_unittest.cc
diff --git a/net/cert/nss_cert_database_unittest.cc b/net/cert/nss_cert_database_unittest.cc
index 983228902abe9ce76f81f280d733b6db868f8492..235ea44cc0d479be12c91ca4379e628a07e0618b 100644
--- a/net/cert/nss_cert_database_unittest.cc
+++ b/net/cert/nss_cert_database_unittest.cc
@@ -68,7 +68,7 @@ class CertDatabaseNSSTest : public testing::Test {
PK11_ReferenceSlot(test_nssdb_.slot())) /* public slot */,
crypto::ScopedPK11Slot(
PK11_ReferenceSlot(test_nssdb_.slot())) /* private slot */));
- public_module_ = cert_db_->GetPublicModule();
+ public_slot_ = cert_db_->GetPublicSlot();
// Test db should be empty at start of test.
EXPECT_EQ(0U, ListCerts().size());
@@ -82,7 +82,7 @@ class CertDatabaseNSSTest : public testing::Test {
}
protected:
- CryptoModule* GetPublicModule() { return public_module_.get(); }
+ PK11SlotInfo* GetPublicSlot() { return public_slot_.get(); }
static std::string ReadTestFile(const std::string& name) {
std::string result;
@@ -128,7 +128,7 @@ class CertDatabaseNSSTest : public testing::Test {
std::unique_ptr<NSSCertDatabase> cert_db_;
const CertificateList empty_cert_list_;
crypto::ScopedTestNSSDB test_nssdb_;
- scoped_refptr<CryptoModule> public_module_;
+ crypto::ScopedPK11Slot public_slot_;
};
TEST_F(CertDatabaseNSSTest, ListCertsSync) {
@@ -160,7 +160,7 @@ TEST_F(CertDatabaseNSSTest, ImportFromPKCS12WrongPassword) {
std::string pkcs12_data = ReadTestFile("client.p12");
EXPECT_EQ(ERR_PKCS12_IMPORT_BAD_PASSWORD,
- cert_db_->ImportFromPKCS12(GetPublicModule(),
+ cert_db_->ImportFromPKCS12(GetPublicSlot(),
pkcs12_data,
base::string16(),
true, // is_extractable
@@ -174,7 +174,7 @@ TEST_F(CertDatabaseNSSTest, ImportFromPKCS12AsExtractableAndExportAgain) {
std::string pkcs12_data = ReadTestFile("client.p12");
EXPECT_EQ(OK,
- cert_db_->ImportFromPKCS12(GetPublicModule(),
+ cert_db_->ImportFromPKCS12(GetPublicSlot(),
pkcs12_data,
ASCIIToUTF16("12345"),
true, // is_extractable
@@ -199,7 +199,7 @@ TEST_F(CertDatabaseNSSTest, ImportFromPKCS12Twice) {
std::string pkcs12_data = ReadTestFile("client.p12");
EXPECT_EQ(OK,
- cert_db_->ImportFromPKCS12(GetPublicModule(),
+ cert_db_->ImportFromPKCS12(GetPublicSlot(),
pkcs12_data,
ASCIIToUTF16("12345"),
true, // is_extractable
@@ -209,7 +209,7 @@ TEST_F(CertDatabaseNSSTest, ImportFromPKCS12Twice) {
// NSS has a SEC_ERROR_PKCS12_DUPLICATE_DATA error, but it doesn't look like
// it's ever used. This test verifies that.
EXPECT_EQ(OK,
- cert_db_->ImportFromPKCS12(GetPublicModule(),
+ cert_db_->ImportFromPKCS12(GetPublicSlot(),
pkcs12_data,
ASCIIToUTF16("12345"),
true, // is_extractable
@@ -221,7 +221,7 @@ TEST_F(CertDatabaseNSSTest, ImportFromPKCS12AsUnextractableAndExportAgain) {
std::string pkcs12_data = ReadTestFile("client.p12");
EXPECT_EQ(OK,
- cert_db_->ImportFromPKCS12(GetPublicModule(),
+ cert_db_->ImportFromPKCS12(GetPublicSlot(),
pkcs12_data,
ASCIIToUTF16("12345"),
false, // is_extractable
@@ -244,7 +244,7 @@ TEST_F(CertDatabaseNSSTest, ImportFromPKCS12AsUnextractableAndExportAgain) {
TEST_F(CertDatabaseNSSTest, ImportFromPKCS12OnlyMarkIncludedKey) {
std::string pkcs12_data = ReadTestFile("client.p12");
EXPECT_EQ(OK,
- cert_db_->ImportFromPKCS12(GetPublicModule(),
+ cert_db_->ImportFromPKCS12(GetPublicSlot(),
pkcs12_data,
ASCIIToUTF16("12345"),
true, // is_extractable
@@ -256,7 +256,7 @@ TEST_F(CertDatabaseNSSTest, ImportFromPKCS12OnlyMarkIncludedKey) {
// Now import a PKCS#12 file with just a certificate but no private key.
pkcs12_data = ReadTestFile("client-nokey.p12");
EXPECT_EQ(OK,
- cert_db_->ImportFromPKCS12(GetPublicModule(),
+ cert_db_->ImportFromPKCS12(GetPublicSlot(),
pkcs12_data,
ASCIIToUTF16("12345"),
false, // is_extractable
@@ -276,7 +276,7 @@ TEST_F(CertDatabaseNSSTest, ImportFromPKCS12InvalidFile) {
std::string pkcs12_data = "Foobarbaz";
EXPECT_EQ(ERR_PKCS12_IMPORT_INVALID_FILE,
- cert_db_->ImportFromPKCS12(GetPublicModule(),
+ cert_db_->ImportFromPKCS12(GetPublicSlot(),
pkcs12_data,
base::string16(),
true, // is_extractable
@@ -289,20 +289,24 @@ TEST_F(CertDatabaseNSSTest, ImportFromPKCS12InvalidFile) {
TEST_F(CertDatabaseNSSTest, ImportFromPKCS12EmptyPassword) {
std::string pkcs12_data = ReadTestFile("client-empty-password.p12");
- EXPECT_EQ(OK, cert_db_->ImportFromPKCS12(GetPublicModule(), pkcs12_data,
- base::string16(),
- true, // is_extractable
- NULL));
+ EXPECT_EQ(OK,
+ cert_db_->ImportFromPKCS12(GetPublicSlot(),
+ pkcs12_data,
+ base::string16(),
+ true, // is_extractable
+ NULL));
EXPECT_EQ(1U, ListCerts().size());
}
TEST_F(CertDatabaseNSSTest, ImportFromPKCS12NullPassword) {
std::string pkcs12_data = ReadTestFile("client-null-password.p12");
- EXPECT_EQ(OK, cert_db_->ImportFromPKCS12(GetPublicModule(), pkcs12_data,
- base::string16(),
- true, // is_extractable
- NULL));
+ EXPECT_EQ(OK,
+ cert_db_->ImportFromPKCS12(GetPublicSlot(),
+ pkcs12_data,
+ base::string16(),
+ true, // is_extractable
+ NULL));
EXPECT_EQ(1U, ListCerts().size());
}
« no previous file with comments | « net/cert/nss_cert_database.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698