diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-01 18:49:47 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-01 18:49:47 +0000 |
commit | 9aed77b6dace047bff676a7cdcfef345a858d1a7 (patch) | |
tree | fddd5e0fac4ee39b6c79af56871f022472f276d9 /net/base/keygen_handler_unittest.cc | |
parent | 2779491e15b4a157b6351e20bb0f2dd26f6d84de (diff) | |
download | chromium_src-9aed77b6dace047bff676a7cdcfef345a858d1a7.zip chromium_src-9aed77b6dace047bff676a7cdcfef345a858d1a7.tar.gz chromium_src-9aed77b6dace047bff676a7cdcfef345a858d1a7.tar.bz2 |
Adds support for the <keygen> element to Windows, matching
support present on Linux and Mac OS X.
Contributed by Ryan Sleevi <ryan.sleevi@gmail.com>.
Original review URL: http://codereview.chromium.org/843005
R=wtc
BUG=148
TEST=KeygenHandler.SmokeTest
Review URL: http://codereview.chromium.org/1591006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43365 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/keygen_handler_unittest.cc')
-rw-r--r-- | net/base/keygen_handler_unittest.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/net/base/keygen_handler_unittest.cc b/net/base/keygen_handler_unittest.cc index 0022c8e..d73d8e1 100644 --- a/net/base/keygen_handler_unittest.cc +++ b/net/base/keygen_handler_unittest.cc @@ -14,6 +14,20 @@ namespace net { namespace { +KeygenHandler::KeyLocation ValidKeyLocation() { + KeygenHandler::KeyLocation 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 @@ TEST(KeygenHandlerTest, FLAKY_SmokeTest) { // openssl asn1parse -inform DER } +TEST(KeygenHandlerTest, Cache) { + KeygenHandler::Cache* cache = KeygenHandler::Cache::GetInstance(); + KeygenHandler::KeyLocation location1; + KeygenHandler::KeyLocation 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 = ValidKeyLocation(); + KeygenHandler::KeyLocation location3 = ValidKeyLocation(); + 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 |