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

Unified Diff: net/base/tls_client_login_cache_unittest.cc

Issue 6804032: Add TLS-SRP (RFC 5054) support Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: remove "httpsv" scheme, minor NSS/OpenSSL changes Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/tls_client_login_cache.cc ('k') | net/data/ssl/certificates/ok.srpv » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/tls_client_login_cache_unittest.cc
diff --git a/net/base/tls_client_login_cache_unittest.cc b/net/base/tls_client_login_cache_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8c041019e85af49db1fa993c0728ee0436ecbaf1
--- /dev/null
+++ b/net/base/tls_client_login_cache_unittest.cc
@@ -0,0 +1,103 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/tls_client_login_cache.h"
+
+#include "base/time.h"
+#include "base/utf_string_conversions.h"
+#include "net/base/auth.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+TEST(TLSClientLoginCacheTest, LookupAddRemove) {
+ TLSClientLoginCache cache;
+
+ std::string server1("foo1:443");
+ scoped_refptr<AuthData> auth_data1(new AuthData);
+ auth_data1->username = ASCIIToUTF16("user1");
+ auth_data1->password = ASCIIToUTF16("secret1");
+
+ std::string server2("foo2:443");
+ scoped_refptr<AuthData> auth_data2(new AuthData);
+ auth_data2->username = ASCIIToUTF16("user2");
+ auth_data2->password = ASCIIToUTF16("secret2");
+
+ std::string server3("foo3:443");
+ scoped_refptr<AuthData> auth_data3(new AuthData);
+ auth_data3->username = ASCIIToUTF16("user3");
+ auth_data3->password = ASCIIToUTF16("secret3");
+
+ scoped_refptr<AuthData> cached_auth_data;
+ // Lookup non-existent TLS login credentials.
+ cached_auth_data = NULL;
+ EXPECT_FALSE(cache.Lookup(server1, &cached_auth_data));
+
+ // Add TLS login credentials for server1.
+ cache.Add(server1, auth_data1);
+ cached_auth_data = NULL;
+ EXPECT_TRUE(cache.Lookup(server1, &cached_auth_data));
+ EXPECT_EQ(auth_data1, cached_auth_data);
+
+ // Add TLS login credentials for server2.
+ cache.Add(server2, auth_data2);
+ cached_auth_data = NULL;
+ EXPECT_TRUE(cache.Lookup(server1, &cached_auth_data));
+ EXPECT_EQ(auth_data1, cached_auth_data.get());
+ cached_auth_data = NULL;
+ EXPECT_TRUE(cache.Lookup(server2, &cached_auth_data));
+ EXPECT_EQ(auth_data2, cached_auth_data);
+
+ // Overwrite the TLS login credentials for server1.
+ cache.Add(server1, auth_data3);
+ cached_auth_data = NULL;
+ EXPECT_TRUE(cache.Lookup(server1, &cached_auth_data));
+ EXPECT_EQ(auth_data3, cached_auth_data);
+ cached_auth_data = NULL;
+ EXPECT_TRUE(cache.Lookup(server2, &cached_auth_data));
+ EXPECT_EQ(auth_data2, cached_auth_data);
+
+ // Remove TLS login credentials of server1.
+ cache.Remove(server1);
+ cached_auth_data = NULL;
+ EXPECT_FALSE(cache.Lookup(server1, &cached_auth_data));
+ cached_auth_data = NULL;
+ EXPECT_TRUE(cache.Lookup(server2, &cached_auth_data));
+ EXPECT_EQ(auth_data2, cached_auth_data);
+
+ // Remove non-existent TLS login credentials.
+ cache.Remove(server1);
+ cached_auth_data = NULL;
+ EXPECT_FALSE(cache.Lookup(server1, &cached_auth_data));
+ cached_auth_data = NULL;
+ EXPECT_TRUE(cache.Lookup(server2, &cached_auth_data));
+ EXPECT_EQ(auth_data2, cached_auth_data);
+}
+
+// Check that if the server differs only by port number, it is considered
+// a separate server.
+TEST(TLSClientLoginCacheTest, LookupWithPort) {
+ TLSClientLoginCache cache;
+
+ std::string server1("foo1:443");
+ scoped_refptr<AuthData> auth_data1(new AuthData);
+ auth_data1->username = ASCIIToUTF16("user1");
+ auth_data1->password = ASCIIToUTF16("secret1");
+
+ std::string server2("foo2:8443");
+ scoped_refptr<AuthData> auth_data2(new AuthData);
+ auth_data2->username = ASCIIToUTF16("user2");
+ auth_data2->password = ASCIIToUTF16("secret2");
+
+ cache.Add(server1, auth_data1.get());
+ cache.Add(server2, auth_data2.get());
+
+ scoped_refptr<AuthData> cached_auth_data;
+ EXPECT_TRUE(cache.Lookup(server1, &cached_auth_data));
+ EXPECT_EQ(auth_data1.get(), cached_auth_data);
+ EXPECT_TRUE(cache.Lookup(server2, &cached_auth_data));
+ EXPECT_EQ(auth_data2.get(), cached_auth_data);
+}
+
+} // namespace net
« no previous file with comments | « net/base/tls_client_login_cache.cc ('k') | net/data/ssl/certificates/ok.srpv » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698