| 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 "net/cert/nss_cert_database_chromeos.h" | 5 #include "net/cert/nss_cert_database_chromeos.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | |
| 10 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/thread_task_runner_handle.h" |
| 11 #include "crypto/nss_util_internal.h" | 11 #include "crypto/nss_util_internal.h" |
| 12 #include "crypto/scoped_test_nss_chromeos_user.h" | 12 #include "crypto/scoped_test_nss_chromeos_user.h" |
| 13 #include "crypto/scoped_test_nss_db.h" | 13 #include "crypto/scoped_test_nss_db.h" |
| 14 #include "net/base/test_data_directory.h" | 14 #include "net/base/test_data_directory.h" |
| 15 #include "net/cert/cert_database.h" | 15 #include "net/cert/cert_database.h" |
| 16 #include "net/test/cert_test_util.h" | 16 #include "net/test/cert_test_util.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 | 20 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 ASSERT_TRUE(user_2_.constructed_successfully()); | 54 ASSERT_TRUE(user_2_.constructed_successfully()); |
| 55 user_1_.FinishInit(); | 55 user_1_.FinishInit(); |
| 56 user_2_.FinishInit(); | 56 user_2_.FinishInit(); |
| 57 | 57 |
| 58 // Create NSSCertDatabaseChromeOS for each user. | 58 // Create NSSCertDatabaseChromeOS for each user. |
| 59 db_1_.reset(new NSSCertDatabaseChromeOS( | 59 db_1_.reset(new NSSCertDatabaseChromeOS( |
| 60 crypto::GetPublicSlotForChromeOSUser(user_1_.username_hash()), | 60 crypto::GetPublicSlotForChromeOSUser(user_1_.username_hash()), |
| 61 crypto::GetPrivateSlotForChromeOSUser( | 61 crypto::GetPrivateSlotForChromeOSUser( |
| 62 user_1_.username_hash(), | 62 user_1_.username_hash(), |
| 63 base::Callback<void(crypto::ScopedPK11Slot)>()))); | 63 base::Callback<void(crypto::ScopedPK11Slot)>()))); |
| 64 db_1_->SetSlowTaskRunnerForTest(base::MessageLoopProxy::current()); | 64 db_1_->SetSlowTaskRunnerForTest(base::ThreadTaskRunnerHandle::Get()); |
| 65 db_1_->SetSystemSlot( | 65 db_1_->SetSystemSlot( |
| 66 crypto::ScopedPK11Slot(PK11_ReferenceSlot(system_db_.slot()))); | 66 crypto::ScopedPK11Slot(PK11_ReferenceSlot(system_db_.slot()))); |
| 67 db_2_.reset(new NSSCertDatabaseChromeOS( | 67 db_2_.reset(new NSSCertDatabaseChromeOS( |
| 68 crypto::GetPublicSlotForChromeOSUser(user_2_.username_hash()), | 68 crypto::GetPublicSlotForChromeOSUser(user_2_.username_hash()), |
| 69 crypto::GetPrivateSlotForChromeOSUser( | 69 crypto::GetPrivateSlotForChromeOSUser( |
| 70 user_2_.username_hash(), | 70 user_2_.username_hash(), |
| 71 base::Callback<void(crypto::ScopedPK11Slot)>()))); | 71 base::Callback<void(crypto::ScopedPK11Slot)>()))); |
| 72 db_2_->SetSlowTaskRunnerForTest(base::MessageLoopProxy::current()); | 72 db_2_->SetSlowTaskRunnerForTest(base::ThreadTaskRunnerHandle::Get()); |
| 73 | 73 |
| 74 // Add observer to CertDatabase for checking that notifications from | 74 // Add observer to CertDatabase for checking that notifications from |
| 75 // NSSCertDatabaseChromeOS are proxied to the CertDatabase. | 75 // NSSCertDatabaseChromeOS are proxied to the CertDatabase. |
| 76 CertDatabase::GetInstance()->AddObserver(this); | 76 CertDatabase::GetInstance()->AddObserver(this); |
| 77 observer_added_ = true; | 77 observer_added_ = true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void TearDown() override { | 80 void TearDown() override { |
| 81 if (observer_added_) | 81 if (observer_added_) |
| 82 CertDatabase::GetInstance()->RemoveObserver(this); | 82 CertDatabase::GetInstance()->RemoveObserver(this); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 "client_2.pem", | 314 "client_2.pem", |
| 315 "client_2.pk8", | 315 "client_2.pk8", |
| 316 system_db_.slot())); | 316 system_db_.slot())); |
| 317 CertificateList certs; | 317 CertificateList certs; |
| 318 db_2_->ListCertsSync(&certs); | 318 db_2_->ListCertsSync(&certs); |
| 319 EXPECT_TRUE(IsCertInCertificateList(cert_1.get(), certs)); | 319 EXPECT_TRUE(IsCertInCertificateList(cert_1.get(), certs)); |
| 320 EXPECT_FALSE(IsCertInCertificateList(cert_2.get(), certs)); | 320 EXPECT_FALSE(IsCertInCertificateList(cert_2.get(), certs)); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace net | 323 } // namespace net |
| OLD | NEW |