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

Side by Side Diff: chrome/browser/chromeos/certificate_provider/certificate_provider_service_unittest.cc

Issue 1422573008: Plumbing SSLPrivateKey (//net) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing un-needed forward decl. Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chromeos/certificate_provider/certificate_provider_serv ice.h" 5 #include "chrome/browser/chromeos/certificate_provider/certificate_provider_serv ice.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 415
416 task_runner_->RunUntilIdle(); 416 task_runner_->RunUntilIdle();
417 EXPECT_EQ(1u, certs.size()); 417 EXPECT_EQ(1u, certs.size());
418 } 418 }
419 419
420 // Trying to sign data using the exposed SSLPrivateKey must cause a sign 420 // Trying to sign data using the exposed SSLPrivateKey must cause a sign
421 // request. The reply must be correctly routed back to the private key. 421 // request. The reply must be correctly routed back to the private key.
422 TEST_F(CertificateProviderServiceTest, SignRequest) { 422 TEST_F(CertificateProviderServiceTest, SignRequest) {
423 ProvideDefaultCert(); 423 ProvideDefaultCert();
424 424
425 scoped_ptr<net::SSLPrivateKey> private_key( 425 scoped_refptr<net::SSLPrivateKey> private_key(
426 client_key_store_->FetchClientCertPrivateKey(*cert_info1_.certificate)); 426 client_key_store_->FetchClientCertPrivateKey(*cert_info1_.certificate));
427 427
428 ASSERT_TRUE(private_key); 428 ASSERT_TRUE(private_key);
429 EXPECT_TRUE(IsKeyEqualToCertInfo(cert_info1_, private_key.get())); 429 EXPECT_TRUE(IsKeyEqualToCertInfo(cert_info1_, private_key.get()));
430 430
431 test_delegate_->ClearAndExpectRequest(TestDelegate::RequestType::SIGN); 431 test_delegate_->ClearAndExpectRequest(TestDelegate::RequestType::SIGN);
432 432
433 std::vector<uint8_t> received_signature; 433 std::vector<uint8_t> received_signature;
434 private_key->SignDigest( 434 private_key->SignDigest(
435 net::SSLPrivateKey::Hash::SHA256, std::string("any input data"), 435 net::SSLPrivateKey::Hash::SHA256, std::string("any input data"),
(...skipping 16 matching lines...) Expand all
452 signature_reply.push_back(8); 452 signature_reply.push_back(8);
453 service_->ReplyToSignRequest(kExtension1, sign_request_id, signature_reply); 453 service_->ReplyToSignRequest(kExtension1, sign_request_id, signature_reply);
454 454
455 task_runner_->RunUntilIdle(); 455 task_runner_->RunUntilIdle();
456 EXPECT_EQ(signature_reply, received_signature); 456 EXPECT_EQ(signature_reply, received_signature);
457 } 457 }
458 458
459 TEST_F(CertificateProviderServiceTest, UnloadExtensionDuringSign) { 459 TEST_F(CertificateProviderServiceTest, UnloadExtensionDuringSign) {
460 ProvideDefaultCert(); 460 ProvideDefaultCert();
461 461
462 scoped_ptr<net::SSLPrivateKey> private_key( 462 scoped_refptr<net::SSLPrivateKey> private_key(
463 client_key_store_->FetchClientCertPrivateKey(*cert_info1_.certificate)); 463 client_key_store_->FetchClientCertPrivateKey(*cert_info1_.certificate));
464 ASSERT_TRUE(private_key); 464 ASSERT_TRUE(private_key);
465 465
466 test_delegate_->ClearAndExpectRequest(TestDelegate::RequestType::SIGN); 466 test_delegate_->ClearAndExpectRequest(TestDelegate::RequestType::SIGN);
467 467
468 net::Error error = net::OK; 468 net::Error error = net::OK;
469 private_key->SignDigest( 469 private_key->SignDigest(
470 net::SSLPrivateKey::Hash::SHA256, std::string("any input data"), 470 net::SSLPrivateKey::Hash::SHA256, std::string("any input data"),
471 base::Bind(&ExpectEmptySignatureAndStoreError, &error)); 471 base::Bind(&ExpectEmptySignatureAndStoreError, &error));
472 472
473 task_runner_->RunUntilIdle(); 473 task_runner_->RunUntilIdle();
474 474
475 // No signature received until the extension replied to the service or is 475 // No signature received until the extension replied to the service or is
476 // unloaded. 476 // unloaded.
477 EXPECT_EQ(net::OK, error); 477 EXPECT_EQ(net::OK, error);
478 478
479 // Unload the extension. 479 // Unload the extension.
480 service_->OnExtensionUnloaded(kExtension1); 480 service_->OnExtensionUnloaded(kExtension1);
481 481
482 task_runner_->RunUntilIdle(); 482 task_runner_->RunUntilIdle();
483 EXPECT_EQ(net::ERR_FAILED, error); 483 EXPECT_EQ(net::ERR_FAILED, error);
484 } 484 }
485 485
486 } // namespace chromeos 486 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698