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

Side by Side Diff: chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc

Issue 1082123003: Rename USE_NSS to USE_NSS_CERTS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-nss-certs
Patch Set: rebase Created 5 years, 8 months 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 (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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ssl/ssl_client_auth_requestor_mock.h" 9 #include "chrome/browser/ssl/ssl_client_auth_requestor_mock.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 "chrome/browser/ui/views/ssl_client_certificate_selector.h" 12 #include "chrome/browser/ui/views/ssl_client_certificate_selector.h"
13 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/interactive_test_utils.h" 14 #include "chrome/test/base/interactive_test_utils.h"
15 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/client_certificate_delegate.h" 16 #include "content/public/browser/client_certificate_delegate.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "content/public/test/browser_test_utils.h" 18 #include "content/public/test/browser_test_utils.h"
19 #include "net/base/request_priority.h" 19 #include "net/base/request_priority.h"
20 #include "net/base/test_data_directory.h" 20 #include "net/base/test_data_directory.h"
21 #include "net/cert/x509_certificate.h" 21 #include "net/cert/x509_certificate.h"
22 #include "net/http/http_transaction_factory.h" 22 #include "net/http/http_transaction_factory.h"
23 #include "net/ssl/ssl_cert_request_info.h" 23 #include "net/ssl/ssl_cert_request_info.h"
24 #include "net/test/cert_test_util.h" 24 #include "net/test/cert_test_util.h"
25 #include "net/url_request/url_request.h" 25 #include "net/url_request/url_request.h"
26 #include "net/url_request/url_request_context.h" 26 #include "net/url_request/url_request_context.h"
27 #include "net/url_request/url_request_context_getter.h" 27 #include "net/url_request/url_request_context_getter.h"
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 29
30 #if defined(USE_NSS) 30 #if defined(USE_NSS_CERTS)
31 #include "crypto/scoped_test_nss_db.h" 31 #include "crypto/scoped_test_nss_db.h"
32 #endif 32 #endif
33 33
34 using ::testing::Mock; 34 using ::testing::Mock;
35 using ::testing::StrictMock; 35 using ::testing::StrictMock;
36 using content::BrowserThread; 36 using content::BrowserThread;
37 37
38 // We don't have a way to do end-to-end SSL client auth testing, so this test 38 // We don't have a way to do end-to-end SSL client auth testing, so this test
39 // creates a certificate selector_ manually with a mocked 39 // creates a certificate selector_ manually with a mocked
40 // SSLClientAuthHandler. 40 // SSLClientAuthHandler.
41 41
42 class SSLClientCertificateSelectorTest : public InProcessBrowserTest { 42 class SSLClientCertificateSelectorTest : public InProcessBrowserTest {
43 public: 43 public:
44 SSLClientCertificateSelectorTest() 44 SSLClientCertificateSelectorTest()
45 : io_loop_finished_event_(false, false), 45 : io_loop_finished_event_(false, false),
46 url_request_(NULL), 46 url_request_(NULL),
47 selector_(NULL) { 47 selector_(NULL) {
48 } 48 }
49 49
50 void SetUpInProcessBrowserTestFixture() override { 50 void SetUpInProcessBrowserTestFixture() override {
51 base::FilePath certs_dir = net::GetTestCertsDirectory(); 51 base::FilePath certs_dir = net::GetTestCertsDirectory();
52 52
53 #if defined(USE_NSS) 53 #if defined(USE_NSS_CERTS)
54 // If USE_NSS, the selector tries to unlock the slot where the private key 54 // If USE_NSS_CERTS, the selector tries to unlock the slot where the
55 // of each certificate is stored. If no private key is found, the slot would 55 // private key of each certificate is stored. If no private key is found,
56 // be null and the unlock will crash. 56 // the slot would be null and the unlock will crash.
57 ASSERT_TRUE(test_nssdb_.is_open()); 57 ASSERT_TRUE(test_nssdb_.is_open());
58 client_cert_1_ = net::ImportClientCertAndKeyFromFile( 58 client_cert_1_ = net::ImportClientCertAndKeyFromFile(
59 certs_dir, "client_1.pem", "client_1.pk8", test_nssdb_.slot()); 59 certs_dir, "client_1.pem", "client_1.pk8", test_nssdb_.slot());
60 client_cert_2_ = net::ImportClientCertAndKeyFromFile( 60 client_cert_2_ = net::ImportClientCertAndKeyFromFile(
61 certs_dir, "client_2.pem", "client_2.pk8", test_nssdb_.slot()); 61 certs_dir, "client_2.pem", "client_2.pk8", test_nssdb_.slot());
62 #else 62 #else
63 // No unlock is attempted if !USE_NSS. Thus, there is no need to import a 63 // No unlock is attempted if !USE_NSS_CERTS. Thus, there is no need to
64 // private key. 64 // import a private key.
65 client_cert_1_ = net::ImportCertFromFile(certs_dir, "client_1.pem"); 65 client_cert_1_ = net::ImportCertFromFile(certs_dir, "client_1.pem");
66 client_cert_2_ = net::ImportCertFromFile(certs_dir, "client_2.pem"); 66 client_cert_2_ = net::ImportCertFromFile(certs_dir, "client_2.pem");
67 #endif 67 #endif
68 ASSERT_NE(nullptr, client_cert_1_.get()); 68 ASSERT_NE(nullptr, client_cert_1_.get());
69 ASSERT_NE(nullptr, client_cert_2_.get()); 69 ASSERT_NE(nullptr, client_cert_2_.get());
70 70
71 cert_request_info_ = new net::SSLCertRequestInfo; 71 cert_request_info_ = new net::SSLCertRequestInfo;
72 cert_request_info_->host_and_port = net::HostPortPair("foo", 123); 72 cert_request_info_->host_and_port = net::HostPortPair("foo", 123);
73 cert_request_info_->client_certs.push_back(client_cert_1_); 73 cert_request_info_->client_certs.push_back(client_cert_1_);
74 cert_request_info_->client_certs.push_back(client_cert_2_); 74 cert_request_info_->client_certs.push_back(client_cert_2_);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 134 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
135 net::URLRequest* url_request_; 135 net::URLRequest* url_request_;
136 136
137 scoped_refptr<net::X509Certificate> client_cert_1_; 137 scoped_refptr<net::X509Certificate> client_cert_1_;
138 scoped_refptr<net::X509Certificate> client_cert_2_; 138 scoped_refptr<net::X509Certificate> client_cert_2_;
139 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; 139 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_;
140 scoped_refptr<StrictMock<SSLClientAuthRequestorMock> > auth_requestor_; 140 scoped_refptr<StrictMock<SSLClientAuthRequestorMock> > auth_requestor_;
141 // The selector will be deleted when a cert is selected or the tab is closed. 141 // The selector will be deleted when a cert is selected or the tab is closed.
142 SSLClientCertificateSelector* selector_; 142 SSLClientCertificateSelector* selector_;
143 #if defined(USE_NSS) 143 #if defined(USE_NSS_CERTS)
144 crypto::ScopedTestNSSDB test_nssdb_; 144 crypto::ScopedTestNSSDB test_nssdb_;
145 #endif 145 #endif
146 }; 146 };
147 147
148 class SSLClientCertificateSelectorMultiTabTest 148 class SSLClientCertificateSelectorMultiTabTest
149 : public SSLClientCertificateSelectorTest { 149 : public SSLClientCertificateSelectorTest {
150 public: 150 public:
151 void SetUpInProcessBrowserTestFixture() override { 151 void SetUpInProcessBrowserTestFixture() override {
152 SSLClientCertificateSelectorTest::SetUpInProcessBrowserTestFixture(); 152 SSLClientCertificateSelectorTest::SetUpInProcessBrowserTestFixture();
153 153
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( 392 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(
393 browser_1_, ui::VKEY_RETURN, false, false, false, false)); 393 browser_1_, ui::VKEY_RETURN, false, false, false, false));
394 394
395 Mock::VerifyAndClear(auth_requestor_.get()); 395 Mock::VerifyAndClear(auth_requestor_.get());
396 Mock::VerifyAndClear(auth_requestor_1_.get()); 396 Mock::VerifyAndClear(auth_requestor_1_.get());
397 397
398 // Now let the default selection for auth_requestor_ mock get checked on 398 // Now let the default selection for auth_requestor_ mock get checked on
399 // destruction. 399 // destruction.
400 EXPECT_CALL(*auth_requestor_.get(), CancelCertificateSelection()); 400 EXPECT_CALL(*auth_requestor_.get(), CancelCertificateSelection());
401 } 401 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698