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

Unified Diff: net/base/keygen_handler_unittest.cc

Issue 843005: Adds support for the <keygen> element to Windows, matching support present on... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Fixing remaining issues Created 10 years, 9 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/keygen_handler_nss.cc ('k') | net/base/keygen_handler_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/keygen_handler_unittest.cc
===================================================================
--- net/base/keygen_handler_unittest.cc (revision 43235)
+++ net/base/keygen_handler_unittest.cc (working copy)
@@ -14,6 +14,20 @@
namespace {
+KeygenHandler::Location ValidLocation() {
+ KeygenHandler::Location result;
+#if defined(OS_WIN)
+ result.container_name = L"Unit tests";
+ result.provider_name = L"Test Provider";
+#elif defined(OS_MACOSX)
+ result.keychain_path = "/Users/tests/test.chain";
+#elif defined(USE_NSS)
+ result.slot_name = "Sample slot";
+#endif
+
+ return result;
+}
+
TEST(KeygenHandlerTest, FLAKY_SmokeTest) {
KeygenHandler handler(2048, "some challenge");
handler.set_stores_key(false); // Don't leave the key-pair behind
@@ -51,6 +65,34 @@
// openssl asn1parse -inform DER
}
+TEST(KeygenHandlerTest, Cache) {
+ KeygenHandler::Cache* cache = KeygenHandler::Cache::GetInstance();
+ KeygenHandler::Location location1;
+ KeygenHandler::Location location2;
+
+ std::string key1("abcd");
+ cache->Insert(key1, location1);
+
+ // The cache should have stored location1 at key1
+ EXPECT_TRUE(cache->Find(key1, &location2));
+
+ // The cache should have retrieved it into location2, and their equality
+ // should be reflexive
+ EXPECT_TRUE(location1.Equals(location2));
+ EXPECT_TRUE(location2.Equals(location1));
+
+ location2 = ValidLocation();
+ KeygenHandler::KeyCache::KeyLocation location3 = ValidLocation();
+ EXPECT_FALSE(location1.Equals(location2));
+
+ // The cache should miss for an unregistered key
+ std::string key2("def");
+ EXPECT_FALSE(cache->Find(key2, &location2));
+
+ // A cache miss should leave the original location unmolested
+ EXPECT_TRUE(location2.Equals(location3));
+}
+
} // namespace
} // namespace net
« no previous file with comments | « net/base/keygen_handler_nss.cc ('k') | net/base/keygen_handler_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698