Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: net/cert/internal/cert_issuer_source_aia_unittest.cc

Issue 2453093004: Remove dependence on a message loop for net::PathBuilder. (Closed)
Patch Set: remove unnecessary forward decl Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/internal/cert_issuer_source_aia.h" 5 #include "net/cert/internal/cert_issuer_source_aia.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h"
8 #include "net/cert/cert_net_fetcher.h" 9 #include "net/cert/cert_net_fetcher.h"
9 #include "net/cert/internal/cert_errors.h" 10 #include "net/cert/internal/cert_errors.h"
10 #include "net/cert/internal/parsed_certificate.h" 11 #include "net/cert/internal/parsed_certificate.h"
11 #include "net/cert/internal/test_helpers.h" 12 #include "net/cert/internal/test_helpers.h"
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 namespace { 19 namespace {
19 20
21 using ::testing::ByMove;
20 using ::testing::Mock; 22 using ::testing::Mock;
23 using ::testing::Return;
21 using ::testing::StrictMock; 24 using ::testing::StrictMock;
25 using ::testing::_;
22 26
23 ::testing::AssertionResult ReadTestPem(const std::string& file_name, 27 ::testing::AssertionResult ReadTestPem(const std::string& file_name,
24 const std::string& block_name, 28 const std::string& block_name,
25 std::string* result) { 29 std::string* result) {
26 const PemBlockMapping mappings[] = { 30 const PemBlockMapping mappings[] = {
27 {block_name.c_str(), result}, 31 {block_name.c_str(), result},
28 }; 32 };
29 33
30 return ReadTestDataFromPemFile(file_name, mappings); 34 return ReadTestDataFromPemFile(file_name, mappings);
31 } 35 }
(...skipping 17 matching lines...) Expand all
49 return ::testing::AssertionSuccess(); 53 return ::testing::AssertionSuccess();
50 } 54 }
51 55
52 std::vector<uint8_t> CertDataVector(const ParsedCertificate* cert) { 56 std::vector<uint8_t> CertDataVector(const ParsedCertificate* cert) {
53 std::vector<uint8_t> data( 57 std::vector<uint8_t> data(
54 cert->der_cert().UnsafeData(), 58 cert->der_cert().UnsafeData(),
55 cert->der_cert().UnsafeData() + cert->der_cert().Length()); 59 cert->der_cert().UnsafeData() + cert->der_cert().Length());
56 return data; 60 return data;
57 } 61 }
58 62
59 // Tracks a CertNetFetcher::Request that will be returned to the 63 // MockCertNetFetcher is an implementation of CertNetFetcher for testing.
60 // CertIssuerSourceAia. Allows the tests to tell if the Request is still alive 64 class MockCertNetFetcher : public CertNetFetcher {
61 // or was deleted(cancelled) by the CertIssuerSourceAia. If the Request is still
62 // alive, the test can get the FetchCallback to simulate the Request completing.
63 class RequestManager {
64 public: 65 public:
65 class Request : public CertNetFetcher::Request { 66 MOCK_METHOD3(FetchCaIssuers,
66 public: 67 std::unique_ptr<Request>(const GURL& url,
67 Request(RequestManager* manager, 68 int timeout_milliseconds,
68 const CertNetFetcher::FetchCallback& callback) 69 int max_response_bytes));
69 : manager_(manager), callback_(callback) {} 70 MOCK_METHOD3(FetchCrl,
70 ~Request() override { manager_->RequestWasDestroyed(); } 71 std::unique_ptr<Request>(const GURL& url,
72 int timeout_milliseconds,
73 int max_response_bytes));
71 74
72 CertNetFetcher::FetchCallback get_callback() const { return callback_; } 75 MOCK_METHOD3(FetchOcsp,
76 std::unique_ptr<Request>(const GURL& url,
77 int timeout_milliseconds,
78 int max_response_bytes));
79 };
73 80
74 private: 81 // MockCertNetFetcherRequest gives back the indicated error and bytes.
75 RequestManager* manager_; 82 class MockCertNetFetcherRequest : public CertNetFetcher::Request {
76 CertNetFetcher::FetchCallback callback_; 83 public:
77 }; 84 MockCertNetFetcherRequest(Error error, std::vector<uint8_t> bytes)
85 : error_(error), bytes_(std::move(bytes)) {}
78 86
79 ~RequestManager() { CHECK(!request_); } 87 void WaitForResult(Error* error, std::vector<uint8_t>* bytes) override {
80 88 DCHECK(!did_consume_result_);
81 std::unique_ptr<Request> CreateRequest( 89 *error = error_;
82 const CertNetFetcher::FetchCallback& callback) { 90 *bytes = std::move(bytes_);
83 EXPECT_FALSE(request_); 91 did_consume_result_ = true;
84 std::unique_ptr<Request> request(new Request(this, callback));
85 request_ = request.get();
86 return request;
87 }
88
89 bool is_request_alive() const { return request_; }
90
91 CertNetFetcher::FetchCallback get_callback() const {
92 CHECK(is_request_alive());
93 return request_->get_callback();
94 } 92 }
95 93
96 private: 94 private:
97 void RequestWasDestroyed() { 95 Error error_;
98 EXPECT_TRUE(request_); 96 std::vector<uint8_t> bytes_;
99 request_ = nullptr; 97 bool did_consume_result_ = false;
100 }
101
102 Request* request_;
103 }; 98 };
104 99
105 // MockCertNetFetcherImpl is an implementation of CertNetFetcher for testing. 100 // Creates a CertNetFetcher::Request that completes with an error.
106 class MockCertNetFetcherImpl : public CertNetFetcher { 101 std::unique_ptr<CertNetFetcher::Request> CreateMockRequest(Error error) {
107 public: 102 return base::MakeUnique<MockCertNetFetcherRequest>(error,
108 MockCertNetFetcherImpl() = default; 103 std::vector<uint8_t>());
109 ~MockCertNetFetcherImpl() override = default; 104 }
110 105
111 RequestManager* GetRequestManagerForURL(const GURL& url) { 106 // Creates a CertNetFetcher::Request that completes with the specified error
112 auto it = request_map_.find(url); 107 // code and bytes.
113 if (it == request_map_.end()) 108 std::unique_ptr<CertNetFetcher::Request> CreateMockRequest(
114 return nullptr; 109 const std::vector<uint8_t>& bytes) {
115 return it->second.get(); 110 return base::MakeUnique<MockCertNetFetcherRequest>(OK, bytes);
116 }
117
118 WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCaIssuers(
119 const GURL& url,
120 int timeout_milliseconds,
121 int max_response_bytes,
122 const FetchCallback& callback) override {
123 EXPECT_TRUE(request_map_.find(url) == request_map_.end());
124
125 std::unique_ptr<RequestManager> request_manager(new RequestManager());
126
127 std::unique_ptr<Request> request = request_manager->CreateRequest(callback);
128
129 request_map_[url] = std::move(request_manager);
130
131 return request;
132 }
133
134 WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCrl(
135 const GURL& url,
136 int timeout_milliseconds,
137 int max_response_bytes,
138 const FetchCallback& callback) override {
139 NOTREACHED();
140 return nullptr;
141 }
142
143 WARN_UNUSED_RESULT std::unique_ptr<Request> FetchOcsp(
144 const GURL& url,
145 int timeout_milliseconds,
146 int max_response_bytes,
147 const FetchCallback& callback) override {
148 NOTREACHED();
149 return nullptr;
150 }
151
152 private:
153 std::map<GURL, std::unique_ptr<RequestManager>> request_map_;
154
155 DISALLOW_COPY_AND_ASSIGN(MockCertNetFetcherImpl);
156 };
157
158 class MockIssuerCallback {
159 public:
160 MOCK_METHOD1(Callback, void(CertIssuerSource::Request*));
161 };
162
163 void NotCalled(CertIssuerSource::Request* request) {
164 ADD_FAILURE() << "NotCalled was called";
165 } 111 }
166 112
167 // CertIssuerSourceAia does not return results for SyncGetIssuersOf. 113 // CertIssuerSourceAia does not return results for SyncGetIssuersOf.
168 TEST(CertIssuerSourceAiaTest, NoSyncResults) { 114 TEST(CertIssuerSourceAiaTest, NoSyncResults) {
169 scoped_refptr<ParsedCertificate> cert; 115 scoped_refptr<ParsedCertificate> cert;
170 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); 116 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert));
171 117
172 StrictMock<MockCertNetFetcherImpl> mock_fetcher; 118 // No methods on |mock_fetcher| should be called.
119 StrictMock<MockCertNetFetcher> mock_fetcher;
173 CertIssuerSourceAia aia_source(&mock_fetcher); 120 CertIssuerSourceAia aia_source(&mock_fetcher);
174 ParsedCertificateList issuers; 121 ParsedCertificateList issuers;
175 aia_source.SyncGetIssuersOf(cert.get(), &issuers); 122 aia_source.SyncGetIssuersOf(cert.get(), &issuers);
176 EXPECT_EQ(0U, issuers.size()); 123 EXPECT_EQ(0U, issuers.size());
177 } 124 }
178 125
179 // If the AuthorityInfoAccess extension is not present, AsyncGetIssuersOf should 126 // If the AuthorityInfoAccess extension is not present, AsyncGetIssuersOf should
180 // synchronously indicate no results. 127 // synchronously indicate no results.
181 TEST(CertIssuerSourceAiaTest, NoAia) { 128 TEST(CertIssuerSourceAiaTest, NoAia) {
182 scoped_refptr<ParsedCertificate> cert; 129 scoped_refptr<ParsedCertificate> cert;
183 ASSERT_TRUE(ReadTestCert("target_no_aia.pem", &cert)); 130 ASSERT_TRUE(ReadTestCert("target_no_aia.pem", &cert));
184 131
185 StrictMock<MockCertNetFetcherImpl> mock_fetcher; 132 // No methods on |mock_fetcher| should be called.
133 StrictMock<MockCertNetFetcher> mock_fetcher;
186 CertIssuerSourceAia aia_source(&mock_fetcher); 134 CertIssuerSourceAia aia_source(&mock_fetcher);
187 std::unique_ptr<CertIssuerSource::Request> request; 135 std::unique_ptr<CertIssuerSource::Request> request;
188 aia_source.AsyncGetIssuersOf(cert.get(), base::Bind(&NotCalled), &request); 136 aia_source.AsyncGetIssuersOf(cert.get(), &request);
189 EXPECT_EQ(nullptr, request); 137 EXPECT_EQ(nullptr, request);
190 } 138 }
191 139
192 // If the AuthorityInfoAccess extension only contains non-HTTP URIs, 140 // If the AuthorityInfoAccess extension only contains non-HTTP URIs,
193 // AsyncGetIssuersOf should create a Request object. The URL scheme check is 141 // AsyncGetIssuersOf should create a Request object. The URL scheme check is
194 // part of the specific CertNetFetcher implementation, this tests that we handle 142 // part of the specific CertNetFetcher implementation, this tests that we handle
195 // ERR_DISALLOWED_URL_SCHEME properly. If FetchCaIssuers is modified to fail 143 // ERR_DISALLOWED_URL_SCHEME properly. If FetchCaIssuers is modified to fail
196 // synchronously in that case, this test will be more interesting. 144 // synchronously in that case, this test will be more interesting.
197 TEST(CertIssuerSourceAiaTest, FileAia) { 145 TEST(CertIssuerSourceAiaTest, FileAia) {
198 scoped_refptr<ParsedCertificate> cert; 146 scoped_refptr<ParsedCertificate> cert;
199 ASSERT_TRUE(ReadTestCert("target_file_aia.pem", &cert)); 147 ASSERT_TRUE(ReadTestCert("target_file_aia.pem", &cert));
200 148
201 StrictMock<MockIssuerCallback> mock_callback; 149 StrictMock<MockCertNetFetcher> mock_fetcher;
202 StrictMock<MockCertNetFetcherImpl> mock_fetcher; 150 EXPECT_CALL(mock_fetcher, FetchCaIssuers(GURL("file:///dev/null"), _, _))
151 .WillOnce(Return(ByMove(CreateMockRequest(ERR_DISALLOWED_URL_SCHEME))));
152
203 CertIssuerSourceAia aia_source(&mock_fetcher); 153 CertIssuerSourceAia aia_source(&mock_fetcher);
204 std::unique_ptr<CertIssuerSource::Request> cert_source_request; 154 std::unique_ptr<CertIssuerSource::Request> cert_source_request;
205 aia_source.AsyncGetIssuersOf(cert.get(), 155 aia_source.AsyncGetIssuersOf(cert.get(), &cert_source_request);
206 base::Bind(&MockIssuerCallback::Callback,
207 base::Unretained(&mock_callback)),
208 &cert_source_request);
209 ASSERT_NE(nullptr, cert_source_request); 156 ASSERT_NE(nullptr, cert_source_request);
210 157
211 RequestManager* req_manager =
212 mock_fetcher.GetRequestManagerForURL(GURL("file:///dev/null"));
213 ASSERT_TRUE(req_manager);
214 ASSERT_TRUE(req_manager->is_request_alive());
215
216 EXPECT_CALL(mock_callback, Callback(cert_source_request.get()));
217 // CertNetFetcher rejects the URL scheme.
218 req_manager->get_callback().Run(ERR_DISALLOWED_URL_SCHEME,
219 std::vector<uint8_t>());
220 Mock::VerifyAndClearExpectations(&mock_callback);
221
222 // No results. 158 // No results.
223 scoped_refptr<ParsedCertificate> result_cert; 159 ParsedCertificateList result_certs;
224 CompletionStatus status = cert_source_request->GetNext(&result_cert); 160 cert_source_request->GetNext(&result_certs);
225 EXPECT_EQ(CompletionStatus::SYNC, status); 161 EXPECT_TRUE(result_certs.empty());
226 EXPECT_FALSE(result_cert.get());
227 } 162 }
228 163
229 // If the AuthorityInfoAccess extension contains an invalid URL, 164 // If the AuthorityInfoAccess extension contains an invalid URL,
230 // AsyncGetIssuersOf should synchronously indicate no results. 165 // AsyncGetIssuersOf should synchronously indicate no results.
231 TEST(CertIssuerSourceAiaTest, OneInvalidURL) { 166 TEST(CertIssuerSourceAiaTest, OneInvalidURL) {
232 scoped_refptr<ParsedCertificate> cert; 167 scoped_refptr<ParsedCertificate> cert;
233 ASSERT_TRUE(ReadTestCert("target_invalid_url_aia.pem", &cert)); 168 ASSERT_TRUE(ReadTestCert("target_invalid_url_aia.pem", &cert));
234 169
235 StrictMock<MockCertNetFetcherImpl> mock_fetcher; 170 StrictMock<MockCertNetFetcher> mock_fetcher;
236 CertIssuerSourceAia aia_source(&mock_fetcher); 171 CertIssuerSourceAia aia_source(&mock_fetcher);
237 std::unique_ptr<CertIssuerSource::Request> request; 172 std::unique_ptr<CertIssuerSource::Request> request;
238 aia_source.AsyncGetIssuersOf(cert.get(), base::Bind(&NotCalled), &request); 173 aia_source.AsyncGetIssuersOf(cert.get(), &request);
239 EXPECT_EQ(nullptr, request); 174 EXPECT_EQ(nullptr, request);
240 } 175 }
241 176
242 // AuthorityInfoAccess with a single HTTP url pointing to a single DER cert. 177 // AuthorityInfoAccess with a single HTTP url pointing to a single DER cert.
243 TEST(CertIssuerSourceAiaTest, OneAia) { 178 TEST(CertIssuerSourceAiaTest, OneAia) {
244 scoped_refptr<ParsedCertificate> cert; 179 scoped_refptr<ParsedCertificate> cert;
245 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); 180 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert));
246 scoped_refptr<ParsedCertificate> intermediate_cert; 181 scoped_refptr<ParsedCertificate> intermediate_cert;
247 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); 182 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert));
248 183
249 StrictMock<MockIssuerCallback> mock_callback; 184 StrictMock<MockCertNetFetcher> mock_fetcher;
250 StrictMock<MockCertNetFetcherImpl> mock_fetcher; 185
186 EXPECT_CALL(mock_fetcher,
187 FetchCaIssuers(GURL("http://url-for-aia/I.cer"), _, _))
188 .WillOnce(Return(
189 ByMove(CreateMockRequest(CertDataVector(intermediate_cert.get())))));
190
251 CertIssuerSourceAia aia_source(&mock_fetcher); 191 CertIssuerSourceAia aia_source(&mock_fetcher);
252 std::unique_ptr<CertIssuerSource::Request> cert_source_request; 192 std::unique_ptr<CertIssuerSource::Request> cert_source_request;
253 aia_source.AsyncGetIssuersOf(cert.get(), 193 aia_source.AsyncGetIssuersOf(cert.get(), &cert_source_request);
254 base::Bind(&MockIssuerCallback::Callback,
255 base::Unretained(&mock_callback)),
256 &cert_source_request);
257 ASSERT_NE(nullptr, cert_source_request); 194 ASSERT_NE(nullptr, cert_source_request);
258 195
259 RequestManager* req_manager = 196 ParsedCertificateList result_certs;
260 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); 197 cert_source_request->GetNext(&result_certs);
261 ASSERT_TRUE(req_manager); 198 ASSERT_EQ(1u, result_certs.size());
262 ASSERT_TRUE(req_manager->is_request_alive()); 199 ASSERT_EQ(result_certs.front()->der_cert(), intermediate_cert->der_cert());
263 200
264 EXPECT_CALL(mock_callback, Callback(cert_source_request.get())); 201 result_certs.clear();
265 req_manager->get_callback().Run(OK, CertDataVector(intermediate_cert.get())); 202 cert_source_request->GetNext(&result_certs);
266 Mock::VerifyAndClearExpectations(&mock_callback); 203 EXPECT_TRUE(result_certs.empty());
267
268 scoped_refptr<ParsedCertificate> result_cert;
269 CompletionStatus status = cert_source_request->GetNext(&result_cert);
270 EXPECT_EQ(CompletionStatus::SYNC, status);
271 ASSERT_TRUE(result_cert.get());
272 ASSERT_EQ(result_cert->der_cert(), intermediate_cert->der_cert());
273
274 status = cert_source_request->GetNext(&result_cert);
275 EXPECT_EQ(CompletionStatus::SYNC, status);
276 EXPECT_FALSE(result_cert.get());
277
278 EXPECT_TRUE(req_manager->is_request_alive());
279 cert_source_request.reset();
280 EXPECT_FALSE(req_manager->is_request_alive());
281 } 204 }
282 205
283 // AuthorityInfoAccess with two URIs, one a FILE, the other a HTTP. 206 // AuthorityInfoAccess with two URIs, one a FILE, the other a HTTP.
284 // Simulate a ERR_DISALLOWED_URL_SCHEME for the file URL. If FetchCaIssuers is 207 // Simulate a ERR_DISALLOWED_URL_SCHEME for the file URL. If FetchCaIssuers is
285 // modified to synchronously reject disallowed schemes, this test will be more 208 // modified to synchronously reject disallowed schemes, this test will be more
286 // interesting. 209 // interesting.
287 TEST(CertIssuerSourceAiaTest, OneFileOneHttpAia) { 210 TEST(CertIssuerSourceAiaTest, OneFileOneHttpAia) {
288 scoped_refptr<ParsedCertificate> cert; 211 scoped_refptr<ParsedCertificate> cert;
289 ASSERT_TRUE(ReadTestCert("target_file_and_http_aia.pem", &cert)); 212 ASSERT_TRUE(ReadTestCert("target_file_and_http_aia.pem", &cert));
290 scoped_refptr<ParsedCertificate> intermediate_cert; 213 scoped_refptr<ParsedCertificate> intermediate_cert;
291 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert)); 214 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert));
292 215
293 StrictMock<MockIssuerCallback> mock_callback; 216 StrictMock<MockCertNetFetcher> mock_fetcher;
294 StrictMock<MockCertNetFetcherImpl> mock_fetcher; 217
218 EXPECT_CALL(mock_fetcher, FetchCaIssuers(GURL("file:///dev/null"), _, _))
219 .WillOnce(Return(ByMove(CreateMockRequest(ERR_DISALLOWED_URL_SCHEME))));
220
221 EXPECT_CALL(mock_fetcher,
222 FetchCaIssuers(GURL("http://url-for-aia2/I2.foo"), _, _))
223 .WillOnce(Return(
224 ByMove(CreateMockRequest(CertDataVector(intermediate_cert.get())))));
225
295 CertIssuerSourceAia aia_source(&mock_fetcher); 226 CertIssuerSourceAia aia_source(&mock_fetcher);
296 std::unique_ptr<CertIssuerSource::Request> cert_source_request; 227 std::unique_ptr<CertIssuerSource::Request> cert_source_request;
297 aia_source.AsyncGetIssuersOf(cert.get(), 228 aia_source.AsyncGetIssuersOf(cert.get(), &cert_source_request);
298 base::Bind(&MockIssuerCallback::Callback,
299 base::Unretained(&mock_callback)),
300 &cert_source_request);
301 ASSERT_NE(nullptr, cert_source_request); 229 ASSERT_NE(nullptr, cert_source_request);
302 230
303 RequestManager* req_manager = 231 ParsedCertificateList result_certs;
304 mock_fetcher.GetRequestManagerForURL(GURL("file:///dev/null")); 232 cert_source_request->GetNext(&result_certs);
305 ASSERT_TRUE(req_manager); 233 ASSERT_EQ(1u, result_certs.size());
306 ASSERT_TRUE(req_manager->is_request_alive()); 234 ASSERT_EQ(result_certs.front()->der_cert(), intermediate_cert->der_cert());
307 235
308 RequestManager* req_manager2 = 236 cert_source_request->GetNext(&result_certs);
309 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia2/I2.foo")); 237 EXPECT_EQ(1u, result_certs.size());
310 ASSERT_TRUE(req_manager2);
311 ASSERT_TRUE(req_manager2->is_request_alive());
312
313 // Request for file URL completes with disallowed scheme failure. Callback is
314 // NOT called.
315 req_manager->get_callback().Run(ERR_DISALLOWED_URL_SCHEME,
316 std::vector<uint8_t>());
317 Mock::VerifyAndClearExpectations(&mock_callback);
318
319 // Request for I2.foo completes. Callback should be called now.
320 EXPECT_CALL(mock_callback, Callback(cert_source_request.get()));
321 req_manager2->get_callback().Run(OK, CertDataVector(intermediate_cert.get()));
322 Mock::VerifyAndClearExpectations(&mock_callback);
323
324 scoped_refptr<ParsedCertificate> result_cert;
325 CompletionStatus status = cert_source_request->GetNext(&result_cert);
326 EXPECT_EQ(CompletionStatus::SYNC, status);
327 ASSERT_TRUE(result_cert.get());
328 ASSERT_EQ(result_cert->der_cert(), intermediate_cert->der_cert());
329
330 status = cert_source_request->GetNext(&result_cert);
331 EXPECT_EQ(CompletionStatus::SYNC, status);
332 EXPECT_FALSE(result_cert.get());
333
334 EXPECT_TRUE(req_manager2->is_request_alive());
335 cert_source_request.reset();
336 EXPECT_FALSE(req_manager2->is_request_alive());
337 } 238 }
338 239
240 // TODO(eroman): Re-enable these tests!
241 #if 0
339 // AuthorityInfoAccess with two URIs, one is invalid, the other HTTP. 242 // AuthorityInfoAccess with two URIs, one is invalid, the other HTTP.
340 TEST(CertIssuerSourceAiaTest, OneInvalidOneHttpAia) { 243 TEST(CertIssuerSourceAiaTest, OneInvalidOneHttpAia) {
341 scoped_refptr<ParsedCertificate> cert; 244 scoped_refptr<ParsedCertificate> cert;
342 ASSERT_TRUE(ReadTestCert("target_invalid_and_http_aia.pem", &cert)); 245 ASSERT_TRUE(ReadTestCert("target_invalid_and_http_aia.pem", &cert));
343 scoped_refptr<ParsedCertificate> intermediate_cert; 246 scoped_refptr<ParsedCertificate> intermediate_cert;
344 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert)); 247 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert));
345 248
346 StrictMock<MockIssuerCallback> mock_callback; 249 StrictMock<MockIssuerCallback> mock_callback;
347 StrictMock<MockCertNetFetcherImpl> mock_fetcher; 250 StrictMock<MockCertNetFetcherImpl> mock_fetcher;
348 CertIssuerSourceAia aia_source(&mock_fetcher); 251 CertIssuerSourceAia aia_source(&mock_fetcher);
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 RequestManager* req_manager5 = 816 RequestManager* req_manager5 =
914 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia5/I5.foo")); 817 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia5/I5.foo"));
915 ASSERT_TRUE(req_manager5); 818 ASSERT_TRUE(req_manager5);
916 EXPECT_TRUE(req_manager5->is_request_alive()); 819 EXPECT_TRUE(req_manager5->is_request_alive());
917 820
918 // Sixth URL should not have created a request. 821 // Sixth URL should not have created a request.
919 EXPECT_FALSE( 822 EXPECT_FALSE(
920 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia6/I6.foo"))); 823 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia6/I6.foo")));
921 } 824 }
922 825
826 #endif
827
923 } // namespace 828 } // namespace
924 829
925 } // namespace net 830 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/cert_issuer_source_aia.cc ('k') | net/cert/internal/cert_issuer_source_static.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698