| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ssl/ssl_client_certificate_selector_test.h" | 5 #include "chrome/browser/ssl/ssl_client_certificate_selector_test.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/test/browser_test_utils.h" | 14 #include "content/public/test/browser_test_utils.h" |
| 15 #include "net/base/request_priority.h" | 15 #include "net/base/request_priority.h" |
| 16 #include "net/cert/x509_certificate.h" | |
| 17 #include "net/http/http_transaction_factory.h" | 16 #include "net/http/http_transaction_factory.h" |
| 18 #include "net/ssl/ssl_cert_request_info.h" | 17 #include "net/ssl/ssl_cert_request_info.h" |
| 19 #include "net/test/cert_test_util.h" | |
| 20 #include "net/test/test_data_directory.h" | |
| 21 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" | 18 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 22 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
| 23 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
| 24 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
| 25 | 22 |
| 26 using ::testing::Mock; | 23 using ::testing::Mock; |
| 27 using ::testing::StrictMock; | 24 using ::testing::StrictMock; |
| 28 using content::BrowserThread; | 25 using content::BrowserThread; |
| 29 | 26 |
| 30 SSLClientCertificateSelectorTestBase::SSLClientCertificateSelectorTestBase() | 27 SSLClientCertificateSelectorTestBase::SSLClientCertificateSelectorTestBase() |
| 31 : io_loop_finished_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 28 : io_loop_finished_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 32 base::WaitableEvent::InitialState::NOT_SIGNALED) { | 29 base::WaitableEvent::InitialState::NOT_SIGNALED) { |
| 33 } | 30 } |
| 34 | 31 |
| 35 SSLClientCertificateSelectorTestBase::~SSLClientCertificateSelectorTestBase() { | 32 SSLClientCertificateSelectorTestBase::~SSLClientCertificateSelectorTestBase() { |
| 36 } | 33 } |
| 37 | 34 |
| 38 void SSLClientCertificateSelectorTestBase::SetUpInProcessBrowserTestFixture() { | 35 void SSLClientCertificateSelectorTestBase::SetUpInProcessBrowserTestFixture() { |
| 39 base::FilePath certs_dir = net::GetTestCertsDirectory(); | |
| 40 | |
| 41 mit_davidben_cert_ = net::ImportCertFromFile(certs_dir, "mit.davidben.der"); | |
| 42 ASSERT_TRUE(mit_davidben_cert_.get()); | |
| 43 | |
| 44 foaf_me_chromium_test_cert_ = net::ImportCertFromFile( | |
| 45 certs_dir, "foaf.me.chromium-test-cert.der"); | |
| 46 ASSERT_TRUE(foaf_me_chromium_test_cert_.get()); | |
| 47 | |
| 48 cert_request_info_ = new net::SSLCertRequestInfo; | 36 cert_request_info_ = new net::SSLCertRequestInfo; |
| 49 cert_request_info_->host_and_port = net::HostPortPair("foo", 123); | 37 cert_request_info_->host_and_port = net::HostPortPair("foo", 123); |
| 50 cert_request_info_->client_certs.push_back(mit_davidben_cert_); | |
| 51 cert_request_info_->client_certs.push_back(foaf_me_chromium_test_cert_); | |
| 52 } | 38 } |
| 53 | 39 |
| 54 void SSLClientCertificateSelectorTestBase::SetUpOnMainThread() { | 40 void SSLClientCertificateSelectorTestBase::SetUpOnMainThread() { |
| 55 url_request_context_getter_ = browser()->profile()->GetRequestContext(); | 41 url_request_context_getter_ = browser()->profile()->GetRequestContext(); |
| 56 | 42 |
| 57 BrowserThread::PostTask( | 43 BrowserThread::PostTask( |
| 58 BrowserThread::IO, | 44 BrowserThread::IO, |
| 59 FROM_HERE, | 45 FROM_HERE, |
| 60 base::Bind(&SSLClientCertificateSelectorTestBase::SetUpOnIOThread, | 46 base::Bind(&SSLClientCertificateSelectorTestBase::SetUpOnIOThread, |
| 61 base::Unretained(this))); | 47 base::Unretained(this))); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 83 |
| 98 std::unique_ptr<net::URLRequest> | 84 std::unique_ptr<net::URLRequest> |
| 99 SSLClientCertificateSelectorTestBase::MakeURLRequest( | 85 SSLClientCertificateSelectorTestBase::MakeURLRequest( |
| 100 net::URLRequestContextGetter* context_getter) { | 86 net::URLRequestContextGetter* context_getter) { |
| 101 std::unique_ptr<net::URLRequest> request = | 87 std::unique_ptr<net::URLRequest> request = |
| 102 context_getter->GetURLRequestContext()->CreateRequest( | 88 context_getter->GetURLRequestContext()->CreateRequest( |
| 103 GURL("https://example"), net::DEFAULT_PRIORITY, NULL, | 89 GURL("https://example"), net::DEFAULT_PRIORITY, NULL, |
| 104 TRAFFIC_ANNOTATION_FOR_TESTS); | 90 TRAFFIC_ANNOTATION_FOR_TESTS); |
| 105 return request; | 91 return request; |
| 106 } | 92 } |
| OLD | NEW |