Chromium Code Reviews| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 // Asynchronous completion with no certs in the store. | 522 // Asynchronous completion with no certs in the store. |
| 523 std::string private_key_info, der_cert; | 523 std::string private_key_info, der_cert; |
| 524 EXPECT_EQ(0, service_->cert_count()); | 524 EXPECT_EQ(0, service_->cert_count()); |
| 525 error = service_->GetDomainBoundCert( | 525 error = service_->GetDomainBoundCert( |
| 526 host, &private_key_info, &der_cert, callback.callback(), &request_handle); | 526 host, &private_key_info, &der_cert, callback.callback(), &request_handle); |
| 527 EXPECT_EQ(ERR_IO_PENDING, error); | 527 EXPECT_EQ(ERR_IO_PENDING, error); |
| 528 EXPECT_TRUE(request_handle.is_active()); | 528 EXPECT_TRUE(request_handle.is_active()); |
| 529 | 529 |
| 530 mock_store->CallGetServerBoundCertCallbackWithResult( | 530 mock_store->CallGetServerBoundCertCallbackWithResult( |
| 531 ERR_FILE_NOT_FOUND, base::Time(), std::string(), std::string()); | 531 ERR_FILE_NOT_FOUND, base::Time(), std::string(), std::string()); |
| 532 // Wait for any posted ServerBoundCertServiceWorkers to finish. | |
| 533 // (By calling CallGetServerBoundCertCallbackWithResult, callbacks are | |
| 534 // called directly, short-circuiting ServerBoundCertService's usual | |
| 535 // bookkeeping.) | |
| 536 sequenced_worker_pool_->FlushForTesting(); | |
| 537 base::MessageLoop::current()->RunUntilIdle(); | |
|
Ryan Sleevi
2013/08/08 23:18:46
Consider updating the comments to be more descript
juanlang
2013/08/08 23:51:08
Done, I think. The rationale is different, and unl
| |
| 532 | 538 |
| 533 error = callback.WaitForResult(); | 539 error = callback.WaitForResult(); |
| 534 EXPECT_EQ(OK, error); | 540 EXPECT_EQ(OK, error); |
| 535 EXPECT_EQ(1, service_->cert_count()); | 541 EXPECT_EQ(1, service_->cert_count()); |
| 536 EXPECT_FALSE(private_key_info.empty()); | 542 EXPECT_FALSE(private_key_info.empty()); |
| 537 EXPECT_FALSE(der_cert.empty()); | 543 EXPECT_FALSE(der_cert.empty()); |
| 538 EXPECT_FALSE(request_handle.is_active()); | 544 EXPECT_FALSE(request_handle.is_active()); |
| 539 } | 545 } |
| 540 | 546 |
| 541 TEST_F(ServerBoundCertServiceTest, AsyncStoreGetOneCertInStore) { | 547 TEST_F(ServerBoundCertServiceTest, AsyncStoreGetOneCertInStore) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 553 // Asynchronous completion with a cert in the store. | 559 // Asynchronous completion with a cert in the store. |
| 554 std::string private_key_info, der_cert; | 560 std::string private_key_info, der_cert; |
| 555 EXPECT_EQ(0, service_->cert_count()); | 561 EXPECT_EQ(0, service_->cert_count()); |
| 556 error = service_->GetDomainBoundCert( | 562 error = service_->GetDomainBoundCert( |
| 557 host, &private_key_info, &der_cert, callback.callback(), &request_handle); | 563 host, &private_key_info, &der_cert, callback.callback(), &request_handle); |
| 558 EXPECT_EQ(ERR_IO_PENDING, error); | 564 EXPECT_EQ(ERR_IO_PENDING, error); |
| 559 EXPECT_TRUE(request_handle.is_active()); | 565 EXPECT_TRUE(request_handle.is_active()); |
| 560 | 566 |
| 561 mock_store->CallGetServerBoundCertCallbackWithResult( | 567 mock_store->CallGetServerBoundCertCallbackWithResult( |
| 562 OK, base::Time(), "ab", "cd"); | 568 OK, base::Time(), "ab", "cd"); |
| 569 // Wait for any posted ServerBoundCertServiceWorkers to finish. | |
| 570 // (By calling CallGetServerBoundCertCallbackWithResult, callbacks are | |
| 571 // called directly, short-circuiting ServerBoundCertService's usual | |
| 572 // bookkeeping.) | |
| 573 sequenced_worker_pool_->FlushForTesting(); | |
| 574 base::MessageLoop::current()->RunUntilIdle(); | |
| 563 | 575 |
| 564 error = callback.WaitForResult(); | 576 error = callback.WaitForResult(); |
| 565 EXPECT_EQ(OK, error); | 577 EXPECT_EQ(OK, error); |
| 566 EXPECT_EQ(1, service_->cert_count()); | 578 EXPECT_EQ(1, service_->cert_count()); |
| 567 EXPECT_EQ(1u, service_->requests()); | 579 EXPECT_EQ(1u, service_->requests()); |
| 568 EXPECT_EQ(1u, service_->cert_store_hits()); | 580 EXPECT_EQ(1u, service_->cert_store_hits()); |
| 569 // Because the cert was found in the store, no new workers should have been | 581 // Because the cert was found in the store, no new workers should have been |
| 570 // created. | 582 // created. |
| 571 EXPECT_EQ(0u, service_->workers_created()); | 583 EXPECT_EQ(0u, service_->workers_created()); |
| 572 EXPECT_STREQ("ab", private_key_info.c_str()); | 584 EXPECT_STREQ("ab", private_key_info.c_str()); |
| 573 EXPECT_STREQ("cd", der_cert.c_str()); | 585 EXPECT_STREQ("cd", der_cert.c_str()); |
| 574 EXPECT_FALSE(request_handle.is_active()); | 586 EXPECT_FALSE(request_handle.is_active()); |
| 575 } | 587 } |
| 576 | 588 |
| 577 #endif // !defined(USE_OPENSSL) | 589 #endif // !defined(USE_OPENSSL) |
| 578 | 590 |
| 579 } // namespace | 591 } // namespace |
| 580 | 592 |
| 581 } // namespace net | 593 } // namespace net |
| OLD | NEW |