Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/ssl_client_auth_cache.h" | 5 #include "net/base/ssl_client_auth_cache.h" |
| 6 | 6 |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "net/base/x509_certificate.h" | 8 #include "net/base/x509_certificate.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 EXPECT_TRUE(cache.Lookup(server1, &cached_cert)); | 130 EXPECT_TRUE(cache.Lookup(server1, &cached_cert)); |
| 131 EXPECT_EQ(cert1, cached_cert); | 131 EXPECT_EQ(cert1, cached_cert); |
| 132 | 132 |
| 133 // Replace the specific preference with a NULL certificate. | 133 // Replace the specific preference with a NULL certificate. |
| 134 cache.Add(server1, NULL); | 134 cache.Add(server1, NULL); |
| 135 cached_cert = NULL; | 135 cached_cert = NULL; |
| 136 EXPECT_TRUE(cache.Lookup(server1, &cached_cert)); | 136 EXPECT_TRUE(cache.Lookup(server1, &cached_cert)); |
| 137 EXPECT_EQ(NULL, cached_cert.get()); | 137 EXPECT_EQ(NULL, cached_cert.get()); |
| 138 } | 138 } |
| 139 | 139 |
| 140 // Check that the Clear() method removes all mappings. | |
|
wtc
2011/02/15 20:50:40
Nit: mappings => cache entries
or ca
Ryan Hamilton
2011/02/16 17:44:40
Done.
| |
| 141 TEST(SSLClientAuthCacheTest, Clear) { | |
| 142 SSLClientAuthCache cache; | |
| 143 base::Time start_date = base::Time::Now(); | |
| 144 base::Time expiration_date = start_date + base::TimeDelta::FromDays(1); | |
| 145 | |
| 146 std::string server1("foo:443"); | |
| 147 scoped_refptr<X509Certificate> cert1( | |
| 148 new X509Certificate("foo", "CA", start_date, expiration_date)); | |
| 149 | |
| 150 cache.Add(server1, cert1); | |
| 151 | |
| 152 std::string server2("foo2:443"); | |
| 153 cache.Add(server2, NULL); | |
| 154 | |
| 155 scoped_refptr<X509Certificate> cached_cert(cert1); | |
| 156 | |
| 157 // Demonstrate the set up is correct. | |
| 158 EXPECT_TRUE(cache.Lookup(server1, &cached_cert)); | |
| 159 EXPECT_EQ(cert1, cached_cert); | |
| 160 | |
| 161 EXPECT_TRUE(cache.Lookup(server2, &cached_cert)); | |
| 162 EXPECT_EQ(NULL, cached_cert.get()); | |
| 163 | |
| 164 cache.Clear(); | |
| 165 | |
| 166 // Check that we no longer have mappings for | |
| 167 // either server. | |
| 168 EXPECT_FALSE(cache.Lookup(server1, &cached_cert)); | |
| 169 EXPECT_FALSE(cache.Lookup(server2, &cached_cert)); | |
| 170 } | |
| 171 | |
| 140 } // namespace net | 172 } // namespace net |
| OLD | NEW |