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/logging.h" | 14 #include "base/logging.h" |
14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "chromeos/network/onc/onc_test_utils.h" | 17 #include "chromeos/network/onc/onc_test_utils.h" |
17 #include "components/onc/onc_constants.h" | 18 #include "components/onc/onc_constants.h" |
18 #include "crypto/nss_util.h" | 19 #include "crypto/nss_util.h" |
20 #include "crypto/nss_util_internal.h" | |
19 #include "net/base/crypto_module.h" | 21 #include "net/base/crypto_module.h" |
20 #include "net/cert/cert_type.h" | 22 #include "net/cert/cert_type.h" |
21 #include "net/cert/nss_cert_database.h" | 23 #include "net/cert/nss_cert_database_chromeos.h" |
22 #include "net/cert/x509_certificate.h" | 24 #include "net/cert/x509_certificate.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
24 | 26 |
25 namespace chromeos { | 27 namespace chromeos { |
26 namespace onc { | 28 namespace onc { |
27 | 29 |
30 namespace { | |
31 | |
28 #if defined(USE_NSS) | 32 #if defined(USE_NSS) |
29 // In NSS 3.13, CERTDB_VALID_PEER was renamed CERTDB_TERMINAL_RECORD. So we use | 33 // In NSS 3.13, CERTDB_VALID_PEER was renamed CERTDB_TERMINAL_RECORD. So we use |
30 // the new name of the macro. | 34 // the new name of the macro. |
31 #if !defined(CERTDB_TERMINAL_RECORD) | 35 #if !defined(CERTDB_TERMINAL_RECORD) |
32 #define CERTDB_TERMINAL_RECORD CERTDB_VALID_PEER | 36 #define CERTDB_TERMINAL_RECORD CERTDB_VALID_PEER |
33 #endif | 37 #endif |
34 | 38 |
35 net::CertType GetCertType(net::X509Certificate::OSCertHandle cert) { | 39 net::CertType GetCertType(net::X509Certificate::OSCertHandle cert) { |
36 CERTCertTrust trust = {0}; | 40 CERTCertTrust trust = {0}; |
37 CERT_GetCertTrust(cert, &trust); | 41 CERT_GetCertTrust(cert, &trust); |
(...skipping 10 matching lines...) Expand all Loading... | |
48 return net::SERVER_CERT; | 52 return net::SERVER_CERT; |
49 return net::OTHER_CERT; | 53 return net::OTHER_CERT; |
50 } | 54 } |
51 #else | 55 #else |
52 net::CertType GetCertType(net::X509Certificate::OSCertHandle cert) { | 56 net::CertType GetCertType(net::X509Certificate::OSCertHandle cert) { |
53 NOTIMPLEMENTED(); | 57 NOTIMPLEMENTED(); |
54 return net::OTHER_CERT; | 58 return net::OTHER_CERT; |
55 } | 59 } |
56 #endif // USE_NSS | 60 #endif // USE_NSS |
57 | 61 |
62 } // namespace | |
63 | |
58 class ONCCertificateImporterImplTest : public testing::Test { | 64 class ONCCertificateImporterImplTest : public testing::Test { |
59 public: | 65 public: |
66 ONCCertificateImporterImplTest() : user_("username_hash"), | |
67 private_user_("private_user_hash") {} | |
68 | |
60 virtual void SetUp() { | 69 virtual void SetUp() { |
61 ASSERT_TRUE(test_nssdb_.is_open()); | 70 ASSERT_TRUE(user_.constructed_successfully()); |
71 ASSERT_TRUE(private_user_.constructed_successfully()); | |
62 | 72 |
63 slot_ = net::NSSCertDatabase::GetInstance()->GetPublicModule(); | 73 // By default test user will have the same public and private slot. |
64 | 74 // Unfortunatelly, ONC importer should care about which slot certificates |
65 // Don't run the test if the setup failed. | 75 // get imported to. To work around this, we create another NSS user whose |
66 ASSERT_TRUE(slot_->os_module_handle()); | 76 // public slot will act as the private slot. |
77 test_nssdb_.reset(new net::NSSCertDatabaseChromeOS( | |
78 crypto::GetPublicSlotForChromeOSUser(user_.username_hash()), | |
79 crypto::GetPublicSlotForChromeOSUser(private_user_.username_hash()))); | |
pneubeck (no reviews)
2014/02/05 11:03:27
is there no direct way to create slots for testing
tbarzic
2014/02/06 01:19:42
none that I'm aware of, I'll look into exposing on
| |
67 | 80 |
68 // Test db should be empty at start of test. | 81 // Test db should be empty at start of test. |
69 EXPECT_EQ(0ul, ListCertsInSlot().size()); | 82 EXPECT_TRUE(ListCertsInPublicSlot().empty()); |
83 EXPECT_TRUE(ListCertsInPrivateSlot().empty()); | |
70 } | 84 } |
71 | 85 |
72 virtual void TearDown() { | 86 virtual void TearDown() { |
73 EXPECT_TRUE(CleanupSlotContents()); | 87 EXPECT_TRUE(CleanupSlotContents()); |
74 EXPECT_EQ(0ul, ListCertsInSlot().size()); | 88 EXPECT_TRUE(ListCertsInPublicSlot().empty()); |
89 EXPECT_TRUE(ListCertsInPrivateSlot().empty()); | |
75 } | 90 } |
76 | 91 |
77 virtual ~ONCCertificateImporterImplTest() {} | 92 virtual ~ONCCertificateImporterImplTest() {} |
78 | 93 |
79 protected: | 94 protected: |
80 void AddCertificatesFromFile(std::string filename, bool expected_success) { | 95 void AddCertificatesFromFile(std::string filename, bool expected_success) { |
81 scoped_ptr<base::DictionaryValue> onc = | 96 scoped_ptr<base::DictionaryValue> onc = |
82 test_utils::ReadTestDictionary(filename); | 97 test_utils::ReadTestDictionary(filename); |
83 scoped_ptr<base::Value> certificates_value; | 98 scoped_ptr<base::Value> certificates_value; |
84 base::ListValue* certificates = NULL; | 99 base::ListValue* certificates = NULL; |
85 onc->RemoveWithoutPathExpansion(::onc::toplevel_config::kCertificates, | 100 onc->RemoveWithoutPathExpansion(::onc::toplevel_config::kCertificates, |
86 &certificates_value); | 101 &certificates_value); |
87 certificates_value.release()->GetAsList(&certificates); | 102 certificates_value.release()->GetAsList(&certificates); |
88 onc_certificates_.reset(certificates); | 103 onc_certificates_.reset(certificates); |
89 | 104 |
90 web_trust_certificates_.clear(); | 105 web_trust_certificates_.clear(); |
91 imported_server_and_ca_certs_.clear(); | 106 imported_server_and_ca_certs_.clear(); |
92 CertificateImporterImpl importer; | 107 CertificateImporterImpl importer; |
93 EXPECT_EQ( | 108 EXPECT_EQ( |
94 expected_success, | 109 expected_success, |
95 importer.ParseAndStoreCertificates(true, // allow web trust | 110 importer.ParseAndStoreCertificates(true, // allow web trust |
96 *certificates, | 111 *certificates, |
97 &web_trust_certificates_, | 112 &web_trust_certificates_, |
113 test_nssdb_.get(), | |
98 &imported_server_and_ca_certs_)); | 114 &imported_server_and_ca_certs_)); |
99 | 115 |
100 result_list_.clear(); | 116 public_list_ = ListCertsInPublicSlot(); |
101 result_list_ = ListCertsInSlot(); | 117 private_list_ = ListCertsInPrivateSlot(); |
102 } | 118 } |
103 | 119 |
104 void AddCertificateFromFile(std::string filename, | 120 void AddCertificateFromFile(std::string filename, |
105 net::CertType expected_type, | 121 net::CertType expected_type, |
106 std::string* guid) { | 122 std::string* guid) { |
107 std::string guid_temporary; | 123 std::string guid_temporary; |
108 if (!guid) | 124 if (!guid) |
109 guid = &guid_temporary; | 125 guid = &guid_temporary; |
110 | 126 |
111 AddCertificatesFromFile(filename, true); | 127 AddCertificatesFromFile(filename, true); |
112 ASSERT_EQ(1ul, result_list_.size()); | 128 ASSERT_EQ(1ul, public_list_.size() + private_list_.size()); |
113 EXPECT_EQ(expected_type, GetCertType(result_list_[0]->os_cert_handle())); | 129 if (!public_list_.empty()) |
130 EXPECT_EQ(expected_type, GetCertType(public_list_[0]->os_cert_handle())); | |
131 if (!private_list_.empty()) | |
132 EXPECT_EQ(expected_type, GetCertType(private_list_[0]->os_cert_handle())); | |
114 | 133 |
115 base::DictionaryValue* certificate = NULL; | 134 base::DictionaryValue* certificate = NULL; |
116 onc_certificates_->GetDictionary(0, &certificate); | 135 onc_certificates_->GetDictionary(0, &certificate); |
117 certificate->GetStringWithoutPathExpansion(::onc::certificate::kGUID, guid); | 136 certificate->GetStringWithoutPathExpansion(::onc::certificate::kGUID, guid); |
118 | 137 |
119 if (expected_type == net::SERVER_CERT || expected_type == net::CA_CERT) { | 138 if (expected_type == net::SERVER_CERT || expected_type == net::CA_CERT) { |
120 EXPECT_EQ(1u, imported_server_and_ca_certs_.size()); | 139 EXPECT_EQ(1u, imported_server_and_ca_certs_.size()); |
121 EXPECT_TRUE(imported_server_and_ca_certs_[*guid]->Equals( | 140 EXPECT_TRUE(imported_server_and_ca_certs_[*guid]->Equals( |
122 result_list_[0])); | 141 public_list_[0])); |
123 } else { // net::USER_CERT | 142 } else { // net::USER_CERT |
124 EXPECT_TRUE(imported_server_and_ca_certs_.empty()); | 143 EXPECT_TRUE(imported_server_and_ca_certs_.empty()); |
125 CertificateImporterImpl::ListCertsWithNickname(*guid, &result_list_); | |
126 } | 144 } |
145 | |
146 public_list_ = ListCertsInPublicSlot(); | |
pneubeck (no reviews)
2014/02/05 11:03:27
redundant, already done in AddCertificatesFromFile
tbarzic
2014/02/06 01:19:42
Done.
| |
147 private_list_ = ListCertsInPrivateSlot(); | |
127 } | 148 } |
128 | 149 |
150 scoped_ptr<net::NSSCertDatabaseChromeOS> test_nssdb_; | |
129 scoped_ptr<base::ListValue> onc_certificates_; | 151 scoped_ptr<base::ListValue> onc_certificates_; |
130 scoped_refptr<net::CryptoModule> slot_; | 152 // List of certs in the nssdb's public slot. |
131 net::CertificateList result_list_; | 153 net::CertificateList public_list_; |
154 // List of certs in the nssdb's "private" slot. | |
155 net::CertificateList private_list_; | |
132 net::CertificateList web_trust_certificates_; | 156 net::CertificateList web_trust_certificates_; |
133 CertificateImporterImpl::CertsByGUID imported_server_and_ca_certs_; | 157 CertificateImporterImpl::CertsByGUID imported_server_and_ca_certs_; |
134 | 158 |
135 private: | 159 private: |
136 net::CertificateList ListCertsInSlot() { | 160 net::CertificateList ListCertsInPublicSlot() { |
161 return ListCertsInSlot(test_nssdb_->GetPublicSlot().get()); | |
162 } | |
163 | |
164 net::CertificateList ListCertsInPrivateSlot() { | |
165 return ListCertsInSlot(test_nssdb_->GetPrivateSlot().get()); | |
166 } | |
167 | |
168 net::CertificateList ListCertsInSlot(PK11SlotInfo* slot) { | |
137 net::CertificateList result; | 169 net::CertificateList result; |
138 CERTCertList* cert_list = PK11_ListCertsInSlot(slot_->os_module_handle()); | 170 CERTCertList* cert_list = PK11_ListCertsInSlot(slot); |
139 for (CERTCertListNode* node = CERT_LIST_HEAD(cert_list); | 171 for (CERTCertListNode* node = CERT_LIST_HEAD(cert_list); |
140 !CERT_LIST_END(node, cert_list); | 172 !CERT_LIST_END(node, cert_list); |
141 node = CERT_LIST_NEXT(node)) { | 173 node = CERT_LIST_NEXT(node)) { |
142 result.push_back(net::X509Certificate::CreateFromHandle( | 174 result.push_back(net::X509Certificate::CreateFromHandle( |
143 node->cert, net::X509Certificate::OSCertHandles())); | 175 node->cert, net::X509Certificate::OSCertHandles())); |
144 } | 176 } |
145 CERT_DestroyCertList(cert_list); | 177 CERT_DestroyCertList(cert_list); |
146 | 178 |
147 // Sort the result so that test comparisons can be deterministic. | 179 // Sort the result so that test comparisons can be deterministic. |
148 std::sort(result.begin(), result.end(), net::X509Certificate::LessThan()); | 180 std::sort(result.begin(), result.end(), net::X509Certificate::LessThan()); |
149 return result; | 181 return result; |
150 } | 182 } |
151 | 183 |
152 bool CleanupSlotContents() { | 184 bool CleanupSlotContents() { |
pneubeck (no reviews)
2014/02/05 11:03:27
Maybe you know better, whether this Cleanup is sti
tbarzic
2014/02/06 01:19:42
I don't think it is (as databases are created in r
| |
153 bool ok = true; | 185 bool ok = true; |
154 net::CertificateList certs = ListCertsInSlot(); | 186 net::CertificateList certs = ListCertsInPublicSlot(); |
187 net::CertificateList private_certs = ListCertsInPrivateSlot(); | |
188 certs.insert(certs.end(), private_certs.begin(), private_certs.end()); | |
189 | |
155 for (size_t i = 0; i < certs.size(); ++i) { | 190 for (size_t i = 0; i < certs.size(); ++i) { |
156 if (!net::NSSCertDatabase::GetInstance()->DeleteCertAndKey(certs[i] | 191 if (!test_nssdb_->DeleteCertAndKey(certs[i].get())) |
157 .get())) | |
158 ok = false; | 192 ok = false; |
159 } | 193 } |
160 return ok; | 194 return ok; |
161 } | 195 } |
162 | 196 |
163 crypto::ScopedTestNSSDB test_nssdb_; | 197 crypto::ScopedTestNSSChromeOSUser user_; |
198 crypto::ScopedTestNSSChromeOSUser private_user_; | |
164 }; | 199 }; |
165 | 200 |
166 TEST_F(ONCCertificateImporterImplTest, MultipleCertificates) { | 201 TEST_F(ONCCertificateImporterImplTest, MultipleCertificates) { |
167 AddCertificatesFromFile("managed_toplevel2.onc", true); | 202 AddCertificatesFromFile("managed_toplevel2.onc", true); |
168 EXPECT_EQ(onc_certificates_->GetSize(), result_list_.size()); | 203 EXPECT_EQ(onc_certificates_->GetSize(), public_list_.size()); |
204 EXPECT_TRUE(private_list_.empty()); | |
169 EXPECT_EQ(2ul, imported_server_and_ca_certs_.size()); | 205 EXPECT_EQ(2ul, imported_server_and_ca_certs_.size()); |
170 } | 206 } |
171 | 207 |
172 TEST_F(ONCCertificateImporterImplTest, MultipleCertificatesWithFailures) { | 208 TEST_F(ONCCertificateImporterImplTest, MultipleCertificatesWithFailures) { |
173 AddCertificatesFromFile("toplevel_partially_invalid.onc", false); | 209 AddCertificatesFromFile("toplevel_partially_invalid.onc", false); |
174 EXPECT_EQ(3ul, onc_certificates_->GetSize()); | 210 EXPECT_EQ(3ul, onc_certificates_->GetSize()); |
175 EXPECT_EQ(1ul, result_list_.size()); | 211 EXPECT_EQ(1ul, private_list_.size()); |
212 EXPECT_TRUE(public_list_.empty()); | |
176 EXPECT_TRUE(imported_server_and_ca_certs_.empty()); | 213 EXPECT_TRUE(imported_server_and_ca_certs_.empty()); |
177 } | 214 } |
178 | 215 |
179 TEST_F(ONCCertificateImporterImplTest, AddClientCertificate) { | 216 TEST_F(ONCCertificateImporterImplTest, AddClientCertificate) { |
180 std::string guid; | 217 std::string guid; |
181 AddCertificateFromFile("certificate-client.onc", net::USER_CERT, &guid); | 218 AddCertificateFromFile("certificate-client.onc", net::USER_CERT, &guid); |
182 EXPECT_TRUE(web_trust_certificates_.empty()); | 219 EXPECT_TRUE(web_trust_certificates_.empty()); |
220 EXPECT_EQ(1ul, private_list_.size()); | |
221 EXPECT_TRUE(public_list_.empty()); | |
183 | 222 |
184 SECKEYPrivateKeyList* privkey_list = | 223 SECKEYPrivateKeyList* privkey_list = |
185 PK11_ListPrivKeysInSlot(slot_->os_module_handle(), NULL, NULL); | 224 PK11_ListPrivKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL, NULL); |
186 EXPECT_TRUE(privkey_list); | 225 EXPECT_TRUE(privkey_list); |
187 if (privkey_list) { | 226 if (privkey_list) { |
188 SECKEYPrivateKeyListNode* node = PRIVKEY_LIST_HEAD(privkey_list); | 227 SECKEYPrivateKeyListNode* node = PRIVKEY_LIST_HEAD(privkey_list); |
189 int count = 0; | 228 int count = 0; |
190 while (!PRIVKEY_LIST_END(node, privkey_list)) { | 229 while (!PRIVKEY_LIST_END(node, privkey_list)) { |
191 char* name = PK11_GetPrivateKeyNickname(node->key); | 230 char* name = PK11_GetPrivateKeyNickname(node->key); |
192 EXPECT_STREQ(guid.c_str(), name); | 231 EXPECT_STREQ(guid.c_str(), name); |
193 PORT_Free(name); | 232 PORT_Free(name); |
194 count++; | 233 count++; |
195 node = PRIVKEY_LIST_NEXT(node); | 234 node = PRIVKEY_LIST_NEXT(node); |
196 } | 235 } |
197 EXPECT_EQ(1, count); | 236 EXPECT_EQ(1, count); |
198 SECKEY_DestroyPrivateKeyList(privkey_list); | 237 SECKEY_DestroyPrivateKeyList(privkey_list); |
199 } | 238 } |
200 | 239 |
201 SECKEYPublicKeyList* pubkey_list = | 240 SECKEYPublicKeyList* pubkey_list = |
202 PK11_ListPublicKeysInSlot(slot_->os_module_handle(), NULL); | 241 PK11_ListPublicKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL); |
203 EXPECT_TRUE(pubkey_list); | 242 EXPECT_TRUE(pubkey_list); |
204 if (pubkey_list) { | 243 if (pubkey_list) { |
205 SECKEYPublicKeyListNode* node = PUBKEY_LIST_HEAD(pubkey_list); | 244 SECKEYPublicKeyListNode* node = PUBKEY_LIST_HEAD(pubkey_list); |
206 int count = 0; | 245 int count = 0; |
207 while (!PUBKEY_LIST_END(node, pubkey_list)) { | 246 while (!PUBKEY_LIST_END(node, pubkey_list)) { |
208 count++; | 247 count++; |
209 node = PUBKEY_LIST_NEXT(node); | 248 node = PUBKEY_LIST_NEXT(node); |
210 } | 249 } |
211 EXPECT_EQ(1, count); | 250 EXPECT_EQ(1, count); |
212 SECKEY_DestroyPublicKeyList(pubkey_list); | 251 SECKEY_DestroyPublicKeyList(pubkey_list); |
213 } | 252 } |
214 } | 253 } |
215 | 254 |
216 TEST_F(ONCCertificateImporterImplTest, AddServerCertificateWithWebTrust) { | 255 TEST_F(ONCCertificateImporterImplTest, AddServerCertificateWithWebTrust) { |
217 AddCertificateFromFile("certificate-server.onc", net::SERVER_CERT, NULL); | 256 AddCertificateFromFile("certificate-server.onc", net::SERVER_CERT, NULL); |
218 | 257 |
219 SECKEYPrivateKeyList* privkey_list = | 258 SECKEYPrivateKeyList* privkey_list = |
220 PK11_ListPrivKeysInSlot(slot_->os_module_handle(), NULL, NULL); | 259 PK11_ListPrivKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL, NULL); |
221 EXPECT_FALSE(privkey_list); | 260 EXPECT_FALSE(privkey_list); |
222 | 261 |
223 SECKEYPublicKeyList* pubkey_list = | 262 SECKEYPublicKeyList* pubkey_list = |
224 PK11_ListPublicKeysInSlot(slot_->os_module_handle(), NULL); | 263 PK11_ListPublicKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL); |
225 EXPECT_FALSE(pubkey_list); | 264 EXPECT_FALSE(pubkey_list); |
226 | 265 |
227 ASSERT_EQ(1u, web_trust_certificates_.size()); | 266 ASSERT_EQ(1u, web_trust_certificates_.size()); |
228 ASSERT_EQ(1u, result_list_.size()); | 267 ASSERT_EQ(1u, public_list_.size()); |
229 EXPECT_TRUE(CERT_CompareCerts(result_list_[0]->os_cert_handle(), | 268 EXPECT_TRUE(private_list_.empty()); |
269 EXPECT_TRUE(CERT_CompareCerts(public_list_[0]->os_cert_handle(), | |
230 web_trust_certificates_[0]->os_cert_handle())); | 270 web_trust_certificates_[0]->os_cert_handle())); |
231 } | 271 } |
232 | 272 |
233 TEST_F(ONCCertificateImporterImplTest, AddWebAuthorityCertificateWithWebTrust) { | 273 TEST_F(ONCCertificateImporterImplTest, AddWebAuthorityCertificateWithWebTrust) { |
234 AddCertificateFromFile("certificate-web-authority.onc", net::CA_CERT, NULL); | 274 AddCertificateFromFile("certificate-web-authority.onc", net::CA_CERT, NULL); |
235 | 275 |
236 SECKEYPrivateKeyList* privkey_list = | 276 SECKEYPrivateKeyList* privkey_list = |
237 PK11_ListPrivKeysInSlot(slot_->os_module_handle(), NULL, NULL); | 277 PK11_ListPrivKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL, NULL); |
238 EXPECT_FALSE(privkey_list); | 278 EXPECT_FALSE(privkey_list); |
239 | 279 |
240 SECKEYPublicKeyList* pubkey_list = | 280 SECKEYPublicKeyList* pubkey_list = |
241 PK11_ListPublicKeysInSlot(slot_->os_module_handle(), NULL); | 281 PK11_ListPublicKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL); |
242 EXPECT_FALSE(pubkey_list); | 282 EXPECT_FALSE(pubkey_list); |
243 | 283 |
244 ASSERT_EQ(1u, web_trust_certificates_.size()); | 284 ASSERT_EQ(1u, web_trust_certificates_.size()); |
245 ASSERT_EQ(1u, result_list_.size()); | 285 ASSERT_EQ(1u, public_list_.size()); |
246 EXPECT_TRUE(CERT_CompareCerts(result_list_[0]->os_cert_handle(), | 286 EXPECT_TRUE(private_list_.empty()); |
287 EXPECT_TRUE(CERT_CompareCerts(public_list_[0]->os_cert_handle(), | |
247 web_trust_certificates_[0]->os_cert_handle())); | 288 web_trust_certificates_[0]->os_cert_handle())); |
248 } | 289 } |
249 | 290 |
250 TEST_F(ONCCertificateImporterImplTest, AddAuthorityCertificateWithoutWebTrust) { | 291 TEST_F(ONCCertificateImporterImplTest, AddAuthorityCertificateWithoutWebTrust) { |
251 AddCertificateFromFile("certificate-authority.onc", net::CA_CERT, NULL); | 292 AddCertificateFromFile("certificate-authority.onc", net::CA_CERT, NULL); |
252 EXPECT_TRUE(web_trust_certificates_.empty()); | 293 EXPECT_TRUE(web_trust_certificates_.empty()); |
253 | 294 |
254 SECKEYPrivateKeyList* privkey_list = | 295 SECKEYPrivateKeyList* privkey_list = |
255 PK11_ListPrivKeysInSlot(slot_->os_module_handle(), NULL, NULL); | 296 PK11_ListPrivKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL, NULL); |
256 EXPECT_FALSE(privkey_list); | 297 EXPECT_FALSE(privkey_list); |
257 | 298 |
258 SECKEYPublicKeyList* pubkey_list = | 299 SECKEYPublicKeyList* pubkey_list = |
259 PK11_ListPublicKeysInSlot(slot_->os_module_handle(), NULL); | 300 PK11_ListPublicKeysInSlot(test_nssdb_->GetPrivateSlot().get(), NULL); |
260 EXPECT_FALSE(pubkey_list); | 301 EXPECT_FALSE(pubkey_list); |
261 } | 302 } |
262 | 303 |
263 struct CertParam { | 304 struct CertParam { |
264 CertParam(net::CertType certificate_type, | 305 CertParam(net::CertType certificate_type, |
265 const char* original_filename, | 306 const char* original_filename, |
266 const char* update_filename) | 307 const char* update_filename) |
267 : cert_type(certificate_type), | 308 : cert_type(certificate_type), |
268 original_file(original_filename), | 309 original_file(original_filename), |
269 update_file(update_filename) {} | 310 update_file(update_filename) {} |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 "certificate-client-update.onc"), | 353 "certificate-client-update.onc"), |
313 CertParam(net::SERVER_CERT, | 354 CertParam(net::SERVER_CERT, |
314 "certificate-server.onc", | 355 "certificate-server.onc", |
315 "certificate-server-update.onc"), | 356 "certificate-server-update.onc"), |
316 CertParam(net::CA_CERT, | 357 CertParam(net::CA_CERT, |
317 "certificate-web-authority.onc", | 358 "certificate-web-authority.onc", |
318 "certificate-web-authority-update.onc"))); | 359 "certificate-web-authority-update.onc"))); |
319 | 360 |
320 } // namespace onc | 361 } // namespace onc |
321 } // namespace chromeos | 362 } // namespace chromeos |
OLD | NEW |