Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chromeos/network/onc/onc_certificate_importer_impl.h" | 5 #include "chromeos/network/onc/onc_certificate_importer_impl.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 #include <certdb.h> | 8 #include <certdb.h> |
| 9 #include <keyhi.h> | 9 #include <keyhi.h> |
| 10 #include <pk11pub.h> | 10 #include <pk11pub.h> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/test/test_simple_task_runner.h" | |
| 17 #include "base/thread_task_runner_handle.h" | |
| 16 #include "base/values.h" | 18 #include "base/values.h" |
| 17 #include "chromeos/network/onc/onc_test_utils.h" | 19 #include "chromeos/network/onc/onc_test_utils.h" |
| 18 #include "components/onc/onc_constants.h" | 20 #include "components/onc/onc_constants.h" |
| 19 #include "crypto/nss_util_internal.h" | 21 #include "crypto/scoped_test_nss_db.h" |
| 20 #include "crypto/scoped_test_nss_chromeos_user.h" | |
| 21 #include "net/base/crypto_module.h" | 22 #include "net/base/crypto_module.h" |
| 22 #include "net/cert/cert_type.h" | 23 #include "net/cert/cert_type.h" |
| 23 #include "net/cert/nss_cert_database_chromeos.h" | 24 #include "net/cert/nss_cert_database_chromeos.h" |
| 24 #include "net/cert/x509_certificate.h" | 25 #include "net/cert/x509_certificate.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 27 |
| 27 namespace chromeos { | 28 namespace chromeos { |
| 28 namespace onc { | 29 namespace onc { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 56 net::CertType GetCertType(net::X509Certificate::OSCertHandle cert) { | 57 net::CertType GetCertType(net::X509Certificate::OSCertHandle cert) { |
| 57 NOTIMPLEMENTED(); | 58 NOTIMPLEMENTED(); |
| 58 return net::OTHER_CERT; | 59 return net::OTHER_CERT; |
| 59 } | 60 } |
| 60 #endif // USE_NSS | 61 #endif // USE_NSS |
| 61 | 62 |
| 62 } // namespace | 63 } // namespace |
| 63 | 64 |
| 64 class ONCCertificateImporterImplTest : public testing::Test { | 65 class ONCCertificateImporterImplTest : public testing::Test { |
| 65 public: | 66 public: |
| 66 ONCCertificateImporterImplTest() : user_("username_hash"), | 67 ONCCertificateImporterImplTest() {} |
| 67 private_user_("private_user_hash") {} | |
| 68 | 68 |
| 69 virtual void SetUp() { | 69 virtual void SetUp() { |
|
Joao da Silva
2014/09/15 12:38:24
OVERRIDE
pneubeck (no reviews)
2014/09/17 12:44:22
Done.
| |
| 70 ASSERT_TRUE(user_.constructed_successfully()); | 70 ASSERT_TRUE(public_nssdb_.is_open()); |
| 71 ASSERT_TRUE(private_user_.constructed_successfully()); | 71 ASSERT_TRUE(private_nssdb_.is_open()); |
| 72 | 72 |
| 73 // By default test user will have the same public and private slot. | 73 task_runner_ = new base::TestSimpleTaskRunner(); |
| 74 // Unfortunatelly, ONC importer should care about which slot certificates | 74 thread_task_runner_handle_.reset( |
| 75 // get imported to. To work around this, we create another NSS user whose | 75 new base::ThreadTaskRunnerHandle(task_runner_)); |
| 76 // public slot will act as the private slot. | 76 |
| 77 // TODO(tbarzic): See if there's a better way to achieve this. | |
| 78 test_nssdb_.reset(new net::NSSCertDatabaseChromeOS( | 77 test_nssdb_.reset(new net::NSSCertDatabaseChromeOS( |
| 79 crypto::GetPublicSlotForChromeOSUser(user_.username_hash()), | 78 crypto::ScopedPK11Slot(public_nssdb_.slot()), |
| 80 crypto::GetPublicSlotForChromeOSUser(private_user_.username_hash()))); | 79 crypto::ScopedPK11Slot(private_nssdb_.slot()))); |
| 81 | 80 |
| 82 // Test db should be empty at start of test. | 81 // Test db should be empty at start of test. |
| 83 EXPECT_TRUE(ListCertsInPublicSlot().empty()); | 82 EXPECT_TRUE(ListCertsInPublicSlot().empty()); |
| 84 EXPECT_TRUE(ListCertsInPrivateSlot().empty()); | 83 EXPECT_TRUE(ListCertsInPrivateSlot().empty()); |
| 85 } | 84 } |
| 86 | 85 |
| 87 virtual ~ONCCertificateImporterImplTest() {} | 86 virtual ~ONCCertificateImporterImplTest() { |
| 87 thread_task_runner_handle_.reset(); | |
| 88 task_runner_ = NULL; | |
|
Joao da Silva
2014/09/15 12:38:24
Do this in TearDown(). If something fails there th
pneubeck (no reviews)
2014/09/17 12:44:22
Done.
| |
| 89 } | |
| 88 | 90 |
| 89 protected: | 91 protected: |
| 92 void OnImportCompleted(bool expected_success, | |
| 93 bool success, | |
| 94 const net::CertificateList& onc_trusted_certificates) { | |
| 95 EXPECT_EQ(expected_success, success); | |
| 96 web_trust_certificates_ = onc_trusted_certificates; | |
| 97 } | |
| 98 | |
| 90 void AddCertificatesFromFile(std::string filename, bool expected_success) { | 99 void AddCertificatesFromFile(std::string filename, bool expected_success) { |
| 91 scoped_ptr<base::DictionaryValue> onc = | 100 scoped_ptr<base::DictionaryValue> onc = |
| 92 test_utils::ReadTestDictionary(filename); | 101 test_utils::ReadTestDictionary(filename); |
| 93 scoped_ptr<base::Value> certificates_value; | 102 scoped_ptr<base::Value> certificates_value; |
| 94 base::ListValue* certificates = NULL; | 103 base::ListValue* certificates = NULL; |
| 95 onc->RemoveWithoutPathExpansion(::onc::toplevel_config::kCertificates, | 104 onc->RemoveWithoutPathExpansion(::onc::toplevel_config::kCertificates, |
| 96 &certificates_value); | 105 &certificates_value); |
| 97 certificates_value.release()->GetAsList(&certificates); | 106 certificates_value.release()->GetAsList(&certificates); |
| 98 onc_certificates_.reset(certificates); | 107 onc_certificates_.reset(certificates); |
| 99 | 108 |
| 100 web_trust_certificates_.clear(); | 109 web_trust_certificates_.clear(); |
| 101 imported_server_and_ca_certs_.clear(); | 110 CertificateImporterImpl importer(task_runner_, test_nssdb_.get()); |
| 102 CertificateImporterImpl importer(test_nssdb_.get()); | 111 importer.ImportCertificates( |
| 103 EXPECT_EQ( | 112 *certificates, |
| 104 expected_success, | 113 ::onc::ONC_SOURCE_USER_IMPORT, // allow web trust |
| 105 importer.ParseAndStoreCertificates(true, // allow web trust | 114 base::Bind(&ONCCertificateImporterImplTest::OnImportCompleted, |
| 106 *certificates, | 115 base::Unretained(this), |
| 107 &web_trust_certificates_, | 116 expected_success)); |
| 108 &imported_server_and_ca_certs_)); | 117 |
| 118 task_runner_->RunUntilIdle(); | |
| 109 | 119 |
| 110 public_list_ = ListCertsInPublicSlot(); | 120 public_list_ = ListCertsInPublicSlot(); |
| 111 private_list_ = ListCertsInPrivateSlot(); | 121 private_list_ = ListCertsInPrivateSlot(); |
| 112 } | 122 } |
| 113 | 123 |
| 114 void AddCertificateFromFile(std::string filename, | 124 void AddCertificateFromFile(std::string filename, |
| 115 net::CertType expected_type, | 125 net::CertType expected_type, |
| 116 std::string* guid) { | 126 std::string* guid) { |
| 117 std::string guid_temporary; | 127 std::string guid_temporary; |
| 118 if (!guid) | 128 if (!guid) |
| 119 guid = &guid_temporary; | 129 guid = &guid_temporary; |
| 120 | 130 |
| 121 AddCertificatesFromFile(filename, true); | 131 AddCertificatesFromFile(filename, true); |
| 122 ASSERT_EQ(1ul, public_list_.size() + private_list_.size()); | 132 |
| 123 if (!public_list_.empty()) | 133 if (expected_type == net::SERVER_CERT || expected_type == net::CA_CERT) { |
| 134 ASSERT_EQ(1u, public_list_.size()); | |
| 124 EXPECT_EQ(expected_type, GetCertType(public_list_[0]->os_cert_handle())); | 135 EXPECT_EQ(expected_type, GetCertType(public_list_[0]->os_cert_handle())); |
| 125 if (!private_list_.empty()) | 136 EXPECT_TRUE(private_list_.empty()); |
| 137 } else { // net::USER_CERT | |
| 138 EXPECT_TRUE(public_list_.empty()); | |
| 139 ASSERT_EQ(1u, private_list_.size()); | |
| 126 EXPECT_EQ(expected_type, GetCertType(private_list_[0]->os_cert_handle())); | 140 EXPECT_EQ(expected_type, GetCertType(private_list_[0]->os_cert_handle())); |
| 141 } | |
| 127 | 142 |
| 128 base::DictionaryValue* certificate = NULL; | 143 base::DictionaryValue* certificate = NULL; |
| 129 onc_certificates_->GetDictionary(0, &certificate); | 144 onc_certificates_->GetDictionary(0, &certificate); |
| 130 certificate->GetStringWithoutPathExpansion(::onc::certificate::kGUID, guid); | 145 certificate->GetStringWithoutPathExpansion(::onc::certificate::kGUID, guid); |
| 131 | |
| 132 if (expected_type == net::SERVER_CERT || expected_type == net::CA_CERT) { | |
| 133 EXPECT_EQ(1u, imported_server_and_ca_certs_.size()); | |
| 134 EXPECT_TRUE( | |
| 135 imported_server_and_ca_certs_[*guid]->Equals(public_list_[0].get())); | |
| 136 } else { // net::USER_CERT | |
| 137 EXPECT_TRUE(imported_server_and_ca_certs_.empty()); | |
| 138 } | |
| 139 } | 146 } |
| 140 | 147 |
| 148 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | |
| 149 scoped_ptr<base::ThreadTaskRunnerHandle> thread_task_runner_handle_; | |
| 141 scoped_ptr<net::NSSCertDatabaseChromeOS> test_nssdb_; | 150 scoped_ptr<net::NSSCertDatabaseChromeOS> test_nssdb_; |
| 142 scoped_ptr<base::ListValue> onc_certificates_; | 151 scoped_ptr<base::ListValue> onc_certificates_; |
| 143 // List of certs in the nssdb's public slot. | 152 // List of certs in the nssdb's public slot. |
| 144 net::CertificateList public_list_; | 153 net::CertificateList public_list_; |
| 145 // List of certs in the nssdb's "private" slot. | 154 // List of certs in the nssdb's "private" slot. |
| 146 net::CertificateList private_list_; | 155 net::CertificateList private_list_; |
| 147 net::CertificateList web_trust_certificates_; | 156 net::CertificateList web_trust_certificates_; |
| 148 CertificateImporterImpl::CertsByGUID imported_server_and_ca_certs_; | 157 |
| 158 crypto::ScopedTestNSSDB public_nssdb_; | |
| 159 crypto::ScopedTestNSSDB private_nssdb_; | |
| 149 | 160 |
| 150 private: | 161 private: |
| 151 net::CertificateList ListCertsInPublicSlot() { | 162 net::CertificateList ListCertsInPublicSlot() { |
| 152 return ListCertsInSlot(test_nssdb_->GetPublicSlot().get()); | 163 return ListCertsInSlot(public_nssdb_.slot()); |
| 153 } | 164 } |
| 154 | 165 |
| 155 net::CertificateList ListCertsInPrivateSlot() { | 166 net::CertificateList ListCertsInPrivateSlot() { |
| 156 return ListCertsInSlot(test_nssdb_->GetPrivateSlot().get()); | 167 return ListCertsInSlot(private_nssdb_.slot()); |
| 157 } | 168 } |
| 158 | 169 |
| 159 net::CertificateList ListCertsInSlot(PK11SlotInfo* slot) { | 170 net::CertificateList ListCertsInSlot(PK11SlotInfo* slot) { |
| 160 net::CertificateList result; | 171 net::CertificateList result; |
| 161 CERTCertList* cert_list = PK11_ListCertsInSlot(slot); | 172 CERTCertList* cert_list = PK11_ListCertsInSlot(slot); |
| 162 for (CERTCertListNode* node = CERT_LIST_HEAD(cert_list); | 173 for (CERTCertListNode* node = CERT_LIST_HEAD(cert_list); |
| 163 !CERT_LIST_END(node, cert_list); | 174 !CERT_LIST_END(node, cert_list); |
| 164 node = CERT_LIST_NEXT(node)) { | 175 node = CERT_LIST_NEXT(node)) { |
| 165 result.push_back(net::X509Certificate::CreateFromHandle( | 176 result.push_back(net::X509Certificate::CreateFromHandle( |
| 166 node->cert, net::X509Certificate::OSCertHandles())); | 177 node->cert, net::X509Certificate::OSCertHandles())); |
| 167 } | 178 } |
| 168 CERT_DestroyCertList(cert_list); | 179 CERT_DestroyCertList(cert_list); |
| 169 | 180 |
| 170 // Sort the result so that test comparisons can be deterministic. | 181 // Sort the result so that test comparisons can be deterministic. |
| 171 std::sort(result.begin(), result.end(), net::X509Certificate::LessThan()); | 182 std::sort(result.begin(), result.end(), net::X509Certificate::LessThan()); |
| 172 return result; | 183 return result; |
| 173 } | 184 } |
| 174 | |
| 175 crypto::ScopedTestNSSChromeOSUser user_; | |
| 176 crypto::ScopedTestNSSChromeOSUser private_user_; | |
| 177 }; | 185 }; |
| 178 | 186 |
| 179 TEST_F(ONCCertificateImporterImplTest, MultipleCertificates) { | 187 TEST_F(ONCCertificateImporterImplTest, MultipleCertificates) { |
| 180 AddCertificatesFromFile("managed_toplevel2.onc", true); | 188 AddCertificatesFromFile("managed_toplevel2.onc", true); |
| 181 EXPECT_EQ(onc_certificates_->GetSize(), public_list_.size()); | 189 EXPECT_EQ(onc_certificates_->GetSize(), public_list_.size()); |
| 182 EXPECT_TRUE(private_list_.empty()); | 190 EXPECT_TRUE(private_list_.empty()); |
| 183 EXPECT_EQ(2ul, imported_server_and_ca_certs_.size()); | 191 EXPECT_EQ(2ul, public_list_.size()); |
| 184 } | 192 } |
| 185 | 193 |
| 186 TEST_F(ONCCertificateImporterImplTest, MultipleCertificatesWithFailures) { | 194 TEST_F(ONCCertificateImporterImplTest, MultipleCertificatesWithFailures) { |
| 187 AddCertificatesFromFile("toplevel_partially_invalid.onc", false); | 195 AddCertificatesFromFile("toplevel_partially_invalid.onc", false); |
| 188 EXPECT_EQ(3ul, onc_certificates_->GetSize()); | 196 EXPECT_EQ(3ul, onc_certificates_->GetSize()); |
| 189 EXPECT_EQ(1ul, private_list_.size()); | 197 EXPECT_EQ(1ul, private_list_.size()); |
| 190 EXPECT_TRUE(public_list_.empty()); | 198 EXPECT_TRUE(public_list_.empty()); |
| 191 EXPECT_TRUE(imported_server_and_ca_certs_.empty()); | |
| 192 } | 199 } |
| 193 | 200 |
| 194 TEST_F(ONCCertificateImporterImplTest, AddClientCertificate) { | 201 TEST_F(ONCCertificateImporterImplTest, AddClientCertificate) { |
| 195 std::string guid; | 202 std::string guid; |
| 196 AddCertificateFromFile("certificate-client.onc", net::USER_CERT, &guid); | 203 AddCertificateFromFile("certificate-client.onc", net::USER_CERT, &guid); |
| 197 EXPECT_TRUE(web_trust_certificates_.empty()); | 204 EXPECT_TRUE(web_trust_certificates_.empty()); |
| 198 EXPECT_EQ(1ul, private_list_.size()); | 205 EXPECT_EQ(1ul, private_list_.size()); |
| 199 EXPECT_TRUE(public_list_.empty()); | 206 EXPECT_TRUE(public_list_.empty()); |
| 200 | 207 |
| 201 SECKEYPrivateKeyList* privkey_list = | 208 SECKEYPrivateKeyList* privkey_list = |
| 202 PK11_ListPrivKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL, NULL); | 209 PK11_ListPrivKeysInSlot(private_nssdb_.slot(), NULL, NULL); |
| 203 EXPECT_TRUE(privkey_list); | 210 EXPECT_TRUE(privkey_list); |
| 204 if (privkey_list) { | 211 if (privkey_list) { |
| 205 SECKEYPrivateKeyListNode* node = PRIVKEY_LIST_HEAD(privkey_list); | 212 SECKEYPrivateKeyListNode* node = PRIVKEY_LIST_HEAD(privkey_list); |
| 206 int count = 0; | 213 int count = 0; |
| 207 while (!PRIVKEY_LIST_END(node, privkey_list)) { | 214 while (!PRIVKEY_LIST_END(node, privkey_list)) { |
| 208 char* name = PK11_GetPrivateKeyNickname(node->key); | 215 char* name = PK11_GetPrivateKeyNickname(node->key); |
| 209 EXPECT_STREQ(guid.c_str(), name); | 216 EXPECT_STREQ(guid.c_str(), name); |
| 210 PORT_Free(name); | 217 PORT_Free(name); |
| 211 count++; | 218 count++; |
| 212 node = PRIVKEY_LIST_NEXT(node); | 219 node = PRIVKEY_LIST_NEXT(node); |
| 213 } | 220 } |
| 214 EXPECT_EQ(1, count); | 221 EXPECT_EQ(1, count); |
| 215 SECKEY_DestroyPrivateKeyList(privkey_list); | 222 SECKEY_DestroyPrivateKeyList(privkey_list); |
| 216 } | 223 } |
| 217 | 224 |
| 218 SECKEYPublicKeyList* pubkey_list = | 225 SECKEYPublicKeyList* pubkey_list = |
| 219 PK11_ListPublicKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL); | 226 PK11_ListPublicKeysInSlot(private_nssdb_.slot(), NULL); |
| 220 EXPECT_TRUE(pubkey_list); | 227 EXPECT_TRUE(pubkey_list); |
| 221 if (pubkey_list) { | 228 if (pubkey_list) { |
| 222 SECKEYPublicKeyListNode* node = PUBKEY_LIST_HEAD(pubkey_list); | 229 SECKEYPublicKeyListNode* node = PUBKEY_LIST_HEAD(pubkey_list); |
| 223 int count = 0; | 230 int count = 0; |
| 224 while (!PUBKEY_LIST_END(node, pubkey_list)) { | 231 while (!PUBKEY_LIST_END(node, pubkey_list)) { |
| 225 count++; | 232 count++; |
| 226 node = PUBKEY_LIST_NEXT(node); | 233 node = PUBKEY_LIST_NEXT(node); |
| 227 } | 234 } |
| 228 EXPECT_EQ(1, count); | 235 EXPECT_EQ(1, count); |
| 229 SECKEY_DestroyPublicKeyList(pubkey_list); | 236 SECKEY_DestroyPublicKeyList(pubkey_list); |
| 230 } | 237 } |
| 231 } | 238 } |
| 232 | 239 |
| 233 TEST_F(ONCCertificateImporterImplTest, AddServerCertificateWithWebTrust) { | 240 TEST_F(ONCCertificateImporterImplTest, AddServerCertificateWithWebTrust) { |
| 234 AddCertificateFromFile("certificate-server.onc", net::SERVER_CERT, NULL); | 241 AddCertificateFromFile("certificate-server.onc", net::SERVER_CERT, NULL); |
| 235 | 242 |
| 236 SECKEYPrivateKeyList* privkey_list = | 243 SECKEYPrivateKeyList* privkey_list = |
| 237 PK11_ListPrivKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL, NULL); | 244 PK11_ListPrivKeysInSlot(private_nssdb_.slot(), NULL, NULL); |
| 238 EXPECT_FALSE(privkey_list); | 245 EXPECT_FALSE(privkey_list); |
| 239 | 246 |
| 240 SECKEYPublicKeyList* pubkey_list = | 247 SECKEYPublicKeyList* pubkey_list = |
| 241 PK11_ListPublicKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL); | 248 PK11_ListPublicKeysInSlot(private_nssdb_.slot(), NULL); |
| 242 EXPECT_FALSE(pubkey_list); | 249 EXPECT_FALSE(pubkey_list); |
| 243 | 250 |
| 244 ASSERT_EQ(1u, web_trust_certificates_.size()); | 251 ASSERT_EQ(1u, web_trust_certificates_.size()); |
| 245 ASSERT_EQ(1u, public_list_.size()); | 252 ASSERT_EQ(1u, public_list_.size()); |
| 246 EXPECT_TRUE(private_list_.empty()); | 253 EXPECT_TRUE(private_list_.empty()); |
| 247 EXPECT_TRUE(CERT_CompareCerts(public_list_[0]->os_cert_handle(), | 254 EXPECT_TRUE(CERT_CompareCerts(public_list_[0]->os_cert_handle(), |
| 248 web_trust_certificates_[0]->os_cert_handle())); | 255 web_trust_certificates_[0]->os_cert_handle())); |
| 249 } | 256 } |
| 250 | 257 |
| 251 TEST_F(ONCCertificateImporterImplTest, AddWebAuthorityCertificateWithWebTrust) { | 258 TEST_F(ONCCertificateImporterImplTest, AddWebAuthorityCertificateWithWebTrust) { |
| 252 AddCertificateFromFile("certificate-web-authority.onc", net::CA_CERT, NULL); | 259 AddCertificateFromFile("certificate-web-authority.onc", net::CA_CERT, NULL); |
| 253 | 260 |
| 254 SECKEYPrivateKeyList* privkey_list = | 261 SECKEYPrivateKeyList* privkey_list = |
| 255 PK11_ListPrivKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL, NULL); | 262 PK11_ListPrivKeysInSlot(private_nssdb_.slot(), NULL, NULL); |
| 256 EXPECT_FALSE(privkey_list); | 263 EXPECT_FALSE(privkey_list); |
| 257 | 264 |
| 258 SECKEYPublicKeyList* pubkey_list = | 265 SECKEYPublicKeyList* pubkey_list = |
| 259 PK11_ListPublicKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL); | 266 PK11_ListPublicKeysInSlot(private_nssdb_.slot(), NULL); |
| 260 EXPECT_FALSE(pubkey_list); | 267 EXPECT_FALSE(pubkey_list); |
| 261 | 268 |
| 262 ASSERT_EQ(1u, web_trust_certificates_.size()); | 269 ASSERT_EQ(1u, web_trust_certificates_.size()); |
| 263 ASSERT_EQ(1u, public_list_.size()); | 270 ASSERT_EQ(1u, public_list_.size()); |
| 264 EXPECT_TRUE(private_list_.empty()); | 271 EXPECT_TRUE(private_list_.empty()); |
| 265 EXPECT_TRUE(CERT_CompareCerts(public_list_[0]->os_cert_handle(), | 272 EXPECT_TRUE(CERT_CompareCerts(public_list_[0]->os_cert_handle(), |
| 266 web_trust_certificates_[0]->os_cert_handle())); | 273 web_trust_certificates_[0]->os_cert_handle())); |
| 267 } | 274 } |
| 268 | 275 |
| 269 TEST_F(ONCCertificateImporterImplTest, AddAuthorityCertificateWithoutWebTrust) { | 276 TEST_F(ONCCertificateImporterImplTest, AddAuthorityCertificateWithoutWebTrust) { |
| 270 AddCertificateFromFile("certificate-authority.onc", net::CA_CERT, NULL); | 277 AddCertificateFromFile("certificate-authority.onc", net::CA_CERT, NULL); |
| 271 EXPECT_TRUE(web_trust_certificates_.empty()); | 278 EXPECT_TRUE(web_trust_certificates_.empty()); |
| 272 | 279 |
| 273 SECKEYPrivateKeyList* privkey_list = | 280 SECKEYPrivateKeyList* privkey_list = |
| 274 PK11_ListPrivKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL, NULL); | 281 PK11_ListPrivKeysInSlot(private_nssdb_.slot(), NULL, NULL); |
| 275 EXPECT_FALSE(privkey_list); | 282 EXPECT_FALSE(privkey_list); |
| 276 | 283 |
| 277 SECKEYPublicKeyList* pubkey_list = | 284 SECKEYPublicKeyList* pubkey_list = |
| 278 PK11_ListPublicKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL); | 285 PK11_ListPublicKeysInSlot(private_nssdb_.slot(), NULL); |
| 279 EXPECT_FALSE(pubkey_list); | 286 EXPECT_FALSE(pubkey_list); |
| 280 } | 287 } |
| 281 | 288 |
| 282 struct CertParam { | 289 struct CertParam { |
| 283 CertParam(net::CertType certificate_type, | 290 CertParam(net::CertType certificate_type, |
| 284 const char* original_filename, | 291 const char* original_filename, |
| 285 const char* update_filename) | 292 const char* update_filename) |
| 286 : cert_type(certificate_type), | 293 : cert_type(certificate_type), |
| 287 original_file(original_filename), | 294 original_file(original_filename), |
| 288 update_file(update_filename) {} | 295 update_file(update_filename) {} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 "certificate-client-update.onc"), | 338 "certificate-client-update.onc"), |
| 332 CertParam(net::SERVER_CERT, | 339 CertParam(net::SERVER_CERT, |
| 333 "certificate-server.onc", | 340 "certificate-server.onc", |
| 334 "certificate-server-update.onc"), | 341 "certificate-server-update.onc"), |
| 335 CertParam(net::CA_CERT, | 342 CertParam(net::CA_CERT, |
| 336 "certificate-web-authority.onc", | 343 "certificate-web-authority.onc", |
| 337 "certificate-web-authority-update.onc"))); | 344 "certificate-web-authority-update.onc"))); |
| 338 | 345 |
| 339 } // namespace onc | 346 } // namespace onc |
| 340 } // namespace chromeos | 347 } // namespace chromeos |
| OLD | NEW |