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

Side by Side Diff: net/base/origin_bound_cert_service_unittest.cc

Issue 8890073: Handle Origin Bound Certificate expiration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review changes Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « net/base/origin_bound_cert_service.cc ('k') | net/base/origin_bound_cert_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/origin_bound_cert_service.h" 5 #include "net/base/origin_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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 EXPECT_EQ(ERR_IO_PENDING, error); 450 EXPECT_EQ(ERR_IO_PENDING, error);
451 EXPECT_TRUE(request_handle != NULL); 451 EXPECT_TRUE(request_handle != NULL);
452 error = callback.WaitForResult(); 452 error = callback.WaitForResult();
453 } 453 }
454 454
455 // Even though the original request was cancelled, the service will still 455 // Even though the original request was cancelled, the service will still
456 // store the result, it just doesn't call the callback. 456 // store the result, it just doesn't call the callback.
457 EXPECT_EQ(6, service->cert_count()); 457 EXPECT_EQ(6, service->cert_count());
458 } 458 }
459 459
460 TEST(OriginBoundCertServiceTest, Expiration) {
461 OriginBoundCertStore* store = new DefaultOriginBoundCertStore(NULL);
462 store->SetOriginBoundCert("https://good",
463 CLIENT_CERT_RSA_SIGN,
464 base::Time::Now() + base::TimeDelta::FromDays(1),
465 "a",
466 "b");
467 store->SetOriginBoundCert("https://expired",
468 CLIENT_CERT_RSA_SIGN,
469 base::Time::Now() - base::TimeDelta::FromDays(1),
470 "c",
471 "d");
472 OriginBoundCertService service(store);
473 EXPECT_EQ(2, service.cert_count());
474
475 int error;
476 std::vector<uint8> types;
477 types.push_back(CLIENT_CERT_RSA_SIGN);
478 TestCompletionCallback callback;
479 OriginBoundCertService::RequestHandle request_handle;
480
481 // Cert still valid - synchronous completion.
482 SSLClientCertType type1;
483 std::string private_key_info1, der_cert1;
484 error = service.GetOriginBoundCert(
485 "https://good", types, &type1, &private_key_info1, &der_cert1,
486 callback.callback(), &request_handle);
487 EXPECT_EQ(OK, error);
488 EXPECT_TRUE(request_handle == NULL);
489 EXPECT_EQ(2, service.cert_count());
490 EXPECT_EQ(CLIENT_CERT_RSA_SIGN, type1);
491 EXPECT_STREQ("a", private_key_info1.c_str());
492 EXPECT_STREQ("b", der_cert1.c_str());
493
494 // Cert expired - New cert will be generated, asynchronous completion.
495 SSLClientCertType type2;
496 std::string private_key_info2, der_cert2;
497 error = service.GetOriginBoundCert(
498 "https://expired", types, &type2, &private_key_info2, &der_cert2,
499 callback.callback(), &request_handle);
500 EXPECT_EQ(ERR_IO_PENDING, error);
501 EXPECT_TRUE(request_handle != NULL);
502 error = callback.WaitForResult();
503 EXPECT_EQ(OK, error);
504 EXPECT_EQ(2, service.cert_count());
505 EXPECT_EQ(CLIENT_CERT_RSA_SIGN, type2);
506 EXPECT_LT(1U, private_key_info2.size());
507 EXPECT_LT(1U, der_cert2.size());
508 }
509
460 #endif // !defined(USE_OPENSSL) 510 #endif // !defined(USE_OPENSSL)
461 511
462 } // namespace 512 } // namespace
463 513
464 } // namespace net 514 } // namespace net
OLDNEW
« no previous file with comments | « net/base/origin_bound_cert_service.cc ('k') | net/base/origin_bound_cert_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698