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

Unified Diff: net/ssl/client_cert_store_mac_unittest.cc

Issue 2411023002: *WIP* Mac Unittest for client cert selection with intermediate certs
Patch Set: rebase Created 4 years, 1 month 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/ssl/client_cert_store_mac.cc ('k') | net/ssl/client_cert_store_nss_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ssl/client_cert_store_mac_unittest.cc
diff --git a/net/ssl/client_cert_store_mac_unittest.cc b/net/ssl/client_cert_store_mac_unittest.cc
index 6dc9279950aa43180e6ad81f369c6c9b704f84ef..59936ca033ca34f22727d2b2cd40f171557bf066 100644
--- a/net/ssl/client_cert_store_mac_unittest.cc
+++ b/net/ssl/client_cert_store_mac_unittest.cc
@@ -4,6 +4,9 @@
#include "net/ssl/client_cert_store_mac.h"
+#include "base/files/file_util.h"
+#include "base/run_loop.h"
+#include "net/cert/test_keychain_search_list_mac.h"
#include "net/ssl/client_cert_store_unittest-inl.h"
namespace net {
@@ -25,6 +28,67 @@ INSTANTIATE_TYPED_TEST_CASE_P(Mac,
ClientCertStoreTest,
ClientCertStoreMacTestDelegate);
+class ClientCertStoreChainMacTestDelegate {
+ public:
+ ClientCertStoreChainMacTestDelegate() {
+ test_keychain_search_list_ = TestKeychainSearchList::Create();
+ CHECK(test_keychain_search_list_);
+ }
+
+ scoped_refptr<X509Certificate> ImportCertAndKeychain(
+ const std::string& name) {
+ base::FilePath keychain_path(
+ GetTestCertsDirectory().AppendASCII(name + ".keychain"));
+ // SecKeychainOpen does not fail if the file doesn't exist, so assert it
+ // here
+ // for easier debugging.
+ if (!base::PathExists(keychain_path)) {
+ ADD_FAILURE() << "keychain doesn't exist:"
+ << keychain_path.MaybeAsASCII();
+ return nullptr;
+ }
+ SecKeychainRef keychain;
+ OSStatus status =
+ SecKeychainOpen(keychain_path.MaybeAsASCII().c_str(), &keychain);
+ EXPECT_EQ(errSecSuccess, status);
+ EXPECT_TRUE(keychain);
+ if (status != errSecSuccess || !keychain)
+ return nullptr;
+ base::ScopedCFTypeRef<SecKeychainRef> scoped_keychain(keychain);
+ test_keychain_search_list_->AddKeychain(keychain);
+
+ return ImportCertFromFile(GetTestCertsDirectory(), name + ".pem");
+ }
+
+ scoped_refptr<X509Certificate> ImportClientCert(const std::string& name) {
+ return ImportCertAndKeychain(name);
+ /*return ImportClientCertAndKeyFromFile(
+ GetTestCertsDirectory(), name + ".pem", name + ".pk8",
+ test_db.slot());*/
+ }
+
+ scoped_refptr<X509Certificate> ImportClientIntermediate(
+ const std::string& name) {
+ return ImportCertAndKeychain(name);
+ }
+
+ void GetClientCerts(const SSLCertRequestInfo& cert_request_info,
+ CertificateList* selected_certs) {
+ base::RunLoop loop;
+ store_.GetClientCerts(cert_request_info, selected_certs,
+ loop.QuitClosure());
+ loop.Run();
+ }
+
+ protected:
+ std::unique_ptr<TestKeychainSearchList> test_keychain_search_list_;
+ ClientCertStoreMac store_;
+};
+
+INSTANTIATE_TYPED_TEST_CASE_P(Mac,
+ ClientCertStoreChainTest,
+ ClientCertStoreChainMacTestDelegate);
+
class ClientCertStoreMacTest : public ::testing::Test {
protected:
bool SelectClientCertsGivenPreferred(
« no previous file with comments | « net/ssl/client_cert_store_mac.cc ('k') | net/ssl/client_cert_store_nss_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698