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 "content/browser/loader/resource_loader.h" | 5 #include "content/browser/loader/resource_loader.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
9 #include "content/browser/loader/resource_loader_delegate.h" | 9 #include "content/browser/loader/resource_loader_delegate.h" |
10 #include "content/public/browser/resource_request_info.h" | 10 #include "content/public/browser/resource_request_info.h" |
11 #include "content/public/test/mock_resource_context.h" | 11 #include "content/public/test/mock_resource_context.h" |
12 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
13 #include "content/test/test_content_browser_client.h" | 13 #include "content/test/test_content_browser_client.h" |
14 #include "net/base/request_priority.h" | |
14 #include "net/cert/x509_certificate.h" | 15 #include "net/cert/x509_certificate.h" |
15 #include "net/ssl/client_cert_store.h" | 16 #include "net/ssl/client_cert_store.h" |
16 #include "net/ssl/ssl_cert_request_info.h" | 17 #include "net/ssl/ssl_cert_request_info.h" |
17 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
18 #include "net/url_request/url_request_test_util.h" | 19 #include "net/url_request/url_request_test_util.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 namespace { | 23 namespace { |
23 | 24 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 }; | 205 }; |
205 | 206 |
206 // Verifies if a call to net::UrlRequest::Delegate::OnCertificateRequested() | 207 // Verifies if a call to net::UrlRequest::Delegate::OnCertificateRequested() |
207 // causes client cert store to be queried for certificates and if the returned | 208 // causes client cert store to be queried for certificates and if the returned |
208 // certificates are correctly passed to the content browser client for | 209 // certificates are correctly passed to the content browser client for |
209 // selection. | 210 // selection. |
210 TEST_F(ResourceLoaderTest, ClientCertStoreLookup) { | 211 TEST_F(ResourceLoaderTest, ClientCertStoreLookup) { |
211 const int kRenderProcessId = 1; | 212 const int kRenderProcessId = 1; |
212 const int kRenderViewId = 2; | 213 const int kRenderViewId = 2; |
213 | 214 |
214 scoped_ptr<net::URLRequest> request(new net::URLRequest( | 215 scoped_ptr<net::URLRequest> request( |
215 GURL("dummy"), NULL, | 216 new net::URLRequest(GURL("dummy"), |
216 resource_context_.GetRequestContext())); | 217 net::DEFAULT_PRIORITY, |
218 NULL, | |
219 resource_context_.GetRequestContext(), | |
220 NULL)); | |
mmenke
2013/10/30 15:27:11
Again, seems like we shouldn't be depending on res
akalin
2013/10/30 21:44:37
removed arg.
| |
217 ResourceRequestInfo::AllocateForTesting(request.get(), | 221 ResourceRequestInfo::AllocateForTesting(request.get(), |
218 ResourceType::MAIN_FRAME, | 222 ResourceType::MAIN_FRAME, |
219 &resource_context_, | 223 &resource_context_, |
220 kRenderProcessId, | 224 kRenderProcessId, |
221 kRenderViewId, | 225 kRenderViewId, |
222 false); | 226 false); |
223 | 227 |
224 // Set up the test client cert store. | 228 // Set up the test client cert store. |
225 net::CertificateList dummy_certs(1, scoped_refptr<net::X509Certificate>( | 229 net::CertificateList dummy_certs(1, scoped_refptr<net::X509Certificate>( |
226 new net::X509Certificate("test", "test", base::Time(), base::Time()))); | 230 new net::X509Certificate("test", "test", base::Time(), base::Time()))); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 } | 272 } |
269 | 273 |
270 // Verifies if a call to net::URLRequest::Delegate::OnCertificateRequested() | 274 // Verifies if a call to net::URLRequest::Delegate::OnCertificateRequested() |
271 // on a platform with a NULL client cert store still calls the content browser | 275 // on a platform with a NULL client cert store still calls the content browser |
272 // client for selection. | 276 // client for selection. |
273 TEST_F(ResourceLoaderTest, ClientCertStoreNull) { | 277 TEST_F(ResourceLoaderTest, ClientCertStoreNull) { |
274 const int kRenderProcessId = 1; | 278 const int kRenderProcessId = 1; |
275 const int kRenderViewId = 2; | 279 const int kRenderViewId = 2; |
276 | 280 |
277 scoped_ptr<net::URLRequest> request(new net::URLRequest( | 281 scoped_ptr<net::URLRequest> request(new net::URLRequest( |
278 GURL("dummy"), NULL, resource_context_.GetRequestContext())); | 282 GURL("dummy"), net::DEFAULT_PRIORITY, NULL, resource_context_.GetRequestCo ntext(), NULL)); |
279 ResourceRequestInfo::AllocateForTesting(request.get(), | 283 ResourceRequestInfo::AllocateForTesting(request.get(), |
280 ResourceType::MAIN_FRAME, | 284 ResourceType::MAIN_FRAME, |
281 &resource_context_, | 285 &resource_context_, |
282 kRenderProcessId, | 286 kRenderProcessId, |
283 kRenderViewId, | 287 kRenderViewId, |
284 false); | 288 false); |
285 | 289 |
286 // Ownership of the |request| is about to be turned over to ResourceLoader. We | 290 // Ownership of the |request| is about to be turned over to ResourceLoader. We |
287 // need to keep a raw pointer copy to access this object later. | 291 // need to keep a raw pointer copy to access this object later. |
288 net::URLRequest* raw_ptr_to_request = request.get(); | 292 net::URLRequest* raw_ptr_to_request = request.get(); |
(...skipping 19 matching lines...) Expand all Loading... | |
308 // Restore the original content browser client. | 312 // Restore the original content browser client. |
309 SetBrowserClientForTesting(old_client); | 313 SetBrowserClientForTesting(old_client); |
310 | 314 |
311 // Check if the SelectClientCertificate was called on the content browser | 315 // Check if the SelectClientCertificate was called on the content browser |
312 // client. | 316 // client. |
313 EXPECT_EQ(1, test_client.call_count()); | 317 EXPECT_EQ(1, test_client.call_count()); |
314 EXPECT_EQ(net::CertificateList(), test_client.passed_certs()); | 318 EXPECT_EQ(net::CertificateList(), test_client.passed_certs()); |
315 } | 319 } |
316 | 320 |
317 } // namespace content | 321 } // namespace content |
OLD | NEW |