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 "net/ocsp/nss_ocsp.h" | 5 #include "net/ocsp/nss_ocsp.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 }; | 66 }; |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 class NssHttpTest : public ::testing::Test { | 70 class NssHttpTest : public ::testing::Test { |
71 public: | 71 public: |
72 NssHttpTest() | 72 NssHttpTest() |
73 : context_(false), | 73 : context_(false), |
74 handler_(NULL), | 74 handler_(NULL), |
75 verify_proc_(new CertVerifyProcNSS), | 75 verify_proc_(new CertVerifyProcNSS), |
76 verifier_(new MultiThreadedCertVerifier(verify_proc_)) { | 76 verifier_(new MultiThreadedCertVerifier(verify_proc_.get())) {} |
77 } | |
78 virtual ~NssHttpTest() {} | 77 virtual ~NssHttpTest() {} |
79 | 78 |
80 virtual void SetUp() { | 79 virtual void SetUp() { |
81 std::string file_contents; | 80 std::string file_contents; |
82 ASSERT_TRUE(file_util::ReadFileToString( | 81 ASSERT_TRUE(file_util::ReadFileToString( |
83 GetTestCertsDirectory().AppendASCII("aia-intermediate.der"), | 82 GetTestCertsDirectory().AppendASCII("aia-intermediate.der"), |
84 &file_contents)); | 83 &file_contents)); |
85 ASSERT_FALSE(file_contents.empty()); | 84 ASSERT_FALSE(file_contents.empty()); |
86 | 85 |
87 // Ownership of |handler| is transferred to the URLRequestFilter, but | 86 // Ownership of |handler| is transferred to the URLRequestFilter, but |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // made successfully. | 128 // made successfully. |
130 TEST_F(NssHttpTest, TestAia) { | 129 TEST_F(NssHttpTest, TestAia) { |
131 scoped_refptr<X509Certificate> test_cert( | 130 scoped_refptr<X509Certificate> test_cert( |
132 ImportCertFromFile(GetTestCertsDirectory(), "aia-cert.pem")); | 131 ImportCertFromFile(GetTestCertsDirectory(), "aia-cert.pem")); |
133 ASSERT_TRUE(test_cert.get()); | 132 ASSERT_TRUE(test_cert.get()); |
134 | 133 |
135 scoped_refptr<X509Certificate> test_root( | 134 scoped_refptr<X509Certificate> test_root( |
136 ImportCertFromFile(GetTestCertsDirectory(), "aia-root.pem")); | 135 ImportCertFromFile(GetTestCertsDirectory(), "aia-root.pem")); |
137 ASSERT_TRUE(test_root.get()); | 136 ASSERT_TRUE(test_root.get()); |
138 | 137 |
139 ScopedTestRoot scoped_root(test_root); | 138 ScopedTestRoot scoped_root(test_root.get()); |
140 | 139 |
141 CertVerifyResult verify_result; | 140 CertVerifyResult verify_result; |
142 TestCompletionCallback test_callback; | 141 TestCompletionCallback test_callback; |
143 CertVerifier::RequestHandle request_handle; | 142 CertVerifier::RequestHandle request_handle; |
144 | 143 |
145 int flags = CertVerifier::VERIFY_CERT_IO_ENABLED; | 144 int flags = CertVerifier::VERIFY_CERT_IO_ENABLED; |
146 int error = verifier()->Verify(test_cert, "aia-host.invalid", flags, NULL, | 145 int error = verifier()->Verify(test_cert.get(), |
147 &verify_result, test_callback.callback(), | 146 "aia-host.invalid", |
148 &request_handle, BoundNetLog()); | 147 flags, |
| 148 NULL, |
| 149 &verify_result, |
| 150 test_callback.callback(), |
| 151 &request_handle, |
| 152 BoundNetLog()); |
149 ASSERT_EQ(ERR_IO_PENDING, error); | 153 ASSERT_EQ(ERR_IO_PENDING, error); |
150 | 154 |
151 error = test_callback.WaitForResult(); | 155 error = test_callback.WaitForResult(); |
152 | 156 |
153 EXPECT_EQ(OK, error); | 157 EXPECT_EQ(OK, error); |
154 | 158 |
155 // Ensure that NSS made an AIA request for the missing intermediate. | 159 // Ensure that NSS made an AIA request for the missing intermediate. |
156 EXPECT_LT(0, request_count()); | 160 EXPECT_LT(0, request_count()); |
157 } | 161 } |
158 | 162 |
159 } // namespace net | 163 } // namespace net |
OLD | NEW |