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/quic/test_tools/crypto_test_utils.h" | 5 #include "net/quic/test_tools/crypto_test_utils.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "net/base/test_data_directory.h" | 9 #include "net/base/test_data_directory.h" |
10 #include "net/cert/cert_verifier.h" | 10 #include "net/cert/cert_verifier.h" |
11 #include "net/cert/test_root_certs.h" | 11 #include "net/cert/test_root_certs.h" |
12 #include "net/cert/x509_certificate.h" | 12 #include "net/cert/x509_certificate.h" |
13 #include "net/quic/crypto/proof_source_chromium.h" | 13 #include "net/quic/crypto/proof_source_chromium.h" |
14 #include "net/quic/crypto/proof_verifier_chromium.h" | 14 #include "net/quic/crypto/proof_verifier_chromium.h" |
15 #include "net/test/cert_test_util.h" | 15 #include "net/test/cert_test_util.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 namespace test { | 19 namespace test { |
20 | 20 |
21 class TestProofVerifierChromium : public ProofVerifierChromium { | 21 class TestProofVerifierChromium : public ProofVerifierChromium { |
22 public: | 22 public: |
23 TestProofVerifierChromium(CertVerifier* cert_verifier, | 23 TestProofVerifierChromium(CertVerifier* cert_verifier, |
24 const std::string& cert_file) | 24 const std::string& cert_file) |
25 : ProofVerifierChromium(cert_verifier), | 25 : ProofVerifierChromium(cert_verifier), cert_verifier_(cert_verifier) { |
26 cert_verifier_(cert_verifier) { | |
27 // Load and install the root for the validated chain. | 26 // Load and install the root for the validated chain. |
28 scoped_refptr<X509Certificate> root_cert = | 27 scoped_refptr<X509Certificate> root_cert = |
29 ImportCertFromFile(GetTestCertsDirectory(), cert_file); | 28 ImportCertFromFile(GetTestCertsDirectory(), cert_file); |
30 scoped_root_.Reset(root_cert.get()); | 29 scoped_root_.Reset(root_cert.get()); |
31 } | 30 } |
32 virtual ~TestProofVerifierChromium() { } | 31 virtual ~TestProofVerifierChromium() {} |
33 | 32 |
34 private: | 33 private: |
35 ScopedTestRoot scoped_root_; | 34 ScopedTestRoot scoped_root_; |
36 scoped_ptr<CertVerifier> cert_verifier_; | 35 scoped_ptr<CertVerifier> cert_verifier_; |
37 }; | 36 }; |
38 | 37 |
39 // static | 38 // static |
40 ProofSource* CryptoTestUtils::ProofSourceForTesting() { | 39 ProofSource* CryptoTestUtils::ProofSourceForTesting() { |
41 return new ProofSourceChromium(); | 40 return new ProofSourceChromium(); |
42 } | 41 } |
43 | 42 |
44 // static | 43 // static |
45 ProofVerifier* CryptoTestUtils::ProofVerifierForTesting() { | 44 ProofVerifier* CryptoTestUtils::ProofVerifierForTesting() { |
46 TestProofVerifierChromium* proof_verifier = new TestProofVerifierChromium( | 45 TestProofVerifierChromium* proof_verifier = new TestProofVerifierChromium( |
47 CertVerifier::CreateDefault(), "quic_root.crt"); | 46 CertVerifier::CreateDefault(), "quic_root.crt"); |
48 return proof_verifier; | 47 return proof_verifier; |
49 } | 48 } |
50 | 49 |
51 // static | 50 // static |
52 ProofVerifyContext* CryptoTestUtils::ProofVerifyContextForTesting() { | 51 ProofVerifyContext* CryptoTestUtils::ProofVerifyContextForTesting() { |
53 return new ProofVerifyContextChromium(BoundNetLog()); | 52 return new ProofVerifyContextChromium(BoundNetLog()); |
54 } | 53 } |
55 | 54 |
56 } // namespace test | 55 } // namespace test |
57 | 56 |
58 } // namespace net | 57 } // namespace net |
OLD | NEW |