| 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(
|
|
|