| OLD | NEW |
| 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 423 |
| 424 task_runner_->RunUntilIdle(); | 424 task_runner_->RunUntilIdle(); |
| 425 EXPECT_EQ(1u, certs.size()); | 425 EXPECT_EQ(1u, certs.size()); |
| 426 } | 426 } |
| 427 | 427 |
| 428 // Trying to sign data using the exposed SSLPrivateKey must cause a sign | 428 // Trying to sign data using the exposed SSLPrivateKey must cause a sign |
| 429 // request. The reply must be correctly routed back to the private key. | 429 // request. The reply must be correctly routed back to the private key. |
| 430 TEST_F(CertificateProviderServiceTest, SignRequest) { | 430 TEST_F(CertificateProviderServiceTest, SignRequest) { |
| 431 ProvideDefaultCert(); | 431 ProvideDefaultCert(); |
| 432 | 432 |
| 433 scoped_ptr<net::SSLPrivateKey> private_key( | 433 scoped_refptr<net::SSLPrivateKey> private_key( |
| 434 client_key_store_->FetchClientCertPrivateKey(*cert_info1_.certificate)); | 434 client_key_store_->FetchClientCertPrivateKey(*cert_info1_.certificate)); |
| 435 | 435 |
| 436 ASSERT_TRUE(private_key); | 436 ASSERT_TRUE(private_key); |
| 437 EXPECT_TRUE(IsKeyEqualToCertInfo(cert_info1_, private_key.get())); | 437 EXPECT_TRUE(IsKeyEqualToCertInfo(cert_info1_, private_key.get())); |
| 438 | 438 |
| 439 test_delegate_->ClearAndExpectRequest(TestDelegate::RequestType::SIGN); | 439 test_delegate_->ClearAndExpectRequest(TestDelegate::RequestType::SIGN); |
| 440 | 440 |
| 441 std::vector<uint8_t> received_signature; | 441 std::vector<uint8_t> received_signature; |
| 442 private_key->SignDigest( | 442 private_key->SignDigest( |
| 443 net::SSLPrivateKey::Hash::SHA256, std::string("any input data"), | 443 net::SSLPrivateKey::Hash::SHA256, std::string("any input data"), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 460 signature_reply.push_back(8); | 460 signature_reply.push_back(8); |
| 461 service_->ReplyToSignRequest(kExtension1, sign_request_id, signature_reply); | 461 service_->ReplyToSignRequest(kExtension1, sign_request_id, signature_reply); |
| 462 | 462 |
| 463 task_runner_->RunUntilIdle(); | 463 task_runner_->RunUntilIdle(); |
| 464 EXPECT_EQ(signature_reply, received_signature); | 464 EXPECT_EQ(signature_reply, received_signature); |
| 465 } | 465 } |
| 466 | 466 |
| 467 TEST_F(CertificateProviderServiceTest, UnloadExtensionDuringSign) { | 467 TEST_F(CertificateProviderServiceTest, UnloadExtensionDuringSign) { |
| 468 ProvideDefaultCert(); | 468 ProvideDefaultCert(); |
| 469 | 469 |
| 470 scoped_ptr<net::SSLPrivateKey> private_key( | 470 scoped_refptr<net::SSLPrivateKey> private_key( |
| 471 client_key_store_->FetchClientCertPrivateKey(*cert_info1_.certificate)); | 471 client_key_store_->FetchClientCertPrivateKey(*cert_info1_.certificate)); |
| 472 ASSERT_TRUE(private_key); | 472 ASSERT_TRUE(private_key); |
| 473 | 473 |
| 474 test_delegate_->ClearAndExpectRequest(TestDelegate::RequestType::SIGN); | 474 test_delegate_->ClearAndExpectRequest(TestDelegate::RequestType::SIGN); |
| 475 | 475 |
| 476 net::Error error = net::OK; | 476 net::Error error = net::OK; |
| 477 private_key->SignDigest( | 477 private_key->SignDigest( |
| 478 net::SSLPrivateKey::Hash::SHA256, std::string("any input data"), | 478 net::SSLPrivateKey::Hash::SHA256, std::string("any input data"), |
| 479 base::Bind(&ExpectEmptySignatureAndStoreError, &error)); | 479 base::Bind(&ExpectEmptySignatureAndStoreError, &error)); |
| 480 | 480 |
| 481 task_runner_->RunUntilIdle(); | 481 task_runner_->RunUntilIdle(); |
| 482 | 482 |
| 483 // No signature received until the extension replied to the service or is | 483 // No signature received until the extension replied to the service or is |
| 484 // unloaded. | 484 // unloaded. |
| 485 EXPECT_EQ(net::OK, error); | 485 EXPECT_EQ(net::OK, error); |
| 486 | 486 |
| 487 // Unload the extension. | 487 // Unload the extension. |
| 488 service_->OnExtensionUnloaded(kExtension1); | 488 service_->OnExtensionUnloaded(kExtension1); |
| 489 | 489 |
| 490 task_runner_->RunUntilIdle(); | 490 task_runner_->RunUntilIdle(); |
| 491 EXPECT_EQ(net::ERR_FAILED, error); | 491 EXPECT_EQ(net::ERR_FAILED, error); |
| 492 } | 492 } |
| 493 | 493 |
| 494 } // namespace chromeos | 494 } // namespace chromeos |
| OLD | NEW |