| 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 "net/ssl/server_bound_cert_service.h" | 5 #include "net/ssl/server_bound_cert_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 public: | 31 public: |
| 32 ServerBoundCertServiceTest() | 32 ServerBoundCertServiceTest() |
| 33 : sequenced_worker_pool_(new base::SequencedWorkerPool( | 33 : sequenced_worker_pool_(new base::SequencedWorkerPool( |
| 34 3, "ServerBoundCertServiceTest")), | 34 3, "ServerBoundCertServiceTest")), |
| 35 service_(new ServerBoundCertService( | 35 service_(new ServerBoundCertService( |
| 36 new DefaultServerBoundCertStore(NULL), | 36 new DefaultServerBoundCertStore(NULL), |
| 37 sequenced_worker_pool_)) { | 37 sequenced_worker_pool_)) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 virtual ~ServerBoundCertServiceTest() { | 40 virtual ~ServerBoundCertServiceTest() { |
| 41 if (sequenced_worker_pool_) | 41 if (sequenced_worker_pool_.get()) |
| 42 sequenced_worker_pool_->Shutdown(); | 42 sequenced_worker_pool_->Shutdown(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 protected: | 45 protected: |
| 46 scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_; | 46 scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_; |
| 47 scoped_ptr<ServerBoundCertService> service_; | 47 scoped_ptr<ServerBoundCertService> service_; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 TEST_F(ServerBoundCertServiceTest, GetDomainForHost) { | 50 TEST_F(ServerBoundCertServiceTest, GetDomainForHost) { |
| 51 EXPECT_EQ("google.com", | 51 EXPECT_EQ("google.com", |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 // Check that we can retrieve the key from the bytes. | 316 // Check that we can retrieve the key from the bytes. |
| 317 std::vector<uint8> key_vec(private_key_info.begin(), private_key_info.end()); | 317 std::vector<uint8> key_vec(private_key_info.begin(), private_key_info.end()); |
| 318 scoped_ptr<crypto::ECPrivateKey> private_key( | 318 scoped_ptr<crypto::ECPrivateKey> private_key( |
| 319 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 319 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
| 320 ServerBoundCertService::kEPKIPassword, key_vec, spki)); | 320 ServerBoundCertService::kEPKIPassword, key_vec, spki)); |
| 321 EXPECT_TRUE(private_key != NULL); | 321 EXPECT_TRUE(private_key != NULL); |
| 322 | 322 |
| 323 // Check that we can retrieve the cert from the bytes. | 323 // Check that we can retrieve the cert from the bytes. |
| 324 scoped_refptr<X509Certificate> x509cert( | 324 scoped_refptr<X509Certificate> x509cert( |
| 325 X509Certificate::CreateFromBytes(der_cert.data(), der_cert.size())); | 325 X509Certificate::CreateFromBytes(der_cert.data(), der_cert.size())); |
| 326 EXPECT_TRUE(x509cert != NULL); | 326 EXPECT_TRUE(x509cert.get() != NULL); |
| 327 } | 327 } |
| 328 | 328 |
| 329 // Tests that the callback of a canceled request is never made. | 329 // Tests that the callback of a canceled request is never made. |
| 330 TEST_F(ServerBoundCertServiceTest, CancelRequest) { | 330 TEST_F(ServerBoundCertServiceTest, CancelRequest) { |
| 331 std::string host("encrypted.google.com"); | 331 std::string host("encrypted.google.com"); |
| 332 SSLClientCertType type; | 332 SSLClientCertType type; |
| 333 std::string private_key_info, der_cert; | 333 std::string private_key_info, der_cert; |
| 334 int error; | 334 int error; |
| 335 std::vector<uint8> types; | 335 std::vector<uint8> types; |
| 336 types.push_back(CLIENT_CERT_ECDSA_SIGN); | 336 types.push_back(CLIENT_CERT_ECDSA_SIGN); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 EXPECT_EQ(CLIENT_CERT_ECDSA_SIGN, type2); | 589 EXPECT_EQ(CLIENT_CERT_ECDSA_SIGN, type2); |
| 590 EXPECT_STREQ("c", private_key_info2.c_str()); | 590 EXPECT_STREQ("c", private_key_info2.c_str()); |
| 591 EXPECT_STREQ("d", der_cert2.c_str()); | 591 EXPECT_STREQ("d", der_cert2.c_str()); |
| 592 } | 592 } |
| 593 | 593 |
| 594 #endif // !defined(USE_OPENSSL) | 594 #endif // !defined(USE_OPENSSL) |
| 595 | 595 |
| 596 } // namespace | 596 } // namespace |
| 597 | 597 |
| 598 } // namespace net | 598 } // namespace net |
| OLD | NEW |