| 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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 "c", | 521 "c", |
| 522 "d"); | 522 "d"); |
| 523 EXPECT_EQ(2, service_->cert_count()); | 523 EXPECT_EQ(2, service_->cert_count()); |
| 524 | 524 |
| 525 int error; | 525 int error; |
| 526 std::vector<uint8> types; | 526 std::vector<uint8> types; |
| 527 types.push_back(CLIENT_CERT_ECDSA_SIGN); | 527 types.push_back(CLIENT_CERT_ECDSA_SIGN); |
| 528 TestCompletionCallback callback; | 528 TestCompletionCallback callback; |
| 529 ServerBoundCertService::RequestHandle request_handle; | 529 ServerBoundCertService::RequestHandle request_handle; |
| 530 | 530 |
| 531 // Cert still valid - synchronous completion. | 531 // Cert is valid - synchronous completion. |
| 532 SSLClientCertType type1; | 532 SSLClientCertType type1; |
| 533 std::string private_key_info1, der_cert1; | 533 std::string private_key_info1, der_cert1; |
| 534 error = service_->GetDomainBoundCert( | 534 error = service_->GetDomainBoundCert( |
| 535 "https://good", types, &type1, &private_key_info1, &der_cert1, | 535 "https://good", types, &type1, &private_key_info1, &der_cert1, |
| 536 callback.callback(), &request_handle); | 536 callback.callback(), &request_handle); |
| 537 EXPECT_EQ(OK, error); | 537 EXPECT_EQ(OK, error); |
| 538 EXPECT_FALSE(request_handle.is_active()); | 538 EXPECT_FALSE(request_handle.is_active()); |
| 539 EXPECT_EQ(2, service_->cert_count()); | 539 EXPECT_EQ(2, service_->cert_count()); |
| 540 EXPECT_EQ(CLIENT_CERT_ECDSA_SIGN, type1); | 540 EXPECT_EQ(CLIENT_CERT_ECDSA_SIGN, type1); |
| 541 EXPECT_STREQ("a", private_key_info1.c_str()); | 541 EXPECT_STREQ("a", private_key_info1.c_str()); |
| 542 EXPECT_STREQ("b", der_cert1.c_str()); | 542 EXPECT_STREQ("b", der_cert1.c_str()); |
| 543 | 543 |
| 544 // Cert expired - New cert will be generated, asynchronous completion. | 544 // Expired cert is valid as well - synchronous completion. |
| 545 SSLClientCertType type2; | 545 SSLClientCertType type2; |
| 546 std::string private_key_info2, der_cert2; | 546 std::string private_key_info2, der_cert2; |
| 547 error = service_->GetDomainBoundCert( | 547 error = service_->GetDomainBoundCert( |
| 548 "https://expired", types, &type2, &private_key_info2, &der_cert2, | 548 "https://expired", types, &type2, &private_key_info2, &der_cert2, |
| 549 callback.callback(), &request_handle); | 549 callback.callback(), &request_handle); |
| 550 EXPECT_EQ(ERR_IO_PENDING, error); | |
| 551 EXPECT_TRUE(request_handle.is_active()); | |
| 552 error = callback.WaitForResult(); | |
| 553 EXPECT_EQ(OK, error); | 550 EXPECT_EQ(OK, error); |
| 551 EXPECT_FALSE(request_handle.is_active()); |
| 554 EXPECT_EQ(2, service_->cert_count()); | 552 EXPECT_EQ(2, service_->cert_count()); |
| 555 EXPECT_EQ(CLIENT_CERT_ECDSA_SIGN, type2); | 553 EXPECT_EQ(CLIENT_CERT_ECDSA_SIGN, type2); |
| 556 EXPECT_LT(1U, private_key_info2.size()); | 554 EXPECT_STREQ("c", private_key_info2.c_str()); |
| 557 EXPECT_LT(1U, der_cert2.size()); | 555 EXPECT_STREQ("d", der_cert2.c_str()); |
| 558 } | 556 } |
| 559 | 557 |
| 560 #endif // !defined(USE_OPENSSL) | 558 #endif // !defined(USE_OPENSSL) |
| 561 | 559 |
| 562 } // namespace | 560 } // namespace |
| 563 | 561 |
| 564 } // namespace net | 562 } // namespace net |
| OLD | NEW |