OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/http/disk_based_cert_cache.h" | 5 #include "net/http/disk_based_cert_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // Testing the DiskBasedCertCache requires constant use of the | 23 // Testing the DiskBasedCertCache requires constant use of the |
24 // certificates in GetTestCertsDirectory(). The TestCertMetaData | 24 // certificates in GetTestCertsDirectory(). The TestCertMetaData |
25 // struct stores metadata relevant to the DiskBasedCertCache for | 25 // struct stores metadata relevant to the DiskBasedCertCache for |
26 // each used test certificate. | 26 // each used test certificate. |
27 struct TestCertMetaData { | 27 struct TestCertMetaData { |
28 const char* file_name; | 28 const char* file_name; |
29 const char* cache_key; | 29 const char* cache_key; |
30 }; | 30 }; |
31 | 31 |
32 const TestCertMetaData kCert1 = { | 32 const TestCertMetaData kCert1 = { |
33 "root_ca_cert.pem", "cert:4C005EF1CF45F80D4A5A2BCFB00D4F198121E8D4"}; | 33 "root_ca_cert.pem", "cert:738D348A8AFCEC4F79C3E4B1845D985AF601AB0F"}; |
34 | 34 |
35 const TestCertMetaData kCert2 = { | 35 const TestCertMetaData kCert2 = { |
36 "ok_cert.pem", "cert:9174C7CB9E4919604E7B1BFC430E4929DA45F65F"}; | 36 "ok_cert.pem", "cert:6C9DFD2CFA9885C71BE6DE0EA0CF962AC8F9131B"}; |
37 | 37 |
38 // MockTransactions are required to use the MockDiskCache backend. | 38 // MockTransactions are required to use the MockDiskCache backend. |
39 // |key| is a cache key, and is equivalent to the key that will be | 39 // |key| is a cache key, and is equivalent to the key that will be |
40 // used to store or retrieve certificates in the cache. |test_mode| | 40 // used to store or retrieve certificates in the cache. |test_mode| |
41 // is an integer that is used to indicate properties of the test | 41 // is an integer that is used to indicate properties of the test |
42 // transaction, mostly whether or not it is synchronous. | 42 // transaction, mostly whether or not it is synchronous. |
43 // For testing the DiskBasedCertCache, other data members of the struct | 43 // For testing the DiskBasedCertCache, other data members of the struct |
44 // are irrelevant. Only one MockTransaction per certificate can be used | 44 // are irrelevant. Only one MockTransaction per certificate can be used |
45 // at a time. | 45 // at a time. |
46 MockTransaction CreateMockTransaction(const char* key, int test_mode) { | 46 MockTransaction CreateMockTransaction(const char* key, int test_mode) { |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 526 |
527 cache.GetCertificate(kCert1.cache_key, get_callback2.callback()); | 527 cache.GetCertificate(kCert1.cache_key, get_callback2.callback()); |
528 get_callback2.WaitForResult(); | 528 get_callback2.WaitForResult(); |
529 EXPECT_TRUE(X509Certificate::IsSameOSCert(get_callback2.cert_handle(), | 529 EXPECT_TRUE(X509Certificate::IsSameOSCert(get_callback2.cert_handle(), |
530 cert->os_cert_handle())); | 530 cert->os_cert_handle())); |
531 EXPECT_EQ(1U, cache.mem_cache_hits_for_testing()); | 531 EXPECT_EQ(1U, cache.mem_cache_hits_for_testing()); |
532 ASSERT_NO_FATAL_FAILURE(CheckCertCached(&backend, kCert1)); | 532 ASSERT_NO_FATAL_FAILURE(CheckCertCached(&backend, kCert1)); |
533 } | 533 } |
534 | 534 |
535 } // namespace net | 535 } // namespace net |
OLD | NEW |