OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 5 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 virtual ~PolicyCertVerifierTest() {} | 40 virtual ~PolicyCertVerifierTest() {} |
41 | 41 |
42 virtual void SetUp() OVERRIDE { | 42 virtual void SetUp() OVERRIDE { |
43 ASSERT_TRUE(test_nssdb_.is_open()); | 43 ASSERT_TRUE(test_nssdb_.is_open()); |
44 cert_db_ = net::NSSCertDatabase::GetInstance(); | 44 cert_db_ = net::NSSCertDatabase::GetInstance(); |
45 | 45 |
46 cert_verifier_.reset(new PolicyCertVerifier(base::Bind( | 46 cert_verifier_.reset(new PolicyCertVerifier(base::Bind( |
47 &PolicyCertVerifierTest::OnTrustAnchorUsed, base::Unretained(this)))); | 47 &PolicyCertVerifierTest::OnTrustAnchorUsed, base::Unretained(this)))); |
48 cert_verifier_->InitializeOnIOThread(new chromeos::CertVerifyProcChromeOS( | 48 cert_verifier_->InitializeOnIOThread(new chromeos::CertVerifyProcChromeOS( |
49 crypto::ScopedPK11Slot(crypto::GetPublicNSSKeySlot()))); | 49 crypto::ScopedPK11Slot(crypto::GetPersistentNSSKeySlot()))); |
50 | 50 |
51 test_ca_cert_ = LoadCertificate("root_ca_cert.pem", net::CA_CERT); | 51 test_ca_cert_ = LoadCertificate("root_ca_cert.pem", net::CA_CERT); |
52 ASSERT_TRUE(test_ca_cert_); | 52 ASSERT_TRUE(test_ca_cert_); |
53 test_server_cert_ = LoadCertificate("ok_cert.pem", net::SERVER_CERT); | 53 test_server_cert_ = LoadCertificate("ok_cert.pem", net::SERVER_CERT); |
54 ASSERT_TRUE(test_server_cert_); | 54 ASSERT_TRUE(test_server_cert_); |
55 test_ca_cert_list_.push_back(test_ca_cert_); | 55 test_ca_cert_list_.push_back(test_ca_cert_); |
56 } | 56 } |
57 | 57 |
58 virtual void TearDown() OVERRIDE { | 58 virtual void TearDown() OVERRIDE { |
59 // Destroy |cert_verifier_| before destroying the ThreadBundle, otherwise | 59 // Destroy |cert_verifier_| before destroying the ThreadBundle, otherwise |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 int error = VerifyTestServerCert(callback, &verify_result, &request_handle); | 224 int error = VerifyTestServerCert(callback, &verify_result, &request_handle); |
225 // Note: this hits the cached result from the first Verify() in this test. | 225 // Note: this hits the cached result from the first Verify() in this test. |
226 EXPECT_EQ(net::ERR_CERT_AUTHORITY_INVALID, error); | 226 EXPECT_EQ(net::ERR_CERT_AUTHORITY_INVALID, error); |
227 } | 227 } |
228 // The additional trust anchors were reset, thus |cert_verifier_| should not | 228 // The additional trust anchors were reset, thus |cert_verifier_| should not |
229 // signal it's usage anymore. | 229 // signal it's usage anymore. |
230 EXPECT_FALSE(WasTrustAnchorUsedAndReset()); | 230 EXPECT_FALSE(WasTrustAnchorUsedAndReset()); |
231 } | 231 } |
232 | 232 |
233 } // namespace policy | 233 } // namespace policy |
OLD | NEW |