| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // URLRequestJobFactory::ProtocolHandler implementation: | 187 // URLRequestJobFactory::ProtocolHandler implementation: |
| 188 net::URLRequestJob* MaybeCreateJob( | 188 net::URLRequestJob* MaybeCreateJob( |
| 189 net::URLRequest* request, | 189 net::URLRequest* request, |
| 190 net::NetworkDelegate* network_delegate) const override { | 190 net::NetworkDelegate* network_delegate) const override { |
| 191 return new MockClientCertURLRequestJob(request, network_delegate); | 191 return new MockClientCertURLRequestJob(request, network_delegate); |
| 192 } | 192 } |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 // Set up dummy values to use in test HTTPS requests. | 195 // Set up dummy values to use in test HTTPS requests. |
| 196 | 196 |
| 197 scoped_refptr<net::X509Certificate> GetTestCert() { | |
| 198 return net::ImportCertFromFile(net::GetTestCertsDirectory(), | |
| 199 "test_mail_google_com.pem"); | |
| 200 } | |
| 201 | |
| 202 const net::CertStatus kTestCertError = net::CERT_STATUS_DATE_INVALID; | 197 const net::CertStatus kTestCertError = net::CERT_STATUS_DATE_INVALID; |
| 203 const int kTestSecurityBits = 256; | 198 const int kTestSecurityBits = 256; |
| 204 // SSL3 TLS_DHE_RSA_WITH_AES_256_CBC_SHA | 199 // SSL3 TLS_DHE_RSA_WITH_AES_256_CBC_SHA |
| 205 const int kTestConnectionStatus = 0x300039; | 200 const int kTestConnectionStatus = 0x300039; |
| 206 | 201 |
| 207 // A mock URLRequestJob which simulates an HTTPS request. | 202 // A mock URLRequestJob which simulates an HTTPS request. |
| 208 class MockHTTPSURLRequestJob : public net::URLRequestTestJob { | 203 class MockHTTPSURLRequestJob : public net::URLRequestTestJob { |
| 209 public: | 204 public: |
| 210 MockHTTPSURLRequestJob(net::URLRequest* request, | 205 MockHTTPSURLRequestJob(net::URLRequest* request, |
| 211 net::NetworkDelegate* network_delegate, | 206 net::NetworkDelegate* network_delegate, |
| 212 const std::string& response_headers, | 207 const std::string& response_headers, |
| 213 const std::string& response_data, | 208 const std::string& response_data, |
| 214 bool auto_advance) | 209 bool auto_advance) |
| 215 : net::URLRequestTestJob(request, | 210 : net::URLRequestTestJob(request, |
| 216 network_delegate, | 211 network_delegate, |
| 217 response_headers, | 212 response_headers, |
| 218 response_data, | 213 response_data, |
| 219 auto_advance) {} | 214 auto_advance) {} |
| 220 | 215 |
| 221 // net::URLRequestTestJob: | 216 // net::URLRequestTestJob: |
| 222 void GetResponseInfo(net::HttpResponseInfo* info) override { | 217 void GetResponseInfo(net::HttpResponseInfo* info) override { |
| 223 // Get the original response info, but override the SSL info. | 218 // Get the original response info, but override the SSL info. |
| 224 net::URLRequestJob::GetResponseInfo(info); | 219 net::URLRequestJob::GetResponseInfo(info); |
| 225 info->ssl_info.cert = GetTestCert(); | 220 info->ssl_info.cert = |
| 221 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); |
| 226 info->ssl_info.cert_status = kTestCertError; | 222 info->ssl_info.cert_status = kTestCertError; |
| 227 info->ssl_info.security_bits = kTestSecurityBits; | 223 info->ssl_info.security_bits = kTestSecurityBits; |
| 228 info->ssl_info.connection_status = kTestConnectionStatus; | 224 info->ssl_info.connection_status = kTestConnectionStatus; |
| 229 } | 225 } |
| 230 | 226 |
| 231 private: | 227 private: |
| 232 ~MockHTTPSURLRequestJob() override {} | 228 ~MockHTTPSURLRequestJob() override {} |
| 233 | 229 |
| 234 DISALLOW_COPY_AND_ASSIGN(MockHTTPSURLRequestJob); | 230 DISALLOW_COPY_AND_ASSIGN(MockHTTPSURLRequestJob); |
| 235 }; | 231 }; |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 private: | 588 private: |
| 593 const GURL test_https_url_; | 589 const GURL test_https_url_; |
| 594 const GURL test_https_redirect_url_; | 590 const GURL test_https_redirect_url_; |
| 595 }; | 591 }; |
| 596 | 592 |
| 597 // Tests that client certificates are requested with ClientCertStore lookup. | 593 // Tests that client certificates are requested with ClientCertStore lookup. |
| 598 TEST_F(ClientCertResourceLoaderTest, WithStoreLookup) { | 594 TEST_F(ClientCertResourceLoaderTest, WithStoreLookup) { |
| 599 // Set up the test client cert store. | 595 // Set up the test client cert store. |
| 600 int store_request_count; | 596 int store_request_count; |
| 601 std::vector<std::string> store_requested_authorities; | 597 std::vector<std::string> store_requested_authorities; |
| 602 net::CertificateList dummy_certs(1, GetTestCert()); | 598 net::CertificateList dummy_certs( |
| 599 1, net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem")); |
| 603 std::unique_ptr<ClientCertStoreStub> test_store(new ClientCertStoreStub( | 600 std::unique_ptr<ClientCertStoreStub> test_store(new ClientCertStoreStub( |
| 604 dummy_certs, &store_request_count, &store_requested_authorities)); | 601 dummy_certs, &store_request_count, &store_requested_authorities)); |
| 605 SetClientCertStore(std::move(test_store)); | 602 SetClientCertStore(std::move(test_store)); |
| 606 | 603 |
| 607 // Plug in test content browser client. | 604 // Plug in test content browser client. |
| 608 SelectCertificateBrowserClient test_client; | 605 SelectCertificateBrowserClient test_client; |
| 609 ContentBrowserClient* old_client = SetBrowserClientForTesting(&test_client); | 606 ContentBrowserClient* old_client = SetBrowserClientForTesting(&test_client); |
| 610 | 607 |
| 611 // Start the request and wait for it to pause. | 608 // Start the request and wait for it to pause. |
| 612 loader_->StartRequest(); | 609 loader_->StartRequest(); |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 | 1554 |
| 1558 // Tests that the effective connection type is not set on non-main frame | 1555 // Tests that the effective connection type is not set on non-main frame |
| 1559 // requests. | 1556 // requests. |
| 1560 TEST_F(EffectiveConnectionTypeResourceLoaderTest, DoesNotBelongToMainFrame) { | 1557 TEST_F(EffectiveConnectionTypeResourceLoaderTest, DoesNotBelongToMainFrame) { |
| 1561 VerifyEffectiveConnectionType(RESOURCE_TYPE_OBJECT, false, | 1558 VerifyEffectiveConnectionType(RESOURCE_TYPE_OBJECT, false, |
| 1562 net::EFFECTIVE_CONNECTION_TYPE_3G, | 1559 net::EFFECTIVE_CONNECTION_TYPE_3G, |
| 1563 net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN); | 1560 net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN); |
| 1564 } | 1561 } |
| 1565 | 1562 |
| 1566 } // namespace content | 1563 } // namespace content |
| OLD | NEW |