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

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

Issue 10916094: Move the NSS functions out of CertDatabase into a new NSSCertDatabase class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 3 months 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
OLDNEW
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
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 OnUserCertAdded() method removes all cache entries. 140 // Check that the OnCertAdded() method removes all cache entries.
141 TEST(SSLClientAuthCacheTest, OnUserCertAdded) { 141 TEST(SSLClientAuthCacheTest, OnCertAdded) {
142 SSLClientAuthCache cache; 142 SSLClientAuthCache cache;
143 base::Time start_date = base::Time::Now(); 143 base::Time start_date = base::Time::Now();
144 base::Time expiration_date = start_date + base::TimeDelta::FromDays(1); 144 base::Time expiration_date = start_date + base::TimeDelta::FromDays(1);
145 145
146 std::string server1("foo:443"); 146 std::string server1("foo:443");
147 scoped_refptr<X509Certificate> cert1( 147 scoped_refptr<X509Certificate> cert1(
148 new X509Certificate("foo", "CA", start_date, expiration_date)); 148 new X509Certificate("foo", "CA", start_date, expiration_date));
149 149
150 cache.Add(server1, cert1); 150 cache.Add(server1, cert1);
151 151
152 std::string server2("foo2:443"); 152 std::string server2("foo2:443");
153 cache.Add(server2, NULL); 153 cache.Add(server2, NULL);
154 154
155 scoped_refptr<X509Certificate> cached_cert; 155 scoped_refptr<X509Certificate> cached_cert;
156 156
157 // Demonstrate the set up is correct. 157 // Demonstrate the set up is correct.
158 EXPECT_TRUE(cache.Lookup(server1, &cached_cert)); 158 EXPECT_TRUE(cache.Lookup(server1, &cached_cert));
159 EXPECT_EQ(cert1, cached_cert); 159 EXPECT_EQ(cert1, cached_cert);
160 160
161 EXPECT_TRUE(cache.Lookup(server2, &cached_cert)); 161 EXPECT_TRUE(cache.Lookup(server2, &cached_cert));
162 EXPECT_EQ(NULL, cached_cert.get()); 162 EXPECT_EQ(NULL, cached_cert.get());
163 163
164 cache.OnUserCertAdded(NULL); 164 cache.OnCertAdded(NULL);
165 165
166 // Check that we no longer have entries for either server. 166 // Check that we no longer have entries for either server.
167 EXPECT_FALSE(cache.Lookup(server1, &cached_cert)); 167 EXPECT_FALSE(cache.Lookup(server1, &cached_cert));
168 EXPECT_FALSE(cache.Lookup(server2, &cached_cert)); 168 EXPECT_FALSE(cache.Lookup(server2, &cached_cert));
169 } 169 }
170 170
171 } // namespace net 171 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698