OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 5 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 void SetUp() override { | 39 void SetUp() override { |
40 ASSERT_TRUE(test_nss_user_.constructed_successfully()); | 40 ASSERT_TRUE(test_nss_user_.constructed_successfully()); |
41 test_nss_user_.FinishInit(); | 41 test_nss_user_.FinishInit(); |
42 | 42 |
43 test_cert_db_.reset(new net::NSSCertDatabaseChromeOS( | 43 test_cert_db_.reset(new net::NSSCertDatabaseChromeOS( |
44 crypto::GetPublicSlotForChromeOSUser(test_nss_user_.username_hash()), | 44 crypto::GetPublicSlotForChromeOSUser(test_nss_user_.username_hash()), |
45 crypto::GetPrivateSlotForChromeOSUser( | 45 crypto::GetPrivateSlotForChromeOSUser( |
46 test_nss_user_.username_hash(), | 46 test_nss_user_.username_hash(), |
47 base::Callback<void(crypto::ScopedPK11Slot)>()))); | 47 base::Callback<void(crypto::ScopedPK11Slot)>()))); |
48 test_cert_db_->SetSlowTaskRunnerForTest( | |
49 base::ThreadTaskRunnerHandle::Get()); | |
50 | 48 |
51 cert_verifier_.reset(new PolicyCertVerifier(base::Bind( | 49 cert_verifier_.reset(new PolicyCertVerifier(base::Bind( |
52 &PolicyCertVerifierTest::OnTrustAnchorUsed, base::Unretained(this)))); | 50 &PolicyCertVerifierTest::OnTrustAnchorUsed, base::Unretained(this)))); |
53 cert_verifier_->InitializeOnIOThread(new chromeos::CertVerifyProcChromeOS( | 51 cert_verifier_->InitializeOnIOThread(new chromeos::CertVerifyProcChromeOS( |
54 crypto::GetPublicSlotForChromeOSUser(test_nss_user_.username_hash()))); | 52 crypto::GetPublicSlotForChromeOSUser(test_nss_user_.username_hash()))); |
55 | 53 |
56 test_ca_cert_ = LoadCertificate("root_ca_cert.pem", net::CA_CERT); | 54 test_ca_cert_ = LoadCertificate("root_ca_cert.pem", net::CA_CERT); |
57 ASSERT_TRUE(test_ca_cert_.get()); | 55 ASSERT_TRUE(test_ca_cert_.get()); |
58 test_server_cert_ = LoadCertificate("ok_cert.pem", net::SERVER_CERT); | 56 test_server_cert_ = LoadCertificate("ok_cert.pem", net::SERVER_CERT); |
59 ASSERT_TRUE(test_server_cert_.get()); | 57 ASSERT_TRUE(test_server_cert_.get()); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 int error = VerifyTestServerCert(callback, &verify_result, &request); | 226 int error = VerifyTestServerCert(callback, &verify_result, &request); |
229 // Note: this hits the cached result from the first Verify() in this test. | 227 // Note: this hits the cached result from the first Verify() in this test. |
230 EXPECT_EQ(net::ERR_CERT_AUTHORITY_INVALID, error); | 228 EXPECT_EQ(net::ERR_CERT_AUTHORITY_INVALID, error); |
231 } | 229 } |
232 // The additional trust anchors were reset, thus |cert_verifier_| should not | 230 // The additional trust anchors were reset, thus |cert_verifier_| should not |
233 // signal it's usage anymore. | 231 // signal it's usage anymore. |
234 EXPECT_FALSE(WasTrustAnchorUsedAndReset()); | 232 EXPECT_FALSE(WasTrustAnchorUsedAndReset()); |
235 } | 233 } |
236 | 234 |
237 } // namespace policy | 235 } // namespace policy |
OLD | NEW |