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

Unified Diff: chrome/browser/chromeos/net/client_cert_store_chromeos_unittest.cc

Issue 2898573002: Refactor client cert private key handling. (Closed)
Patch Set: removed no longer needed forward declaration Created 3 years, 6 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
Index: chrome/browser/chromeos/net/client_cert_store_chromeos_unittest.cc
diff --git a/chrome/browser/chromeos/net/client_cert_store_chromeos_unittest.cc b/chrome/browser/chromeos/net/client_cert_store_chromeos_unittest.cc
index 6cd545d612103c0ad9050cb037d723f39da9d53a..668d05bf60f979c47ceec04daee17e0b2849e800 100644
--- a/chrome/browser/chromeos/net/client_cert_store_chromeos_unittest.cc
+++ b/chrome/browser/chromeos/net/client_cert_store_chromeos_unittest.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/chromeos/certificate_provider/certificate_provider.h"
#include "crypto/scoped_test_nss_db.h"
#include "net/cert/x509_certificate.h"
+#include "net/ssl/client_cert_identity_test_util.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "net/test/cert_test_util.h"
#include "net/test/test_data_directory.h"
@@ -74,10 +75,10 @@ class TestCertFilter : public ClientCertStoreChromeOS::CertFilter {
scoped_refptr<net::X509Certificate> not_allowed_cert_;
};
-void SaveCertsAndQuitCallback(net::CertificateList* out_certs,
- base::Closure quit_closure,
- net::CertificateList in_certs) {
- *out_certs = std::move(in_certs);
+void SaveIdentitiesAndQuitCallback(net::ClientCertIdentityList* out_identities,
+ base::Closure quit_closure,
+ net::ClientCertIdentityList in_identities) {
+ *out_identities = std::move(in_identities);
quit_closure.Run();
}
@@ -119,24 +120,24 @@ TEST_F(ClientCertStoreChromeOSTest, RequestWaitsForNSSInitAndSucceeds) {
scoped_refptr<net::SSLCertRequestInfo> request_all(
new net::SSLCertRequestInfo());
- net::CertificateList selected_certs;
+ net::ClientCertIdentityList selected_identities;
base::RunLoop run_loop;
- store.GetClientCerts(*request_all,
- base::Bind(SaveCertsAndQuitCallback, &selected_certs,
- run_loop.QuitClosure()));
+ store.GetClientCerts(
+ *request_all, base::Bind(SaveIdentitiesAndQuitCallback,
+ &selected_identities, run_loop.QuitClosure()));
{
base::RunLoop run_loop_inner;
run_loop_inner.RunUntilIdle();
// GetClientCerts should wait for the initialization of the filter to
// finish.
- ASSERT_EQ(0u, selected_certs.size());
+ ASSERT_EQ(0u, selected_identities.size());
EXPECT_TRUE(cert_filter->init_called());
}
cert_filter->FinishInit();
run_loop.Run();
- ASSERT_EQ(1u, selected_certs.size());
+ ASSERT_EQ(1u, selected_identities.size());
}
// Ensure that cert requests, that are started after the filter was initialized,
@@ -158,13 +159,13 @@ TEST_F(ClientCertStoreChromeOSTest, RequestsAfterNSSInitSucceed) {
new net::SSLCertRequestInfo());
base::RunLoop run_loop;
- net::CertificateList selected_certs;
- store.GetClientCerts(*request_all,
- base::Bind(SaveCertsAndQuitCallback, &selected_certs,
- run_loop.QuitClosure()));
+ net::ClientCertIdentityList selected_identities;
+ store.GetClientCerts(
+ *request_all, base::Bind(SaveIdentitiesAndQuitCallback,
+ &selected_identities, run_loop.QuitClosure()));
run_loop.Run();
- ASSERT_EQ(1u, selected_certs.size());
+ ASSERT_EQ(1u, selected_identities.size());
}
TEST_F(ClientCertStoreChromeOSTest, Filter) {
@@ -190,27 +191,27 @@ TEST_F(ClientCertStoreChromeOSTest, Filter) {
{
base::RunLoop run_loop;
cert_filter->SetNotAllowedCert(cert_2);
- net::CertificateList selected_certs;
- store.GetClientCerts(*request_all,
- base::Bind(SaveCertsAndQuitCallback, &selected_certs,
- run_loop.QuitClosure()));
+ net::ClientCertIdentityList selected_identities;
+ store.GetClientCerts(
+ *request_all, base::Bind(SaveIdentitiesAndQuitCallback,
+ &selected_identities, run_loop.QuitClosure()));
run_loop.Run();
- ASSERT_EQ(1u, selected_certs.size());
- EXPECT_TRUE(cert_1->Equals(selected_certs[0].get()));
+ ASSERT_EQ(1u, selected_identities.size());
+ EXPECT_TRUE(cert_1->Equals(selected_identities[0]->certificate()));
}
{
base::RunLoop run_loop;
cert_filter->SetNotAllowedCert(cert_1);
- net::CertificateList selected_certs;
- store.GetClientCerts(*request_all,
- base::Bind(SaveCertsAndQuitCallback, &selected_certs,
- run_loop.QuitClosure()));
+ net::ClientCertIdentityList selected_identities;
+ store.GetClientCerts(
+ *request_all, base::Bind(SaveIdentitiesAndQuitCallback,
+ &selected_identities, run_loop.QuitClosure()));
run_loop.Run();
- ASSERT_EQ(1u, selected_certs.size());
- EXPECT_TRUE(cert_2->Equals(selected_certs[0].get()));
+ ASSERT_EQ(1u, selected_identities.size());
+ EXPECT_TRUE(cert_2->Equals(selected_identities[0]->certificate()));
}
}
@@ -241,14 +242,14 @@ TEST_F(ClientCertStoreChromeOSTest, CertRequestMatching) {
request->cert_authorities = authority_1;
base::RunLoop run_loop;
- net::CertificateList selected_certs;
- store.GetClientCerts(*request,
- base::Bind(SaveCertsAndQuitCallback, &selected_certs,
- run_loop.QuitClosure()));
+ net::ClientCertIdentityList selected_identities;
+ store.GetClientCerts(
+ *request, base::Bind(SaveIdentitiesAndQuitCallback, &selected_identities,
+ run_loop.QuitClosure()));
run_loop.Run();
- ASSERT_EQ(1u, selected_certs.size());
- EXPECT_TRUE(cert_1->Equals(selected_certs[0].get()));
+ ASSERT_EQ(1u, selected_identities.size());
+ EXPECT_TRUE(cert_1->Equals(selected_identities[0]->certificate()));
}
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/net/client_cert_store_chromeos.cc ('k') | chrome/browser/chromeos/platform_keys/platform_keys_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698