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

Side by Side Diff: content/browser/loader/resource_loader_unittest.cc

Issue 1304143010: Plumbing SSLPrivateKey Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase. Created 4 years, 10 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) 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 #include <utility> 9 #include <utility>
10 10
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 451
452 ++call_count_; 452 ++call_count_;
453 passed_certs_ = cert_request_info->client_certs; 453 passed_certs_ = cert_request_info->client_certs;
454 delegate_ = std::move(delegate); 454 delegate_ = std::move(delegate);
455 select_certificate_run_loop_.Quit(); 455 select_certificate_run_loop_.Quit();
456 } 456 }
457 457
458 int call_count() { return call_count_; } 458 int call_count() { return call_count_; }
459 net::CertificateList passed_certs() { return passed_certs_; } 459 net::CertificateList passed_certs() { return passed_certs_; }
460 460
461 void ContinueWithCertificate(net::X509Certificate* cert) { 461 void ContinueWithCertificate(net::X509Certificate* cert,
462 delegate_->ContinueWithCertificate(cert); 462 net::SSLPrivateKey* private_key) {
463 delegate_->ContinueWithCertificate(cert, private_key);
463 delegate_.reset(); 464 delegate_.reset();
464 } 465 }
465 466
466 void CancelCertificateSelection() { delegate_.reset(); } 467 void CancelCertificateSelection() { delegate_.reset(); }
467 468
468 private: 469 private:
469 net::CertificateList passed_certs_; 470 net::CertificateList passed_certs_;
470 int call_count_; 471 int call_count_;
471 scoped_ptr<ClientCertificateDelegate> delegate_; 472 scoped_ptr<ClientCertificateDelegate> delegate_;
472 473
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 // Check if the test store was queried against correct |cert_authorities|. 710 // Check if the test store was queried against correct |cert_authorities|.
710 EXPECT_EQ(1, store_request_count); 711 EXPECT_EQ(1, store_request_count);
711 EXPECT_EQ(MockClientCertURLRequestJob::test_authorities(), 712 EXPECT_EQ(MockClientCertURLRequestJob::test_authorities(),
712 store_requested_authorities); 713 store_requested_authorities);
713 714
714 // Check if the retrieved certificates were passed to the content browser 715 // Check if the retrieved certificates were passed to the content browser
715 // client. 716 // client.
716 EXPECT_EQ(1, test_client.call_count()); 717 EXPECT_EQ(1, test_client.call_count());
717 EXPECT_EQ(dummy_certs, test_client.passed_certs()); 718 EXPECT_EQ(dummy_certs, test_client.passed_certs());
718 719
719 // Continue the request. 720 // Continue the request with no certificate.
720 test_client.ContinueWithCertificate(nullptr); 721 test_client.ContinueWithCertificate(nullptr, nullptr);
721 raw_ptr_resource_handler_->WaitForResponseComplete(); 722 raw_ptr_resource_handler_->WaitForResponseComplete();
722 EXPECT_EQ(net::OK, raw_ptr_resource_handler_->status().error()); 723 EXPECT_EQ(net::OK, raw_ptr_resource_handler_->status().error());
723 724
724 // Restore the original content browser client. 725 // Restore the original content browser client.
725 SetBrowserClientForTesting(old_client); 726 SetBrowserClientForTesting(old_client);
726 } 727 }
727 728
728 // Tests that client certificates are requested on a platform with NULL 729 // Tests that client certificates are requested on a platform with NULL
729 // ClientCertStore. 730 // ClientCertStore.
730 TEST_F(ClientCertResourceLoaderTest, WithNullStore) { 731 TEST_F(ClientCertResourceLoaderTest, WithNullStore) {
731 // Plug in test content browser client. 732 // Plug in test content browser client.
732 SelectCertificateBrowserClient test_client; 733 SelectCertificateBrowserClient test_client;
733 ContentBrowserClient* old_client = SetBrowserClientForTesting(&test_client); 734 ContentBrowserClient* old_client = SetBrowserClientForTesting(&test_client);
734 735
735 // Start the request and wait for it to pause. 736 // Start the request and wait for it to pause.
736 loader_->StartRequest(); 737 loader_->StartRequest();
737 test_client.WaitForSelectCertificate(); 738 test_client.WaitForSelectCertificate();
738 739
739 // Check if the SelectClientCertificate was called on the content browser 740 // Check if the SelectClientCertificate was called on the content browser
740 // client. 741 // client.
741 EXPECT_EQ(1, test_client.call_count()); 742 EXPECT_EQ(1, test_client.call_count());
742 EXPECT_EQ(net::CertificateList(), test_client.passed_certs()); 743 EXPECT_EQ(net::CertificateList(), test_client.passed_certs());
743 744
744 // Continue the request. 745 // Continue the request with no certificate.
745 test_client.ContinueWithCertificate(nullptr); 746 test_client.ContinueWithCertificate(nullptr, nullptr);
746 raw_ptr_resource_handler_->WaitForResponseComplete(); 747 raw_ptr_resource_handler_->WaitForResponseComplete();
747 EXPECT_EQ(net::OK, raw_ptr_resource_handler_->status().error()); 748 EXPECT_EQ(net::OK, raw_ptr_resource_handler_->status().error());
748 749
749 // Restore the original content browser client. 750 // Restore the original content browser client.
750 SetBrowserClientForTesting(old_client); 751 SetBrowserClientForTesting(old_client);
751 } 752 }
752 753
753 // Tests that the ContentBrowserClient may cancel a certificate request. 754 // Tests that the ContentBrowserClient may cancel a certificate request.
754 TEST_F(ClientCertResourceLoaderTest, CancelSelection) { 755 TEST_F(ClientCertResourceLoaderTest, CancelSelection) {
755 // Plug in test content browser client. 756 // Plug in test content browser client.
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 ASSERT_TRUE( 1148 ASSERT_TRUE(
1148 CertStore::GetInstance()->RetrieveCert(deserialized.cert_id, &cert)); 1149 CertStore::GetInstance()->RetrieveCert(deserialized.cert_id, &cert));
1149 EXPECT_TRUE(cert->Equals(GetTestCert().get())); 1150 EXPECT_TRUE(cert->Equals(GetTestCert().get()));
1150 1151
1151 EXPECT_EQ(kTestCertError, deserialized.cert_status); 1152 EXPECT_EQ(kTestCertError, deserialized.cert_status);
1152 EXPECT_EQ(kTestConnectionStatus, deserialized.connection_status); 1153 EXPECT_EQ(kTestConnectionStatus, deserialized.connection_status);
1153 EXPECT_EQ(kTestSecurityBits, deserialized.security_bits); 1154 EXPECT_EQ(kTestSecurityBits, deserialized.security_bits);
1154 } 1155 }
1155 1156
1156 } // namespace content 1157 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_loader.cc ('k') | content/browser/ssl/ssl_client_auth_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698